Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => OpenOCD JTAG => Topic started by: mashi on November 15, 2011, 05:02:06 pm

Title: Problem using BusPirate and OpenOCD
Post by: mashi on November 15, 2011, 05:02:06 pm
After spending a few hours trying to get OpenOCD 0.5.0 (linux) talk to Bus Pirate I had to resign.  I am out of ideas.

First hurdle was: OpenOCD needs a "configure --enable-buspirate" in order for it to even compile support for Bus pirate.  Took me a while to figure this out.  The error message when running openocd is not very clear.

Second hurdle: There doesn't seem to be any OpenOCD support in latest version 5.10 of the Bus pirate firmware.  I eventually figured that out by reading this forum.  I proceeded to install version 5.8.

Third hurdle which I haven't yet been able to pass is related to communication.  I would like to know if anyone knows whether the log below indicates a problem between Bus pirate and OCD or is it from the Bus pirate to the target device?  Any hints or ideas appreciated. 

Code: [Select]
[b]:~# openocd -d 5[/b]
...
Debug: 88 13 buspirate.c:719 buspirate_jtag_enable(): Entering binary mode
Debug: 89 14 buspirate.c:915 buspirate_serial_write(): size = 20 ret = 20
Debug: 90 14 buspirate.c:977 buspirate_print_buffer(): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Debug: 91 14 buspirate.c:983 buspirate_print_buffer(): 00 00 00 00
Debug: 92 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 93 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 94 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 95 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 96 24 buspirate.c:915 buspirate_serial_write(): size = 1 ret = 1
Debug: 97 24 buspirate.c:983 buspirate_print_buffer(): 06
Debug: 98 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 99 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 100 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 101 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 102 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 103 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 104 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 105 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 106 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 107 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 108 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 109 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 110 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 111 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 112 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 113 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 114 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 115 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 116 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 117 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 118 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 119 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 120 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 121 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 122 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 123 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 124 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 125 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 126 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 127 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 128 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 129 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 130 24 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 131 24 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 132 24 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 133 24 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 134 26 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 135 26 buspirate.c:983 buspirate_print_buffer(): 42 42 49 4f
Debug: 136 27 buspirate.c:947 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 137 27 buspirate.c:983 buspirate_print_buffer(): 31
Debug: 138 10026 buspirate.c:947 buspirate_serial_read(): should have read = 4 actual size = 0
Error: 139 10026 buspirate.c:951 buspirate_serial_read(): Error reading data
Error: 140 10026 buspirate.c:728 buspirate_jtag_enable(): Buspirate error. Is is binary//OpenOCD support enabled?
Title: Re: Problem using BusPirate and OpenOCD
Post by: ian on November 16, 2011, 01:24:40 pm
The first part 00 00 ... 00 enters binary mode ok (BBIO1 reply)

Then it enters JTAG (06), but the reply is still BBIO1, it should be something else.

In your configuration what speed are you running the interface? I think for a while someone speed it up to 900KBPS from the default 115200bps. This may be an option in your OpenOCD compile configuration.
Title: Re: Problem using BusPirate and OpenOCD
Post by: robots on November 16, 2011, 03:21:50 pm
could you please try this firmware ?

viewtopic.php?f=27&t=1702#p17536 (http://dangerousprototypes.com/forum/viewtopic.php?f=27&t=1702#p17536)

For some reason openocd support has been removed in certain versions. This one is specifically compiled to have the support built in.
Title: Re: Problem using BusPirate and OpenOCD
Post by: mashi on November 22, 2011, 09:44:26 pm
ian: I am building the source off SVN.  I tried with both values of 115200 and 1000000.  Neither works.  I then installed openocd 0.3.1 via apt-get, but same result.

I then tried flashing the buspirate with the firmware robots linked to.  The buspirate then identifies itself as:

Code: [Select]
Bus Pirate v3b
Firmware v6.0RC (r572)  Bootloader v4.4
DEVID:0x044F REVID:0x3046 (24FJ64GA002 B8)
http://dangerousprototypes.com

However it seems to behave exactly the same, the 06 is followed by another BBIO:

Code: [Select]
Debug: 172 34 buspirate.c:985 buspirate_print_buffer(): 42 42 49 4f
Debug: 173 34 buspirate.c:949 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 174 34 buspirate.c:985 buspirate_print_buffer(): 31
Debug: 175 34 buspirate.c:917 buspirate_serial_write(): size = 1 ret = 1
Debug: 176 34 buspirate.c:985 buspirate_print_buffer(): 06
Debug: 177 34 buspirate.c:949 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 178 34 buspirate.c:985 buspirate_print_buffer(): 42 42 49 4f
Title: Re: Problem using BusPirate and OpenOCD
Post by: robots on November 22, 2011, 10:13:04 pm
does it still give you the "Buspirate error. Is is binary//OpenOCD support enabled?" error ?
Title: Re: Problem using BusPirate and OpenOCD
Post by: mashi on November 22, 2011, 10:18:39 pm
Yes, it ends like this:

Code: [Select]
Debug: 212 34 buspirate.c:985 buspirate_print_buffer(): 31
Debug: 213 38 buspirate.c:949 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 214 38 buspirate.c:985 buspirate_print_buffer(): 42 42 49 4f
Debug: 215 38 buspirate.c:949 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 216 38 buspirate.c:985 buspirate_print_buffer(): 31
Debug: 217 10038 buspirate.c:949 buspirate_serial_read(): should have read = 4 actual size = 0
Error: 218 10038 buspirate.c:953 buspirate_serial_read(): Error reading data
Error: 219 10038 buspirate.c:729 buspirate_jtag_enable(): Buspirate error. Is is binary//OpenOCD support enabled?
Title: Re: Problem using BusPirate and OpenOCD
Post by: robots on November 23, 2011, 10:13:36 am
Code: [Select]
Debug: 211 6 buspirate.c:723 buspirate_jtag_enable(): Entering binary mode
Debug: 212 6 buspirate.c:923 buspirate_serial_write(): size = 20 ret = 20
Debug: 213 6 buspirate.c:985 buspirate_print_buffer(): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Debug: 214 6 buspirate.c:991 buspirate_print_buffer(): 00 00 00 00
Debug: 215 16 buspirate.c:955 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 216 16 buspirate.c:991 buspirate_print_buffer(): 42 42 49 4f
Debug: 217 16 buspirate.c:955 buspirate_serial_read(): should have read = 1 actual size = 1
Debug: 218 16 buspirate.c:991 buspirate_print_buffer(): 31
Debug: 219 16 buspirate.c:923 buspirate_serial_write(): size = 1 ret = 1
Debug: 220 16 buspirate.c:991 buspirate_print_buffer(): 06
Debug: 221 17 buspirate.c:955 buspirate_serial_read(): should have read = 4 actual size = 4
Debug: 222 17 buspirate.c:991 buspirate_print_buffer(): 4f 43 44 31
Debug: 223 17 buspirate.c:923 buspirate_serial_write(): size = 2 ret = 2
Debug: 224 17 buspirate.c:991 buspirate_print_buffer(): 07 01
Debug: 225 17 buspirate.c:923 buspirate_serial_write(): size = 2 ret = 2
Debug: 226 17 buspirate.c:991 buspirate_print_buffer(): aa 55
Debug: 227 18 buspirate.c:955 buspirate_serial_read(): should have read = 2 actual size = 2
Debug: 228 18 buspirate.c:991 buspirate_print_buffer(): 07 01
Info : 229 18 buspirate.c:809 buspirate_jtag_set_speed(): Buspirate switched to FAST mode
Info : 230 18 buspirate.c:237 buspirate_init(): Buspirate Interface ready!
Debug: 231 18 buspirate.c:923 buspirate_serial_write(): size = 2 ret = 2
Debug: 232 18 buspirate.c:991 buspirate_print_buffer(): 01 02
Debug: 233 18 buspirate.c:923 buspirate_serial_write(): size = 3 ret = 3
Debug: 234 18 buspirate.c:991 buspirate_print_buffer(): 02 02 00
Debug: 235 18 buspirate.c:923 buspirate_serial_write(): size = 3 ret = 3
Debug: 236 18 buspirate.c:991 buspirate_print_buffer(): 02 10 00
Debug: 237 18 buspirate.c:698 buspirate_reset(): trst: 0, srst: 0
Debug: 238 18 buspirate.c:923 buspirate_serial_write(): size = 3 ret = 3
Debug: 239 18 buspirate.c:991 buspirate_print_buffer(): 02 04 01
Debug: 240 18 buspirate.c:923 buspirate_serial_write(): size = 3 ret = 3
Debug: 241 18 buspirate.c:991 buspirate_print_buffer(): 02 08 01

This is output as it should look. I have downloaded the latest openocd version from git. Compiled using
Code: [Select]
./configure --enable-ft2232_libftdi --enable-buspirate --enable-maintainer-mode --prefix=/usr/local/cross-arm
make -j6
sudo make install

My openocd.cfg looks like this:
Code: [Select]
interface buspirate
buspirate_port /dev/ttyUSB1
buspirate_speed fast

reset_config srst_only

set WORKAREASIZE 0x5000

source [find target/stm32.cfg]

and i have plugged BP at this point to the computer (no playing with terminal, no testing of binary mode) (I just hope that your network manager doesn't touch serial ports)

I will try to make the binary entering routine a bit better, but it will take some time :-)

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01032098872session_write_close ( )...(null):0
20.01062230464ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01062231240Database_MySQL->query( ).../DatabaseHandler.php:119
40.05372369976Database_MySQL->error( ).../Db-mysql.class.php:273