Help with st-link

BennehBoy
Fri Jan 27, 2017 11:25 am
I managed to brick one of my maple mini clones when attempting to use victors firmware updater sketch.

I bought an st-link2 clone which arrived today.

I’ve connected ground to ground on the mini, reset to reset on the min, SWCLK to pin 21, and SWDIO to pin 22

I then powered the Mini only by USB (so not 3.3v connection from the st-link2 clone)

The st-link utility reports the following:

11:23:49 : Can not connect to target!
Please select "Connect Under Reset" mode from Target->Settings menu and try again.
If you're trying to connect to a low frequency application , please select a lower SWD Frequency mode from Target->Settings menu.
11:23:50 : No target connected


BennehBoy
Fri Jan 27, 2017 11:41 am
So I didn’t look hard enough for the ‘Connect Under Reset’ option, found it but still had no luck…

11:40:51 : Can not connect to target!
If you're trying to connect to an STM32W1xx device, please select Normal or HotPlug mode from Target->Settings menu.
If you're trying to connect to a low frequency application , please select a lower SWD Frequency mode from Target->Settings menu.
11:40:53 : No target connected


BennehBoy
Fri Jan 27, 2017 11:43 am
PS, unfortunately the st-link clone only came with 4 dupont leads so I can’t power the board from it just yet – hence why USB power.

BennehBoy
Fri Jan 27, 2017 12:03 pm
Found this russian posts which says reset isn’t needed. http://nuzhen-sovet.ru/content/podklyuc … k-v2-kitay

Removed reset, and powered the board from the st-link, still no leds light on the board and cant connect.

Tried my working board, the leds flash, but still can’t connect.

I’m clearly doing something wrong. I’ve tried a few different frequencies too – default was 4mhz.


racemaniac
Fri Jan 27, 2017 12:10 pm
btw, just a tip if you like working with electronics: at least make sure you’ve got the basic stuff like the wires :).
i’ve got tons of dupont wires (male-male, female-female & female-male) just for the reason you just mentioned: it’s so stupid to not have them when you need them. especially when it costs next to nothing :).

And the last time i had issues with flashing, flashing under reset did work, but i don’t know what exactly i had to do to get it to work. i also fiddled with it until it worked :). (but i did have 5 cables :p )


zmemw16
Fri Jan 27, 2017 12:13 pm
i’ve added a reference to this thread to http://www.stm32duino.com/viewtopic.php?f=10&t=1740
hopefully something on how to unbrick will emerge :)
stephen

BennehBoy
Fri Jan 27, 2017 12:27 pm
racemaniac wrote:btw, just a tip if you like working with electronics: at least make sure you’ve got the basic stuff like the wires :).

ahull
Fri Jan 27, 2017 1:43 pm
Unbricking from Linux…

https://github.com/rogerclarkmelbourne/ … from-Linux

… for what its worth, when I wrote that, I only used 3 “du-pont” wires… It shows how to connect to a Bluepill and the “Uggly board” but it should work with pretty much any stm32fXXX board, so the mm will work too. The version of Linux is not important. So long as the version of openocd is fairly recent you should be fine.

Connecting under reset with openocd will unbrick pretty much any screwup that doesn’t actually result in smoke. :D

Pinout for stm32f103 is

Programmer -> Target

Ground (Green) -> GND

SWDIO (Blue) -> PA13

SWCLK (Yellow) -> PA14

(Colour of wire is up to you of course ;) )

If still dead, unplug the maple mini USB and connect the 3v3 pin from the programmer to 3v3 on the mm and try again.


BennehBoy
Fri Jan 27, 2017 2:23 pm
Thanks, gave that a try but neither board responds.


Open On-Chip Debugger 0.10.0+dev-00001-g0ecee83 (2017-01-27-13:59)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.233618
Error: init mode failed (unable to connect to the target)
in procedure 'init'
in procedure 'ocd_bouncer'


BennehBoy
Fri Jan 27, 2017 2:24 pm
The other possibility of course is that the st-link v2 clone is faulty.

stevestrong
Fri Jan 27, 2017 2:34 pm
Have you updated the V2 firmware?
https://www.youtube.com/watch?v=DC5tlE6XOIg

BennehBoy
Fri Jan 27, 2017 2:36 pm
stevestrong wrote:Have you updated the V2 firmware?
https://www.youtube.com/watch?v=DC5tlE6XOIg

stevestrong
Fri Jan 27, 2017 2:38 pm
Can you connect the STlink to the target with the STlink utility?

BennehBoy
Fri Jan 27, 2017 2:52 pm
stevestrong wrote:Can you connect the STlink to the target with the STlink utility?

victor_pv
Fri Jan 27, 2017 3:02 pm
BennehBoy wrote:stevestrong wrote:Can you connect the STlink to the target with the STlink utility?

BennehBoy
Fri Jan 27, 2017 4:40 pm
Are you sure I should power the target with USB AND 3.3 from the st-link? I thought this would result in magic smoke?

BennehBoy
Fri Jan 27, 2017 4:49 pm
Tried with the settings you supplied (used these earlier too), failed. Tried resetting the board, still fails.

For fear of destroying the board I _did not_ also connect it via USB whilst 3.3 was being supplied to the VCC pin.

Here’s a photo of the wiring:
Image


victor_pv
Fri Jan 27, 2017 4:50 pm
BennehBoy wrote:Are you sure I should power the target with USB AND 3.3 from the st-link? I thought this would result in magic smoke?

BennehBoy
Fri Jan 27, 2017 4:56 pm
It’s steadfastly refusing to connect. :?

I think this st-link clone hardware must be garbage. I can feel a stamping frenzy coming on. :evil:

I continuity checked the dupont leads just for peace of mind, all are good.


racemaniac
Fri Jan 27, 2017 5:02 pm
BennehBoy wrote:It’s steadfastly refusing to connect. :?

I think this st-link clone hardware must be garbage. I can feel a stamping frenzy coming on. :evil:

I continuity checked the dupont leads just for peace of mind, all are good.


BennehBoy
Fri Jan 27, 2017 5:12 pm
racemaniac wrote:
And it’s a good advice that Roger likes to repeat on this forum: always have 2 of whatever you’re working on. it’s cheap chinese stuff, something will be broken or break, and if you then have to wait a month for the replacement to arrive…

victor_pv
Fri Jan 27, 2017 5:51 pm
BennehBoy wrote:racemaniac wrote:
And it’s a good advice that Roger likes to repeat on this forum: always have 2 of whatever you’re working on. it’s cheap chinese stuff, something will be broken or break, and if you then have to wait a month for the replacement to arrive…

BennehBoy
Fri Jan 27, 2017 6:18 pm
I tried both the bricked board and the working one, neither connects.

Just checked continuity and it’s good.

:(

I hope I’m just doing something stupid…


BennehBoy
Fri Jan 27, 2017 6:25 pm
Checked the pins against a schematic and it’s deffo PA13 SWDIO (pin 22) & PA14 SWCLK (pin 21) so it’s not some bizarre pinout change by the manufacturer.

victor_pv
Fri Jan 27, 2017 6:40 pm
Open up the stlink clone and check it out, perhaps the bad solder is there.
The swdio and swdclk pins in the MCU should match the schematics for the stlinks in the nucleo boards, which are widely available. Check continuity on those, gnd, etc.
And it’s possibly about time to order another one of those stlinks ;)

BennehBoy
Fri Jan 27, 2017 7:05 pm
So there looks to be a solder bridge between the bottom two right hand pins of RP1 in this image… Guess would be it’s not supposed to be there?

Image


BennehBoy
Fri Jan 27, 2017 7:20 pm
No change with it removed :(

BennehBoy
Fri Jan 27, 2017 7:27 pm
Seller contacted, fingers crossed they put another (working!) one in the post.

infrared
Mon Jan 30, 2017 9:12 pm
I’m not sure if this is related, but I recently experienced strange behavior from my st-link v2 interface. I have been using a cheap st-link v2 dongle to program/debug stm32f103c8 blue pill boards, and CubeMX to generate the chip configuration and app framework.

Last night, I upgraded my HAL libraries to STM32Cube_FW_F1_V1.4.0, migrated one of my projects via CubeMX, and Openocd programmed the target one time. Openocd managed to get the new firmware into the target, but immediately lost connection with the target. I was never able to establish connection with that target again.

Today, to see if my st-link dongle was dead, I attempted the same thing with a different target. I experienced exactly the same problem… Firmware was downloaded into the target one time, connection was immediately lost, and I am unable to re-establish connection.


ahull
Mon Jan 30, 2017 9:28 pm
I managed to bork a couple of boards by compiling binaries for the wrong processor. This seems to lock things up quite nicely, however connecting the ST-Link v2 under reset has so far always managed to resurrect them.

RogerClark
Mon Jan 30, 2017 10:30 pm
ahull wrote:I managed to bork a couple of boards by compiling binaries for the wrong processor. This seems to lock things up quite nicely, however connecting the ST-Link v2 under reset has so far always managed to resurrect them.

zmemw16
Tue Jan 31, 2017 12:54 am
as each has worked once? inpo ‘ attempting to say/save in no particular order – google fails’
bootloader, target start address, linker address’s ?
stephen

BennehBoy
Thu Feb 02, 2017 8:06 pm
My replacement st-link is probably weeks away.

However today I received a CH340 based USB to Serial adapter

Presumably I can use this to program the board, but how do I get a bootloader .bin uploaded? What tool do I need?

From what I’ve rad I need

tx from the ch340 to rx1 on the mini
rx from the ch340 to tx1 on the mini
gnd to gnd
3.3v to vcc
boot1 tied to ground…

Then what? I’ve got the v2 bootloader bin from github but not sure how to get it onto the device!?!


RogerClark
Thu Feb 02, 2017 8:25 pm
Yes

You can flash with USB to serial

You can even make your own STLink if you have a spare STM32F103 board (albeit the STLink binary is not officially released but is available from various websites (mainly russian ones))

Download ST’s

“Flash loader Demonstrator” PC gui program

(You can use the STM32Flash exe in the repo, but the Gui is easier)


BennehBoy
Thu Feb 02, 2017 8:28 pm
I tried this:

http://jeelabs.org/book/1546c/

the ch340 shows up as ttyUSB0 in ubuntu

Issuing this command whilst holding down ‘button’

./stm32loader.py -p /dev/ttyUSB0 -ewv maple_mini_boot20.bin

results in this:

Traceback (most recent call last):
File "./stm32loader.py", line 434, in <module>
bootversion = cmd.cmdGet()
File "./stm32loader.py", line 118, in cmdGet
if self.cmdGeneric(0x00):
File "./stm32loader.py", line 115, in cmdGeneric
return self._wait_for_ask(hex(cmd))
File "./stm32loader.py", line 80, in _wait_for_ask
raise CmdException("Can't read port or timeout")
__main__.CmdException: Can't read port or timeout


RogerClark
Thu Feb 02, 2017 8:30 pm
Sorry
I forgot you were using Ubuntu

BennehBoy
Thu Feb 02, 2017 8:37 pm
I’ve got win10 too, will give that a go…

BennehBoy
Thu Feb 02, 2017 8:42 pm
1x debricked maple mini YAY

Thanks Roger!


RogerClark
Thu Feb 02, 2017 10:04 pm
Cool!

zmemw16
Thu Feb 02, 2017 10:43 pm
would or could you perhaps brick it again and then do the unbrick from linux to elucidate and enlighten us ? ;)

BennehBoy
Thu Feb 02, 2017 10:46 pm
zmemw16 wrote:would or could you perhaps brick it again and then do the unbrick from linux to elucidate and enlighten us ? ;)

BennehBoy
Thu Feb 02, 2017 10:57 pm
Should be a way to use this method -> https://github.com/rogerclarkmelbourne/ … from-Linux

But it will need a different config for the ch340 usb to serial…

So this line:

while true; do openocd -f /usr/local/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg ; sleep 1;done

Would need to look something like:

while true; do openocd -f /usr/local/share/openocd/scripts/interface/ftdi/ch340.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg ; sleep 1;done

I’m trying to find a suitable config though.


RogerClark
Thu Feb 02, 2017 11:08 pm
Can someone repost to this thread, as I need to check the cacheing

BennehBoy
Thu Feb 02, 2017 11:19 pm
reposted

BennehBoy
Thu Feb 02, 2017 11:25 pm
This could be why I had problems using the python script to do the flashing on linux -> https://sourceforge.net/p/stm32flash/wiki/Hints/

RogerClark
Thu Feb 02, 2017 11:49 pm
This is a test post. I will delete later to test the server caching issues

Leave a Reply

Your email address will not be published. Required fields are marked *