Tuesday, December 14, 2010

OpenOCD on OS X using flyswatter and stm32 discovery

Making OpenOCD talk to my flyswatter and stm32 discovery using jtag was kind of a pain. I'm going to write up some instructions on how i made it work in case someone else needs it in the future (or i have to do it again).

You need:
a breadboard
an stm32 discovery
a tin can tools flyswatter
OpenOCD from git (0.4.0 doesn't work)
most recent commit on version i'm using is on 12/10/2010, cbf48bed6a26279900ad00e6d6462a7f29676175
libftdi (0.18)
libusb-compat

Instructions:
0) i removed solder bridges 11, 16, 17, and 18 but i'm not sure if that's necessary. i wasn't sure what the ST Link does when you power the board so i just disconnected sb11, sb17, and sb18. i shouldn't have removed sb16 so now i have to put a 510 ohm resistor between BOOT and ground.

1) libusb-compat:
./configure
make
sudo make install

2) libftdi:
./configure
make
sudo make install

3) edit openocd/tcl/target/stm32.cfg
after the line that says:
set _BSTAPID5 0x06418041
add a new line that says:
set _BSTAPID6 0x06420041
change the line that says:
-expected-id $_BSTAPID4 -expected-id $_BSTAPID5
to:
-expected-id $_BSTAPID4 -expected-id $_BSTAPID5 -expected-id $_BSTAPID6

4) OpenOCD:
./bootstrap
./autoreconf -i -f
./configure --enable-maintainer-mode --enable-ft2232_libftdi --enable-usbprog
make
sudo make install

5) create a file called openocd.cfg with these contents:

#daemon configuration
telnet_port 4444
gdb_port 3333

source [find interface/flyswatter.cfg]
set WORKAREASIZE 0x1000
source [find target/stm32.cfg]

#i'm not sure if setting WORKAREASIZE is essential, but the
#default is 16k (0x4000) which is more ram than the stm32
#discovery has so i lowered it

6) to run (in same directory as openocd.cfg):
openocd

7) to telnet in:
telnet localhost 4444

8) to probe flash:
flash probe 0


i haven't changed what's on the flash yet but i'll update once i get gcc compiled and have something to flash it with.

here's a picture of my flyswatter setup/breadboard/power supply


here's a picture of my crazy jtag octopus connection

1 comment: