PEmicro Blog

JTAG Daisy Chaining MCUs With PEmicro Multilink & Cyclone

Dec 14, 2018

Dec. 2018 - We've updated this blog post with more info about Multilink and Cyclone implementation...

The JTAG specification introduced daisy chaining of MCUs in order to reduce the number of headers required to debug and program multiple MCUs. JTAG daisy chaining allows multiple MCU’s (and other JTAG compatible hardware, such as FPGAs) to share a single debug header. PEmicro currently supports daisy chaining of ARM-Cortex MCUs via our Cyclone programmers and Multilink debug probes. The same is true for most PEmicro software, including our Eclipse plugin GDB Server, and our Cyclone automation and control packages.

Connection: There are four pins necessary for JTAG: TDI, TMS, TCK, and TDO.

  • TDI is the input pin for JTAG data.
  • TMS is a control signal.
  • TCK is the clock signal.
  • TDO is the data output.

In a daisy chain setup, TMS and TCK are common to every device in the chain. This means that when routing your board, these signals should be routed to every device in the chain. TDO and TDI are a little more interesting. The debugger should attach its TDI pin to the TDI pin of the first device in the chain. That first device should then pass its TDO to the TDI pin of the next device, and so on. There is no practical limit to this chaining. Finally the last device in the chain should attach its TDO pin to the TDO pin of the debugger.

Debugging: JTAG relies on the JTAG state machine to shift data into the IR (instruction register) and DR (data register) that are present on every device. The current state and value of TMS determines the next state. Using the state machine, the debugger shifts in instructions and data. The key instruction for daisy chaining is the BYPASS instruction. By shifting all "1"s into a certain device’s IR register, that device can be bypassed. In daisy chaining, all devices are bypassed except for the target device. That means that the debugger is effectively talking to one device in the chain at a time.

PEMicro Multilink Implementation: In order to be able to implement a JTAG daisy chain configuration in our PROG software, first make sure that the “Use SWD reduced pin protocol for communications” is unchecked in the Connection Assistant Window (Figure 1).

Figure 1: Connection Assistant Window

Next, at the right side of the "Device Selection" area,  select the “Advanced” tab which will bring up the window shown in Figure 2

Figure 2: Advanced: JTAG Daisy Chain

Two parameters are necessary for PEmicro hardware to debug or program a certain device in a chain: Tap number, and Pre IR bits.The Tap number is the index of the device in the chain. As you can see, the first device connected to TDI is index 0, then index 1 and so on. The last device connected to the TDO of the debugger is the index number of devices minus 1. The Pre IR bits parameter is the sum of the length of the IR registers of the devices between the target device and TDO pin of the debugger. One might think that this parameter should be called "Post" IR bits, but "Pre" makes sense because these bits must be shifted in first. Once the user has specified these two parameters, PEmicro can infer the rest and connect to the target. 

Once connected to the target with the corresponding flash programming algorithm to the device that is to be programmed, the PROG software works as usual. Selecting commands will have an affect on the MCU that is currently connected to the Multilink in the daisy chain. NOTE: JTAG daisy chaining is NOT a gang programming interface. A debugger/programmer can only communicate with one device at a time in the chain. When all necessary commands are executed, the PROG software will have to be reloaded and changes within the “Advanced” tab that displays the JTAG daisy chain configurations (Figure 2) are needed to reflect the new MCU that wishes to be programmed. Once the new MCU is configured with the correct Tap number and Pre IR bits, connection can once again be made and the same process will be followed to program the next MCU.

PEMicro Cyclone Implementation: Similar to the implementation of the Multilink, the Cyclone can also utilize the JTAG daisy chain configuration through our PROG software. The same process as stated above is used to program the MCU using prob via the Cyclone. 

The Cyclone product allows the user to create a Stand-Alone image to program the MCU and also support the JTAG daisy chain configuration. The Cyclone Image Creation Utility (Figure 3) is used to create this Stand-Alone image (SAP).

Figure 3: Cyclone Image Creation Utility

After you have selected the correct device, architecture and standard desired settings for the SAP image, make sure that the “Mode” in the “Communication Settings” title is set to “JTAG”. Next select the “Advanced” tab and once again the window in Figure 3 will pop up. The same setup for selecting Tap Number and Pre IR bits should be done in order to have the correct configuration for the JTAG daisy chain. After these have been selected the SAP image may be created and executed as desired.

Troubleshooting: The most common mistake in specifying parameters occurs when setting Pre IR bits. Make sure that you are counting the number of bits after the device up to the TDO pin of the debugger. Also, it is not always a straightforward task determining the width of the IR register of a particular device. Usually this number is 4 for ARM, but some devices actually contain more than one JTAG device internally and are therefore larger. Consulting the device data sheet is usually a great place to start.

Quick Note: One important distinction to grasp is that JTAG daisy chaining is NOT a gang programming interface. A debugger/programmer can only communicate with one device at a time in the chain.

Conclusion: JTAG Daisy Chaining is an important feature that can simplify hardware layouts and increase productivity. The most difficult part of debugging in a daisy chain setup is selecting the correct initial parameters. PEmicro technical support is more than happy to assist in selecting these parameters. Once that is done, things should work properly without any further user intervention.

Tags related to this Blog Post

Cyclone     Cyclone FX     Multilink     Multilink FX     GDB Server     ARM     Debug     Automated Control