3
\$\begingroup\$

I'm unable to connect to my STM32F4Discovery board using an ST-Link/v2.

I've removed jumpers from CN3, connected the cables correctly but the utility tool won't detect anything...

Using the ST-Link/v2 manual:

PIN1  (VAPP)      -> VDD
PIN7  (TMS_SWDIO) -> PA13
PIN9  (TCK_SWCLK) -> PA14
PIN20 (GND)       -> GND

Here is the physical connection:

enter image description here

And software settings:

enter image description here

This is the error message that I get when trying to connect:

enter image description here

Here is the log message that I get in trace:

ST-Link/V2 device detected
Target voltage detected: 0.601975
Driving NRST low
Error getting target IDCODE: if SWD, check SWD connection
Error (4) while initializing ST-Link in SWD mode

Please help, it's driving me mad...

\$\endgroup\$
  • 1
    \$\begingroup\$ Do you know that the Discovery has an on-board ST-Link? \$\endgroup\$ – Bence Kaulics Apr 23 '16 at 9:40
  • \$\begingroup\$ Yes, but I soldered another SMT32F chip on an adapter board and tried to access it. I couldn't and then fallen back to a device I know it should work (discovery board) and now having the same issues. So I need to make it work on a professional made board and only then I can move with 100% certainty to my own board. \$\endgroup\$ – StjepanV Apr 23 '16 at 9:57
  • \$\begingroup\$ I see, then never mind my comment. \$\endgroup\$ – Bence Kaulics Apr 23 '16 at 10:28
  • 3
    \$\begingroup\$ Although this post was useful to me, I'd like to add that the picture is wrong. You correctly said that: PIN1 -> VDD PIN7 -> PA13 PIN9 -> PA14 PIN20 -> GND But on the picture you have: PIN1 -> VDD PIN9 -> PA13 PIN11 -> PA14 PIN20 -> GND The problem is with google image search engine, lazy people would make wrong connections (as myself on my first attempt hehe). P.D. This should be a comment, but my reputation doesn't allow me yet ;) \$\endgroup\$ – smajtkst Dec 13 '16 at 16:51
  • 1
    \$\begingroup\$ -1 for posting a picture which shows incorrect SWD connections differing from the text as the middle two pins are incorrectly connected off-by-1 at pins 9 and 11 of the STLINK instead of pins 7 and 9 where they belong. \$\endgroup\$ – Chris Stratton Dec 5 '18 at 21:13
9
\$\begingroup\$

Target voltage detected: 0.601975

You need to power your target. The debug adapter does not provide power, it uses the Vtarget pin to determine the output voltage levels.

\$\endgroup\$
  • \$\begingroup\$ Thanks for quick reply! Now that I have connected 3.3V input it starts to blink and all that demo stuff but I have a new error now: ST-Link/V2 device detected Target voltage detected: 3.242133 Error getting target IDCODE: if SWD, check SWD connection Error (4) while initializing ST-Link in SWD mode \$\endgroup\$ – StjepanV Apr 23 '16 at 9:46
  • \$\begingroup\$ "Hardware reset" requires the reset line to be connected. This is apparently not the case. \$\endgroup\$ – Turbo J Apr 23 '16 at 9:52
  • \$\begingroup\$ I connected it now, and it pulls the NRST pin down and it blinks for a moment when I press the connect button and then just throws an error above. And I've tried using Normal mode but it's giving me the same error. \$\endgroup\$ – StjepanV Apr 23 '16 at 9:58
  • 1
    \$\begingroup\$ So, the problem was when I connected discovery board using USB, even though the CN3 jumpers were not connected it still recognized onboard ST-Link v2 and tried to use that one... After painful realization switching it to a external one it worked just fine! Thanks to everybody involved! \$\endgroup\$ – StjepanV Apr 25 '16 at 8:58
1
\$\begingroup\$

Presumably you use the GPIOA port in your source code. If so, first download program to discovery; your code conflicts with swd pins. When you power your board, your source code changes the pa13 and pa14 pins roles. You must connect swd to your board immediately after reset (and do so after power) before loading your code to the CPU.

What should you do? You should erase the flash memory.

First open the STM32 ST-LINK Utility.

  1. push and hold discover black button (nrst button),
  2. click target -> setting,
  3. select "connect under reset” option; at the same time click refresh and release discovery board black button,
  4. repeat until STM32 ST-LINK Utility connect your board,
  5. erase flash memory,
  6. enjoy!
\$\endgroup\$

protected by Community Apr 12 '17 at 18:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.