Bus Pirate - OpenOCD - Raspbery Pi

OpenOCD JTAG debugging with the Bus Pirate.

Bus Pirate - OpenOCD - Raspbery Pi

Postby ehwhatever » Wed May 06, 2015 2:35 pm

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 all
source [find tcl/interface/buspirate.cfg]
source [find tcl/target/raspberry.cfg]


I altered my buspirate.cfg so it contains the following

Code: Select all
#
# Buspirate with OpenOCD support
#
# http://dangerousprototypes.com/bus-pirate-manual/
#

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 all
adapter_khz 1000
adapter_nsrst_delay 400
reset_config none

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

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

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

set _TARGETNAME $_CHIPNAME.arm
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.
ehwhatever
Newbie
Newbie
 
Posts: 3
Joined: Tue May 05, 2015 5:14 pm

Re: Bus Pirate - OpenOCD - Raspbery Pi

Postby ehwhatever » Wed May 06, 2015 2:46 pm

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.
Attachments
OpenOCD_output.txt
(26.64 KiB) Downloaded 225 times
ehwhatever
Newbie
Newbie
 
Posts: 3
Joined: Tue May 05, 2015 5:14 pm

Re: Bus Pirate - OpenOCD - Raspbery Pi

Postby robots » Sun May 10, 2015 2:47 pm

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 ;)
User avatar
robots
Hero Member
Hero Member
 
Posts: 569
Joined: Sat Dec 05, 2009 11:19 am
Location: CZ/Prague

Re: Bus Pirate - OpenOCD - Raspbery Pi

Postby ehwhatever » Fri May 15, 2015 2:53 pm

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.
ehwhatever
Newbie
Newbie
 
Posts: 3
Joined: Tue May 05, 2015 5:14 pm

Re: Bus Pirate - OpenOCD - Raspbery Pi

Postby robots » Wed May 20, 2015 12:26 pm

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.
User avatar
robots
Hero Member
Hero Member
 
Posts: 569
Joined: Sat Dec 05, 2009 11:19 am
Location: CZ/Prague

Re: Bus Pirate - OpenOCD - Raspbery Pi

Postby robots » Wed May 20, 2015 12:31 pm

have you read this for example ?

http://sysprogs.com/VisualKernel/tutori ... jtagsetup/

point 10. how to enable jtag on gpio by setting gpios to alt function 4.
User avatar
robots
Hero Member
Hero Member
 
Posts: 569
Joined: Sat Dec 05, 2009 11:19 am
Location: CZ/Prague

Re: Bus Pirate - OpenOCD - Raspbery Pi

Postby gojimmypi » Sat Oct 10, 2015 9:25 pm

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 all
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: https://github.com/gojimmypi/PiOCD/wiki/Using-a-Raspberry-Pi-with-a-Bus-Pirate-as-a-JTAG-Dongle-to-Linksys-BEFSR41-Router-V2

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.
gojimmypi
Newbie
Newbie
 
Posts: 1
Joined: Sat Oct 10, 2015 9:08 pm


Return to OpenOCD JTAG