OpenOCD

September 20, 2016

Amazingly, this is available as a fedora package, so I just do:

dnf install openocd
Installing:
 hidapi                                     x86_64                     0.8.0-0.2.d17db57.fc24
 libftdi                                    x86_64                     1.2-8.fc24
 openocd                                    x86_64                     0.9.0-4.fc24
Then typing "openocd" on the command line, I get:
openocd
Open On-Chip Debugger 0.9.0 (2016-05-13-19:37)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:60: Error: Can't find openocd.cfg
So, it is version 0.9.0 and wants a config file. Seeing "tcl" sets my stomach churning, but as long as it stays out of my way and doesn't cause problems, I am OK with it.

A little poking around, and I discover that a bunch of config files have been installed at /usr/share/openocd/scripts/interface, including:

/usr/share/openocd/scripts/interface/buspirate.cfg
/usr/share/openocd/scripts/interface/stlink-v1.cfg
/usr/share/openocd/scripts/interface/stlink-v2-1.cfg
/usr/share/openocd/scripts/interface/stlink-v2.cfg
/usr/share/openocd/scripts/interface/ftdi/flyswatter.cfg
I am gratified to see files for the buspirate and stlink-v2. All of these are short ascii files. Here is the buspirate config file:
interface buspirate

# you need to specify port on which BP lives
#buspirate_port /dev/ttyUSB0

# communication speed setting
buspirate_speed normal ;# or fast

# voltage regulator Enabled = 1 Disabled = 0
#buspirate_vreg 0

# pin mode normal or open-drain
#buspirate_mode normal

# pullup state Enabled = 1 Disabled = 0
#buspirate_pullup 0

# this depends on the cable, you are safe with this option
reset_config srst_only
This answers (I think) my most pressing question, namely whether I can use the openocd packaged by Fedora or if I need to compile from source.

I need to at least set the serial port name (and it tends to jump around a lot on my system) so I copy this file to "mypirate.cfg", plug in my pirate, and do:

openocd -f mypirate.cfg
Open On-Chip Debugger 0.9.0 (2016-05-13-19:37)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Warn : Adapter driver 'buspirate' did not declare which transports it allows; assuming legacy JTAG-only
Info : only one transport option; autoselect 'jtag'
srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst
Error: Error reading data
Error: Buspirate error. Is binary/OpenOCD support enabled?
It turns out that the suggestion is right, my Bus Pirate does not support OpenOCD. I need to upgrade from the 5.10 firmware to the 6.1 firmware, so I do that and try again. Now I get:
openocd -f mypirate.cfg
Open On-Chip Debugger 0.9.0 (2016-05-13-19:37)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Warn : Adapter driver 'buspirate' did not declare which transports it allows; assuming legacy JTAG-only
Info : only one transport option; autoselect 'jtag'
srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst
Info : Buspirate Interface ready!
Info : This adapter doesn't support configurable speed
Warn : There are no enabled taps.  AUTO PROBING MIGHT NOT WORK!!
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
This is progress! I don't have an STM32 hooked up yet, so these errors make sense. For the record, I will note that when I do this, the "mode" light on the pirate comes on.

Random stuff and possibly useful links


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org