Skip to main content
Topic: Bus Pirate - OpenOCD - Raspbery Pi (Read 5831 times) previous topic - next topic

Bus Pirate - OpenOCD - Raspbery Pi

I bought a Bus Pirate as a cheap way to begin investigating Jtag on a couple chips. I thought the raspberry pi would make for a good test case as it is well documented and has a large support community. I have learned after reading through several sites that this is not a good setup on either end as the bus pirate is very limited in its Jtag capabilities and the Pi does not have Jtag turned on by default. However, this is what I have to work with, so I'd like to see it through if possible.

I have the latest version of OpenOCD installed (0.9.0), I have my bus pirate V3 hardware upgraded to Firmware v6.1 r1676 and Bootloader v4.4. I have my bus pirate on /dev/ttyUSB0 and have confirmed with an echo that it is receiving commands. I have created an openocd.cfg file to select my interface and target. It contains

Code: [Select]
source [find tcl/interface/buspirate.cfg]
source [find tcl/target/raspberry.cfg]

I altered my buspirate.cfg so it contains the following

Code: [Select]
# Buspirate with OpenOCD support

interface buspirate

# you need to specify port on which BP lives (I have a udev rule for this)
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

I created a raspberry.cfg based off of a tutorial I found at  sysprogs<dot>com/VisualKernel/tutorials/raspberry/jtagsetup/. I also used a script from this site to turn the Pi's Jtag pins on.
Code: [Select]
adapter_khz 1000
adapter_nsrst_delay 400
reset_config none

if { [info exists CHIPNAME] } {
} else {
set _CHIPNAME rspi

if { [info exists CPU_TAPID ] } {
} else {
set _CPU_TAPID 0x07b7617F

jtag newtap $_CHIPNAME arm -irlen 5 -expected-id $_CPU_TAPID

target create $_TARGETNAME arm11 -chain-position $_TARGETNAME
rspi.arm configure -event gdb-attach { halt }

When I go to run OpenOCD the output indicates that the files are found and that it is connecting with the bus pirate, however, it is not correctly communicating with the Pi. I ran out of characters, so I'll post the debug in a follow up comment. Please let me know if you have any ideas.

Re: Bus Pirate - OpenOCD - Raspbery Pi

Reply #1
Here is the debug output. Sorry it's in an attachment. The post review kept telling me my debug output looked like a website and that it was too "spamy" to post.

Re: Bus Pirate - OpenOCD - Raspbery Pi

Reply #2
double check your connection, TDI on TDI and TDO on TDO ... its not like uart where you connect rx to tx.

second thing to check is: is jtag enabled on rpi ? Like you said:
..Pi does not have Jtag turned on by default...
This might be the problem ;)

Re: Bus Pirate - OpenOCD - Raspbery Pi

Reply #3
Thank you for the suggestion.

The wiring configuration I have is based on things I've seen on this site and others. BP wire colors in parentheses, RPi pins on the right.

VREF (white) --> pin 1
TRST -- not wired up, not available with BP and said to be optional. (would be pin 15)
TDI (orange) --> pin 7
TMS (red) --> pin 13 (it's a B+ RPi)
TCK (yellow)--> pin 22
TDO (brown) --> pin 18
GND (black) --> pin 25

I am using a script I found on sysprogs<dot>com/VisualKernel/tutorials/raspberry/jtagsetup/ to turn the jtag pins on. It prints out on the terminal that they are on, but I guess I don't have any other way of verifying that they're on. I'll look into whether I can do this another way.

The main thing I'd like to know is whether my _CPU_TAPID value is correct? I feel like this would prevent me from reading anything out.

Re: Bus Pirate - OpenOCD - Raspbery Pi

Reply #4
openocd would tell you that it found different tapid. But i only see in the logs that input is all ones (or zeroes i dont remember) that suggests: wrong connection, disabled jtag.


Re: Bus Pirate - OpenOCD - Raspbery Pi

Reply #6
Although I'm a newbie to the Bus Pirate, I don't think you need the Raspberry Pi config file. It is my understanding that you would only do that if you were using the GPIO pins on the RPi directly as a JTAG dongle.  I instead used the Bus Pirate as an RPi peripheral connected to ttyUSB0 (the way I understood your setup) and this config file:

Code: [Select]
source [find interface/buspirate.cfg]
interface buspirate
buspirate_port /dev/ttyUSB0
buspirate_vreg 0
buspirate_mode open-drain
buspirate_pullup 1
buspirate_speed normal

To see my full first experience with the Bus Pirate hanging off a Raspberry Pi via USB and connecting the Bus Pirate JTAG to a Linksys BEFSR41 router's JTAG interface, see my PiOCD on github here: http://

As JTAG goes, I suppose in theory the reverse might work: GPIO pins on the RPi could instead query the JTAG connector on the Bus Pirate, no? But in this case, I believe the config file would be only for the RPi, and not for the Bus Pirate. (I've never actually used mine this way).  I'd be interested in knowing if this can work in this manner.