Please login or register.

Login with username, password and session length
 

News:

Latest updates at DangerousPrototypes.com.


Author Topic: MIPS JTAG support?  (Read 912 times)

kodemunky

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
MIPS JTAG support?
« on: February 02, 2010, 03:34:12 PM »
I'm a JTAG noob, and trying to learn by using the BPv3 with a ubiquiti routerstation pro board that has a JTAG port with helpful silkscreen.  The routerstation has an atheros AR7161 MIPS 24K processor, so I assume it is EJTAG.

So far, I've tried connecting 4 wires according to the table on the hackaday page, but I get lots of 0x00's, and nothing else. The table isn't all that clear to a noob, but I've assumed that I should connect MOSI->TDI, CLK->TCK, MISO->TDO, and CS->TMS.

Diagrams of wiggler cable knock-offs show all pins connected to something (for example, tying together and grounding the 5 gnd pins), whereas I'm obviously not doing that, but since none of the BP posts I've seen mention this, I'm not sure if it's relevant.

Can anyone give me a clue?

ian

  • Crew
  • Hero Member
  • *****
  • Posts: 2898
  • Karma: +61/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #1 on: February 03, 2010, 12:56:53 AM »
Hi kodemunky,

Do you have the ground of the BUs Pirate connected to the ground of the router?

Are you using regular outputs or hiz? Does the router JTAG interface require pull-up resistors?

You might also try swapping the TDI and TDO pins.

kodemunky

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #2 on: February 03, 2010, 11:35:53 AM »
The router has a 2x7 JTAG port. I don't have it in front of me now, but I believe that pins 4,6,8, and 10 are labeled as ground. I've tried connecting the ground pin from the BP to router pin 4, but I haven't tried tying 4,6,8,10 to ground. I'm wondering if I should.

I'm using regular outputs (not hiz). I don't have detailed documentation of the router JTAG interface, so maybe I'll fish around for this.

I tried swapping TDI/TDO, and this changed the output from macro (2). With the original setup, I get a report of 0xFA devices in the chain, with all 0x00's for IDs. When I swap them, I get a report of (0xF5? working from memory here, don't have the system in front of me) and all 0xFF's for IDs.
 

kodemunky

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #3 on: March 21, 2010, 03:43:42 PM »
I finally got my new BP, and am trying again. The JTAG is definitely MIPS32 EJTAG. The device is a Ubiquiti routerstation pro.

Since I somehow fried my last BP, I'm being a bit more cautious. I looked at the wiggler jtag cable contruction here:

http://wiki.openwrt.org/oldwiki/openwrtdocs/customizing/hardware/jtag_cable

That cable uses Vcc and pullup resistors, so I put my BP in HiZ mode and enabled the pullups. I've connected as follows:

BP             Target
-----          ----------
Vpu             pin 14 (3.3v)
GND            pins 2,4,6,8,10
CS               pin 7 (TMS)
MISO           pin 5 (TDO)
MOSI           pin 3 (TDI)
CLK             pin 9 (TCK)

I reset the chain (macro (1)) and then try to probe (macro (2)) and I see the following:
JTAG>(1)
JTAGSM: RESET
JTAGSM: RESET->IDLE
JTAGSM: IDLE->Instruction Register (DELAYED ONE BIT FOR TMS)
JTAGSM: IR->IDLE
JTAGSM: IDLE->Data Register
JTAGSM: DR->IDLE
JTAGSM: RESET
JTAGSM: RESET->IDLE
JTAGSM: IDLE->Data REgister
0x00 DEVICE(S) IN JTAG CHAIN
JTAGSM: DR->IDLE
JTAG>

If I swap MISO/MOSI, I get the same response.

Does anyone see anything obvious here? One thing that is bugging me is that that there are unconnected pins on the JTAG header. In particular, pin 1 (TRST) and pin 11 (RST) are dangling -- should these be connected?

Any help greatly appreciated.



ian

  • Crew
  • Hero Member
  • *****
  • Posts: 2898
  • Karma: +61/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #4 on: March 22, 2010, 12:59:05 AM »
TRST and RST are both JTAG reset signals, though I'm not 100% sure what each resets, what does the datasheet say? It may be necessary to manipulate one or both of these to use your JTAG interface.

Do the pins have internal pull-up resistors? You can check the datasheet, or test them with a multi-meter while it's running (are the pins high even with no connection).

This is all just a guess though. Is a datasheet available for your chip? That would probably be the next place I'd check to see how its JTAG interface works.

robots

  • Full Member
  • ***
  • Posts: 185
  • Karma: +9/-0
    • View Profile
    • My Blog
Re: MIPS JTAG support?
« Reply #5 on: March 22, 2010, 02:54:09 AM »
TRST signal resets the JTAG state machine. You can also reset the JTAG state machine by sending some command.

RST is cpu reset - Active low. I'm not sure about the polarity of TRST.

The JTAG can also be disabled, if this is the case,  you probably need the RST pin to reset the CPU.

I think that OpenOCD supports EJTAG, so you should give it a try :)

kodemunky

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #6 on: March 22, 2010, 07:06:39 AM »
According to this:

http://www.linux-mips.org/wiki/JTAG

"If probe does not control this pin, you need just to feed logical "1" to nTRST pin or pull this to the +VCC via ~300Ohm resistor."

The picture here

http://dangerousprototypes.com/2009/07/27/bus-pirate-practical-guide-to-pull-up-resistors/

shows only 4 pullup resistors, so I'm guessing there are no more available on the BP. I assume that if I pick up a 300 Ohm resistor, I can place it between TRST and a 3.3v source, but is it safe to use Vpu, or should I use the BP 3.3v source instead?

ian

  • Crew
  • Hero Member
  • *****
  • Posts: 2898
  • Karma: +61/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #7 on: March 22, 2010, 07:26:05 AM »
That should work. Connect the pull-up resistor to the same supply as Vpu is connected to (target power supply?).

I'm not sure you need the pullups if the target is 3.3volts also, unless it outputs hi-z and needs external pullups (?)

ian

  • Crew
  • Hero Member
  • *****
  • Posts: 2898
  • Karma: +61/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #8 on: March 22, 2010, 07:26:42 AM »
*need pullups on the other pins, obviously TRST needs the 300ohm pullup.

kodemunky

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #9 on: March 22, 2010, 01:30:40 PM »
I decided to try with pullups for two reasons:

1) somehow I fried my first BP when I didn't use pullups, and the only oddity was that I connected a couple of the target ground pins (8,10, I think) to the GND between PGD and +3.3v; since references to HiZ suggest that it protects the BP circuitry (if I'm not misunderstanding), this seems like a "safer" way to connect

2) the picture of the wiggler-style interface for openwrt uses pullup resistors and Vcc from the target -- but then again, I don't think the host supplies voltage in this case, so maybe this is irrelevant.

Is assumption (1) above flawed, i.e. does HiZ mode actually not protect the BP?

Sorry if these seem like really elementary questions, but I figure it's better to just ask... 

IPenguin

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +16/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #10 on: March 22, 2010, 08:22:56 PM »
Quote
BP             Target
-----          ----------
Vpu            pin 14 (3.3v)
GND           pins 2,4,6,8,10
CS              pin 7 (TMS)
MISO          pin 5 (TDO)
MOSI          pin 3 (TDI)
CLK            pin 9 (TCK)

VIO is the targets reference voltage ... better NOT connect it to the Vpu pin (3.3V) of the Bus Pirate!!!!!
However, you could connect Vpu to the ADC (voltage measurement probe) pin on the Bus Pirate
to check for the voltage level of the target board (D/d command).

The Bus Pirates AUX signal can be used to control the system reset on the target board (nS)RST* or
the TAP controller reset signal (n)TRST but this is optional.
 
MIPS' JTAG implementation EJTAG is specified in "MIPS® EJTAG Specification", document number MD00047,
chapter 10 - "Off-Chip and Probe Interfaces".

The document can be downloaded from MIPS website for free after registering. The Atheros WNPUs (AR5000,
AR7000 and AR9000 families) implement the EJTAG interface as specified by MIPS for the processor (side). It's
an essential document if you want to understand the EJTAG interface and functionality in detail.

Pinout of the EJTAG header as defined by MIPS (top view):

Code: [Select]
1 nTRST   oo GND 2
3 TDI oo GND 4
5 TDO oo GND 6
7 TMS oo GND 8
9 TCK oo GND 10
11 nSRST   oo N.C.  12
13 DINT oo VIO 14

The EJTAG signals of interest on the target/router board:

TCKTest Clock Input is the clock that controls the updates of the TAP
controller and the shifts through the Instruction or selected data register(s).
Both the rising and the falling edges of TCK are used.
InputRequired with probe connection
TMSTest Mode Select Input is the control signal for the TAP controller.
This signal is sampled at the rising edge of TCK.
Input
TDITest Data Input has the data shifted into the Instruction or data register.
This signal is sampled on the rising edge of TCK.
Input
TDOTest Data Output has the data shifted out from the Instruction
or data register. This signal is changed on the falling edge of TCK.
Output
nTRST*Test Reset Input is used for the TAP reset of the TAP controller, Instruction register,
and EJTAGBOOT indication. TAP reset is applied asynchronously when low.
InputOptional with probe connection
nSRST*nSRST* is the system reset of the target board. When the probe asserts RST* low,
the result is either a reset (recommended) or soft reset of the processor. No reset
is applied when the RST* is undriven (3-stated from the probe).
InputRequired with probe connection (why?)
VIOVoltage Sense for I/O indicates if target power is applied, and indicates the voltage
level for the probe signals.
OutputRequired with probe connection

* Input/Output (direction applies) to/from the target board/WNPU. The other signals are not needed
unless you plan to debug/emulate the WNPU. 

In fact you will only need to connect TDI, TDO, TMS, TCK and (one) GND pin to the Bus Pirate as follows
((nS)RST* or (n)TRST* are optional) :

Code: [Select]
Bus Pirate   EJTAG connector
connector on target/router

MOSI   ---> TDI
MISO   <--- TDO
CS ---> TMS
CLK ---> TCK
AUX ---> (nS)RST* or (n)TRST*  <-- optional
GND ---- GND

I am inclined to say that the description of the (n)TRST* signal on the JTAG page of the MIPS Wiki appears
to be rather confusing:

Quote
To conform to MIPS EJTAG specifications this pin should be pulled to the ground via resistor ~1KOhm to keep TAP in reset state w/o probe attached.
If probe does not control this pin, you need just to feed logical "1" to nTRST pin or pull this to the +VCC via ~300Ohm resistor.

The EJTAG (and JTAG) specification requires that the TAP controller is reset at power on! This is usually
accomplished by a 1.0 kΩ pull-down resistor that holds (n)TRST always down (unless a JTAG probe is
connected). However, if (n)TRST* is always "1" (because it's connected to some external power, i.e.
Bus Pirate ) then (n)TRST* will not be driven low during power-up. Therefor (n)TRST* must be connected
to +Vcc on the target board via a 300Ω pull-up resistor (and the fingers crossed that Vcc stays low long
enough during power-up). After power-up (n)TRST* must be "1" for the JTAG interface to work properly
while a probe is attached. 

Regarding the questions about pull-ups/pull-downs for the lines robots already gave a good hint while
I was writing this up and checking the details: Use the Bus Pirate to check the states/levels of (nS)RST*,
(n)TRST*, TDO, TDI, TMS, TCK (and VIO) with the Bus Pirates voltage measurement probe (ADC). This will
tell you which signals have pull-ups/pull-downs on the target board.

I have pulled following general info from Mentor's "JTAG DEBUG – EVERYTHING YOU NEED TO KNOW"
white paper (consider the MAJIC probe to be the Bus Pirate):

Quote
REGARDING LAYOUT OF THE BOARD'S JTAG LINES:
▪▪ The TRST* signal [JTAG TAP Reset] connection to the processor is optional, but it’s recommended that the
connector pin be pulled up regardless of whether it is connected to the processor
. It’s acceptable to pull down
the TRST* pin, providing that you configure the MAJIC probe to enable its TRST* outputdriver (which is
the default). In this case, however, you will not be able to use TRST* for sensing the target voltage level.

▪▪ Some CPU datasheets recommend a pull-down on certain JTAG signals instead of a pull-up. The MAJIC
probe can support that recommendation, but the signals should not be left floating.

Quote
REGARDING RESET MANAGEMENT:
▪▪ The RST* signal should be connected so that the target system (including the CPU) will be reset when it is
asserted (low) by the MAJIC probe, but will not result in TRST* (JTAG reset) being asserted on the target
processor. This allows the MAJIC probe to reset the target system upon your command. When both cold and
warm resets are provided, warm reset is recommended. This is an optional feature, but RST* should be pulled
up to the target’s I/O voltage regardless of whether the reset feature is implemented.


▪▪ The RST* signal is an open-collector signal, so you must provide a pull-up for this signal. It may be tied
directly to the reset switch or power-up reset circuit on your board (unless that results in TRST* being
asserted as well).


Please Note: RST* (Board Reset) and TRST* (Tap Reset) should never be tied together.

If the designers of your router board followed the guidlines given in the MIPS EJTAG specification then
no pull-up/pull-down resistors will be needed (because they should be either in the Atheros WNPU
and/or on the board). However, since every cent counts in SOHO products designers often remove all
components from the production units that are not absolutely needed for the units to function.
Instead they design special test/JTAG adapters for production/testing/service and put those
components inside the adapter.

According to the MIPS (and JTAG) specification (n)TRST* must be pulled low (to GND) via a 1.0 kΩ
resistor to assure that the TAP controller (on/inside the CPU/WNPU) is reset upon power-up.
(nS)RST* must have a pull-up resistor (1.0 kΩ or more). I'd expect those resistors to be installed
on the board so you won't have to do anything if you do not connect/use (n)TRST and (nS)RST.

« Last Edit: March 23, 2010, 04:42:42 AM by IPenguin »

robots

  • Full Member
  • ***
  • Posts: 185
  • Karma: +9/-0
    • View Profile
    • My Blog
Re: MIPS JTAG support?
« Reply #11 on: March 23, 2010, 04:01:24 AM »
The IEEE xxx jtag specification tells that onboard pullups should be present, you should probably test the voltages on the pins, before connecting anything :)

kodemunky

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #12 on: March 23, 2010, 02:40:32 PM »
I connected as suggested by IPenguin:

In fact you will only need to connect TDI, TDO, TMS, TCK and (one) GND pin to the Bus Pirate as follows
((nS)RST* or (n)TRST* are optional) :

Code: [Select]
Bus Pirate   EJTAG connector
connector on target/router

MOSI   ---> TDI
MISO   <--- TDO
CS ---> TMS
CLK ---> TCK
AUX ---> (nS)RST* or (n)TRST*  <-- optional
GND ---- GND

I tried connecting AUX to both rst pins (one at a time, of course), and trying A/a commands before each test. All I get is 0xFA devices in chain, all 0x00's for read commands.

I measured the various target pins with a multimeter (with BP disconnected). TRST is low, RST is high, TDI and CLK are low, TDO seems to be floating (reading varies, typically somewhere between 10 and 200 mV).

Regarding the admonishment to *not* connect target pin 14 to to BP pin Vpu, why is this bad? I thought the purpose of Vpu is to draw the reference voltage from the target. Is this wrong?

Thanks for all the help.
« Last Edit: March 23, 2010, 02:42:35 PM by kodemunky »

robots

  • Full Member
  • ***
  • Posts: 185
  • Karma: +9/-0
    • View Profile
    • My Blog
Re: MIPS JTAG support?
« Reply #13 on: March 24, 2010, 02:27:16 AM »
Vpu is needed if buspirate is in open-drain mode (this is the mode where the output pins either are pulled low, or hiz).

If all the onboard pullups are in place, then the Vpu is not needed.
But as you measured floating TDO, you are not going to get any data out (unless the TDO has push-pull driver, which i doubt)

IPenguin

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +16/-0
    • View Profile
Re: MIPS JTAG support?
« Reply #14 on: March 24, 2010, 03:36:41 AM »
Sorry, my fault - Vpu is an input on the Bus Pirate and should be connected to VIO on the target to drive the pull-up resistors
on the BP when required! (In a state of confusion I must have considered Vpu an output on the BP when I wrote the adonishment) ;)