Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => OpenOCD JTAG => Topic started by: tnt on June 26, 2010, 04:31:02 pm

Title: [solved: use v5.1] OpenOCD Broken with FW V5.0
Post by: tnt on June 26, 2010, 04:31:02 pm
Hi,

I just tried the OpenOCD with the v5 firmware ( BPv3-Firmware-v5.0.hex ) and it doesn't work (not even the IDCODE)
Looking at it with a logic analyzer shows the the commands sent to the JTAG bus are correct, the TDO signal is correct on the bus but does _not_ match the bits received by openocd.

With the exact same setup and just reflashing to BPv3-Firmware-v4.2.OpenOCD.hex and things work fine.

Cheers,

   Sylvain
Title: Re: OpenOCD Broken with FW V5.0
Post by: ian on June 26, 2010, 04:48:39 pm
Hi tnt - Thanks for the bug report. Is there any debugging info from Open OCD that you can share?

It sounds like the Bus Pirate is getting to OpenOCD mode and responding, but not returning the right values.  I took a quick look at the source from v4.3 and v5.0, but a diff showed that they are the same. It much be something in the larger binary mode, the UART I/O, memory/buffer usage, or maybe interrupts. I'll take a closer look and see if I can make a test release for you with a possible fix.
Title: Re: OpenOCD Broken with FW V5.0
Post by: Sjaak on June 26, 2010, 06:39:00 pm
@tnt: Could you please try the latest version 4? it is here: http://code.google.com/p/the-bus-pirate ... e-v4.5.hex (http://code.google.com/p/the-bus-pirate/source/browse/trunk/firmware/v4-nightly/BPv3%26v2go/BPv3-Firmware-v4.5.hex) ?

I also looked a bit in the source, but I don't have a clue where it goed wrong.. Can you give an example what you see on the logic analyzer and what is 'printed' in OpenOCD?
Title: Re: OpenOCD Broken with FW V5.0
Post by: tnt on June 26, 2010, 07:59:38 pm
I tested V4.5 and it works fine too.

In attachement, there is the full 'debug_level 3' output of OpenOCD as well as logic analyzer logs in VCD format (GtkWave) for the three firmware versions.

Here's an extract where you see the DR scan for IDCODE and you clearly see the problem :

V4.5
[tt:]Debug: 92 489 core.c:1028 jtag_examine_chain(): DR scan interrogation for IDCODE/BYPASS
Debug: 93 489 core.c:318 jtag_call_event_callbacks(): jtag event: TAP reset
Debug: 94 489 buspirate.c:585 buspirate_tap_execute(): executing tap num bits = 655 scans = 1
Debug: 95 489 buspirate.c:911 buspirate_serial_write(): size = 167 ret = 167
Debug: 96 489 buspirate.c:968 buspirate_print_buffer(): 05 02 8f 80 17 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 97 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 98 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 99 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 100 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 101 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 102 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 103 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 104 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 105 489 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 106 489 buspirate.c:974 buspirate_print_buffer(): 00 00 00 00 40 00 7f
Debug: 107 495 buspirate.c:943 buspirate_serial_read(): should have read = 85 actual size = 85
Debug: 108 495 buspirate.c:968 buspirate_print_buffer(): 05 02 8f ff d4 31 c9 83 7f 00 00 80 7f 00 00 80
Debug: 109 495 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80
Debug: 110 495 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80
Debug: 111 495 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80
Debug: 112 495 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80
Debug: 113 495 buspirate.c:974 buspirate_print_buffer(): 7f 00 00 80 7f
Warn : 114 495 core.c:1129 jtag_examine_chain(): AUTO auto0.tap - use "jtag newtap auto0 tap -expected-id 0x079263a9 ..."[/tt:]

v5.0
[tt:]Debug: 150 684 core.c:1028 jtag_examine_chain(): DR scan interrogation for IDCODE/BYPASS
Debug: 151 684 core.c:318 jtag_call_event_callbacks(): jtag event: TAP reset
Debug: 152 684 buspirate.c:585 buspirate_tap_execute(): executing tap num bits = 655 scans = 1
Debug: 153 684 buspirate.c:911 buspirate_serial_write(): size = 167 ret = 167
Debug: 154 684 buspirate.c:968 buspirate_print_buffer(): 05 02 8f 80 17 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 155 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 156 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 157 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 158 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 159 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 160 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 161 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 162 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 163 684 buspirate.c:968 buspirate_print_buffer(): 00 00 00 80 00 7f 00 00 00 00 00 80 00 7f 00 00
Debug: 164 684 buspirate.c:974 buspirate_print_buffer(): 00 00 00 00 40 00 7f
Debug: 165 690 buspirate.c:943 buspirate_serial_read(): should have read = 85 actual size = 85
Debug: 166 690 buspirate.c:968 buspirate_print_buffer(): 05 02 8f d4 31 ff c9 83 7f 00 00 80 7f 00 00 80
Debug: 167 690 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80
Debug: 168 690 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80 
Debug: 169 690 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 80
Debug: 170 690 buspirate.c:968 buspirate_print_buffer(): 7f 00 00 80 7f 00 00 80 7f 00 00 80 7f 00 00 7f
Debug: 171 690 buspirate.c:974 buspirate_print_buffer(): 00 80 00 80 7f
Info : 172 690 core.c:928 jtag_examine_chain_display(): JTAG tap: auto0.tap tap/device found: 0x0793fe63 (mfg: 0x731, part: 0x793f, ver: 0x0)
Warn : 173 690 core.c:966 jtag_examine_chain_end(): Unexpected idcode after end of chain: 576 0xfe0000ff
Warn : 174 690 core.c:966 jtag_examine_chain_end(): Unexpected idcode after end of chain: 608 0x00010000[/tt:]

If you look at the returned buffer, you can see some bytes have been weirdly swapped :

V4.5[font=courier:]Debug: 108 495 buspirate.c:968 buspirate_print_buffer(): 05 02 8f ff d4 31 c9 83 7f 00 00 80 7f 00 00 80[/font:]
V5.0[font=courier:]Debug: 166 690 buspirate.c:968 buspirate_print_buffer(): 05 02 8f d4 31 ff c9 83 7f 00 00 80 7f 00 00 80[/font:]
Title: Re: OpenOCD Broken with FW V5.0
Post by: ian on June 27, 2010, 08:17:53 am
Thanks, that's really helpful. I think maybe robots used the 4096byte buffer in the v4 firmware and I believe it's been reduced in v5. I've added it to my list, I'll debug it Monday.
Title: Re: OpenOCD Broken with FW V5.0
Post by: ian on June 27, 2010, 09:40:53 am
I checked the buffer, but it is unchanged. I'll take a closer look tomorrow.
Title: Re: OpenOCD Broken with FW V5.0
Post by: Sjaak on June 27, 2010, 11:46:00 am
I just had a brainwave. One thing I altered in the UART1TX is to check whether it is suppose to echo or not. This was necessary for the scripting engine to suppress the normal messages.

I made a testbuilt without this check. Could you please test it?

It is only for testing if the error is caused by this change and by no means useable for anything else !
Title: Re: OpenOCD Broken with FW V5.0
Post by: tnt on June 27, 2010, 12:59:25 pm
I tested it but it doesn't work. Same problem as a standard v5.0

Another piece of information: depending if I put the bus pirate in 'normal' or 'fast' speed, the error changes slightly. The weird swap at the beginning is exactly the same, but there is no swap at the end.

Am I the only one with this problem ? Do some people use v5 successfully with openocd ? Because here, the problem is not random, it happens each time and exactly the same way.
Title: Re: OpenOCD Broken with FW V5.0
Post by: robots on June 27, 2010, 02:18:09 pm
[quote author="Sjaak"]
I just had a brainwave. One thing I altered in the UART1TX is to check whether it is suppose to echo or not. This was necessary for the scripting engine to suppress the normal messages.
[/quote]

Those data is sent though ISR not the Uart1tx. I don't see any reason why would first 3 bytes be rotated in my code :). I have to check v5 sources.
Title: Re: OpenOCD Broken with FW V5.0
Post by: robots on June 27, 2010, 03:53:39 pm
I have found the bug. Someone messed up formating in the baseIO.c (svn blame tells it was ian ;) ). It should be fixed!

Sjaak: Could you please compile new hex ?  I do not have MPlab available right now.
Title: Re: OpenOCD Broken with FW V5.0
Post by: ian on June 27, 2010, 05:50:35 pm
Thanks robots. I'm sorry, I must have removed some stuff I shouldn't have when I cleaned old code from the newterm version and merged it into the trunk.

I compiled and updated the nightly:
http://the-bus-pirate.googlecode.com/sv ... e-v5.1.hex (http://the-bus-pirate.googlecode.com/svn/trunk/firmware/v5-nightly/BPv3&v2go/BPv3-Firmware-v5.1.hex)
Title: Re: OpenOCD Broken with FW V5.0
Post by: tnt on June 27, 2010, 05:56:10 pm
I can confirm that the latest nighly works fine now !

Thanks a lot robots / ian / Sjaak :)
Title: Re: OpenOCD Broken with FW V5.0
Post by: ian on June 27, 2010, 06:02:37 pm
Thanks for the update, I'm glad it's working. Sorry I messed up the code :)
Title: Re: OpenOCD Broken with FW V5.0
Post by: robots on June 27, 2010, 06:36:11 pm
it looked like you did some copy/paste, and did not correct the formating. One line was commented by accident. I'm happy it is working :)
Title: Re: OpenOCD Broken with FW V5.0
Post by: Sjaak on June 27, 2010, 09:33:58 pm
I think I'm the one to blame. I tried to copy and paste the openOCD subs and UART ISR into the v5 build, but haven't got a jtag target to test it, so I didn't notice it. It compiled fine back then.. Ian only did the moving of the /trunk/source/newterm into the /trunk/source.

I'm glad it is working now, but still I'm sorry..

( ! ) 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.01112123336session_write_close ( )...(null):0
20.01142254928ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01142255704Database_MySQL->query( ).../DatabaseHandler.php:119
40.05472394432Database_MySQL->error( ).../Db-mysql.class.php:273