I am building DIY SWD debugger for my project. As it seems it works somehow, I am writing this document.
It is not fully tested yet, because software is not ready. Just I tested with current version of Tomek Cedro's modification of OpenOCD. It got IDCODE=EE2805D8 successfully.
SWD (Serial Wire Debug)
SWD (Serial Wire Debug) is an alternative interface of JTAG for ARM-Cortex.
It only requires three wires at minimum (SWDIO, SWDCLK and GND).
You'd say, UART serial line access is possible for three wires (RX, TX and GND) as well (for flash ROM update). But to do so, it is needed to change BOOT0 pin to 1. Thus, if we design a board with UART flash ROM update, it is needed to have jumper pin to pull up BOOT0.
With SWD, we only need to offer three pins.
|Breadboard jumper wires||3|
|USB cable A-miniB||1|
|FT2232D USB Dual 232 module||1|
I am connecting bare FTDI 2232D to STM32F103C8 with resistors.
FTDI 2232D STM32F103C8 AD0 -------------------> SWDCLK/TCLK AD1 -----[1k ]---+-----> SWDIO/TMS AD2 <----[100 ]--/ GND -------------------> GND VCCIOA -- no connection, which results outputs are like open collector.
I don't know exact reason why this connection with resistors (with their values) works. I found the values of resistors by trial-and-error.
OpenOCD with modification for SWD support
I cloned the repo of git://repo.or.cz/openocd/libswd.git .
For detail, see: http://stm32primer2swd.sf.net/
Here is the log:
$ openocd -c "adapter_khz 10" -f interface/openocd-usb-swd.cfg Open On-Chip Debugger 0.5.0-dev-g4e2a176-dirty (2011-08-18-09:58) Licensed under GNU GPL v2 For bug reports, read http://openocd.berlios.de/doc/doxygen/bugs.html 10 kHz Info : only one transport option; autoselect 'swd' Info : New SWD context initialized at 0x091156C0 Info : KT-LINK SWD-Mode initialization complete... Info : clock speed 10 kHz SWD_I: Executing swd_dap_activate(0x91156c0, SWD_OPERATION_EXECUTE) SWD_I: Executing swd_dap_reset(0x91156c0, SWD_OPERATION_EXECUTE) SWD_I: Executing swd_dp_read_idcode(0x91156c0, SWD_OPERATION_EXECUTE) SWD_I: swd_dp_read_idcode() succeeds, IDCODE=EE2805D8 (11101110001010000000010111011000) Info : SWD transport initialization complete. Found IDCODE=0xEE2805D8. Warn : gdb services need one or more targets defined
Here, the content of interface/openocd-usb-swd.cfg is:
interface ft2232_swd ft2232_device_desc "Dual RS232" ft2232_layout ktlink_swd ft2232_vid_pid 0x0403 0x6010 ft2232_latency 2 interface_signal add RnW 0x02
Note that I specify RnW for TDI/DO bit.