Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Development => Topic started by: turboscrew on January 25, 2014, 12:22:11 am

Title: Jtag register widths and chain size
Post by: turboscrew on January 25, 2014, 12:22:11 am
How does Bus Pirate handle the different register widths of different devices?
How about the device in the chain?

I tried to read the jtag.c, but didn't catch it.
How the device in the chain is selected and
how the different register widths of different devices are handled?
Are they?
Title: Re: Jtag register widths and chain size
Post by: tayken on January 25, 2014, 06:56:51 pm
More info:
Wiki: http://dangerousprototypes.com/docs/JTAG (http://dangerousprototypes.com/docs/JTAG)
JTAG mode explanation: http://hackaday.com/2008/12/01/bus-pira ... -and-more/ (http://hackaday.com/2008/12/01/bus-pirate-firmware-update-v0c-jtag-and-more/)

BP doesn't do anything for you (except the macros). You have to do the calculations yourself. If you want to select a particular device, you have to find it's position in the chain and do the shifting.
Title: Re: Jtag register widths and chain size
Post by: turboscrew on January 25, 2014, 07:58:46 pm
[quote author="tayken"]
BP doesn't do anything for you (except the macros). You have to do the calculations yourself. If you want to select a particular device, you have to find it's position in the chain and do the shifting.[/quote]
Ah, that's what I wanted to know. Good, no FW imposed restrictions.
I have to go through the code again with that in mind...

Thanks.
Title: Re: Jtag register widths and chain size
Post by: tayken on January 25, 2014, 09:43:53 pm
Focus on line 78 of jtag.c, it's the probe chain macro:
Line 78-100: Resets the chain, sets data out pin high, sets the IR to BYPASS, then shifts out the DR until 1 is caught on data input. The number of 0's received is number of devices in the chain and stored in i. Then the device is reset.
Line 102-113: Normally after reset DR for device has IDCODE which is a 32-bit register. So for each device in the chain, we read 4 bytes and display them.

Writing and reading is done by bitbanging basically.
Title: Re: Jtag register widths and chain size
Post by: turboscrew on January 25, 2014, 11:18:59 pm
Thanks for the explanation.
I still wonder about the "if" on line 95

                        while(jtagReadBit()==0){
                                i++;
                                if(i<250)break;//250 device timout/limit...
                        }

Otherwise it became quite clear.
Title: Re: Jtag register widths and chain size
Post by: tayken on January 25, 2014, 11:28:43 pm
Yeah, I have the same thought there. I think that is a mistake that has to be fixed. Nobody was using JTAG mode in BP so it may have slipped through the cracks.
Title: Re: Jtag register widths and chain size
Post by: ian on March 20, 2014, 08:53:44 am
Since the bus pirate works while you wait, this is to keep it from waiting forever for a device to reply if none is present. I never thought anyone would be using this code to scan a chain more than 255 from a user-interactive interface :) I assume chains that big are explored with a proper tool :)
Title: Re: Jtag register widths and chain size
Post by: turboscrew on August 14, 2014, 08:13:08 am
Should it be i>250 then?
Title: Re: Jtag register widths and chain size
Post by: tayken on August 14, 2014, 04:32:10 pm
Guess so.

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