ok, this is not a support topic really just some ramblings on what I doing to try to do firmware debugging (just started) as it might help someone, and also as a reminder to me and thanks to @johannes for helping me get this going!
(Work in progress, I'll add more, as I learn more )
(no blame taken if you get it wrong and blow up your board... (very unlikely but still!))
Hardware connections
First, locate the 7-pin header labeled X3, close to LEDs. The SWD connector is labeled JP1, near X3, and has 5 pins, and comes without pinheader soldered in.
the board looks something like this, well as closely as ASCII graphics can do.
e.g.
βββββββββββ
LEDR LEDG
o o o o o o o (X3)
JP1
o (5) NRST
o (4) SWDIO
o (3) GND
o (2) SWCLK
o (1) VCC
ββββββββββ
you will need to solder in standard header pins, then you can connect with female/female jumper cables.
SWD to STLink/v2 connections
SWD - STLINK/V2
5 - 15 (NRST)
4 - 7 (SWDIO)
3 - 8 (GND)
2 - 9 (SWCLK)
1 - 1 (VCC)
openocd for debugging
command line:
/usr/local/opt/open-ocd/share/openocd/scripts/board/stm32f4discovery.cfg
openocd -f ~/stm32f4discovery.cfg
if this works you will see the following, and the COM light will flash RED/GREEN
Open On-Chip Debugger 0.9.0 (2015-08-08-00:27)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.219895
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
if you get something about low voltage, checkout VCC
example:
Info : Target voltage: 1.009287
Error: target voltage may be too low for reliable debugging
if it doesnβt communication, check SWDIO/SWCLK
example:
Error: init mode failed (unable to connect to the target)
in procedure 'init'
in procedure 'ocd_bouncer'
if you get both, check all your connections