Training JTAG Interface
For most embedded CPU architecture implementations, the JTAG port is used by the debugger to interface the chip for debugging one or more cores.
The normal user will probably not need to know details of the JTAG implementation unless there is a need
to debug several daisy-chained JTAG TAP controllers or to access special test functions or configurations
via JTAG that are not implemented in the debugger software.
JTAG is the name used for the IEEE 1149.1 standard entitled Standard Test Access Port
and Boundary-Scan Architecture for test access ports (TAP) used for testing printed circuit boards (PCB) using boundary scan.
JTAG is the acronym for Joint Test Action Group, the name of the group of people that developed the IEEE 1149.1 standard.
The functionality usually offered by JTAG is Debug Access and Boundary Scan:
Debug Access is used by debugger tools to access the internals of a chip making its resources and functionality available and modifiable,
e.g. registers, memories and the system state.
Boundary Scan is used by hardware test tools to test the physical connection of a device,
e.g. on a PCB.
Although the TAP (Test Access Port) access itself is generic for all architectures, the functionality implemented behind JTAG is different for each device.
The following chapter explains all necessities for accessing a JTAG TAP. For a complete description of JTAG see the IEEE 1149.1 standard.
JTAG is defined as a serial communication protocol and a state machine accessible via a TAP.
The DTAB (Debug and Test Access Block) is implemented on the target chip as a “passive” device that never sends data without request.
The DTAB mainly consists of the following

The TAP (Test Access Port) with its physical connections (signals) to the external world.
The TAP Controller (a 16-state state machine).
One IR (Instruction Register) and several DRs (Data Registers).
The Debug Bus for communication with the on-chip debug logic.
The TAP defines the interface between the DTAB and the debug tool.
The JTAG Port is the physical connector on the PCB where the debug cable is plugged.
The IEEE standard defines the following TAP signals,
used for the serial communication and driving the TAP controller (JTAG state machine):

The TMS and TDI line are sampled by the DTAP on each rising edge on the TCK line.
The TDO line changes its value after a falling edge on the TCK line.
Instruction and Data Registers
The functionality of the DTAB is accessible via different instructions stuffed into the Instruction Register.
By loading an instruction, the corresponding Data Register is selected for access,
providing and/or accepting data according to the selected instruction.
Only a few instructions are defined by the IEEE standard, and only a few of them are mandatory,
the BYPASS instruction (mandatory) for use in daisy-chained multi-core configurations
IDCODE instruction (not mandatory) for identifying a device
Unused instruction codes can be freely implemented by the device manufacturer.
The width of the IR is not specified by the JTAG standard but needs to be the same for all instructions of a specific device.
Since the DR is selected according to the loaded instruction the DR width is variable.
The following schematic shows the connection of the input signals
with the DTAB and the selection of the Data Register depending on the content of the Instruction Register:

The IEEE standard defines a 16-state state machine called the TAP controller to control several actions:

Each state of the TAP controller can be reached by a sequence of bits transmitted via the TMS line depending on the current state.
Normally a DR or IR shift access starts from the pause parking position,
changes to one of the shift states where data is transmitted and ends up in the pause parking position again.
Pause parking position: state the TAP controller holds while waiting for the next shift operation.
The following states of the TAP controller are of importance:
Test Logic Reset
sets the Instruction Register to its reset value (IDCODE or BYPASS).
This state can be reached from any other state by shifting five times “1” on TMS.
Some CPUs do also reset the DTAB and/or the on-chip debug logic when this state is entered.
As a result an active debug connection might get lost, if this state is driven by a PRACTICE script or a custom application.
Run-Test/ Idle and Select DR-Scan are used by most debuggers as pause parking position.
In the Shift-IR state the debug tool shifts an instruction into the Instruction Register.
The instruction is activated once the TAP controller reaches the Update-IR state.
In the Shift-DR state the debug tool shifts data to/from the Data Register selected by the currently loaded instruction.
The debug tool communicates with the DTAB by reading and/or writing IRs and DRs.
The debug tool first drives the TAP Controller to the Shift-IR state to write the appropriate instruction to IR.
Then it drives to the Shift-DR state where the DR can be read or written.
Once the Update-DR state is reached, the processing of DR is started, e.g. the data contained in DR is forwarded to the on-chip debug system.
The following example shows how the chip ID code is read on a TriCore processor
(IR: 8 bits, IDCODE DR: 32 bits)


Reading or writing the IR or DR is performed bitwise from LSB to MSB. With every bit shifted into the TAP controller via TDI,
the contents of DR is rightshifted one bit, providing the LSB on TDO.

Shifting in a Daisy-chained Multi-TAP Solution
The TAP controllers of all DTABs are synchronized.
So when transmitting data in Shift-IR and Shift-DR states this means that the Instruction- and Data Registers are chained, too.
Communication with all DTABs simultaneously is not possible
since the connected debuggers all have different tasks to do and so have an individual communication with their core.
Instead only one debugger at a time communicates with one single DTAB,
by loading the Instruction Registers of all other DTABs with the BYPASS instruction (“ignore” mode).
Loading the BYPASS instruction into the Instruction Register will switch the Bypass Register into the Data Register path:
• The JTAG standard defines the BYPASS instruction to consist of “1”s only.
In case the width of the Instruction Register (IR-width) is 4 bit, the JTAG instruction is 0xf,
in case IR-width is 7 bit, the BYPASS instruction is 0x7f.
• The Bypass Register must be a 1-bit register and is preloaded with “0” in the Capture-DR state.
So depending on the position of the DTAB to be addressed,
the Instruction-/Data-Registers of the other DTABs have to be filled with BYPASS instructions, respectively “bypass” bits.
On the following pages an example chip is used, which provides a chain of three DTABs (one TAP each):

The picture below shows the Instruction/Data Registers if TAP1 is accessed.

Remember that shifting is performed from LSB to MSB, so in case of an IR shift,
the BYPASS instruction(s) of the TAP(s) after the addressed TAP are shifted in first.
Accordingly these bits are called IR_PRE bits.
The BYPASS instructions of the TAP(s) before are shifted in last so these bits are called IR_POST.
The same applies to the DR path with DR_PRE and DR_POST.
On embedded designs with several TAPs the signals can be chained on board level, so only one common debug connector is required.
This saves space and costs. In case the TAPs are already connected on-chip this also saves pins.
In case a single debugger hardware handles access to all cores under debug,
advanced debug features such as the synchronous multi-core start can be implemented more performant.
The tool must be able to address its core within the TAP chain (multi-TAP capable),
and it must be able to share the JTAG port with other tools.
Because all IRs need to be accessed for shifting instructions,
the complete TAP chain can only be as fast as the slowest TAP thus reducing performance of faster TAPs.
This is especially the case in designs with a return clock (RTCK), e.g. DTABs from ARM.
The connection of the JTAG signals as well as the on-board or on-chip routing must be handled with care to avoid electrical interference,
e.g. by interference of reflections at the end of branch lines.
For handling a multi-TAP system, needs to know only few details about the chain:
• IR_POST is the sum of the IR-width of all TAPs between the TDI pin of the debug connector and the addressed TAP.
• IR_PRE is the sum of the IR-width of all TAPs between the addressed TAP and the TDO pin of the debug connector.
• DR_POST usually is the sum of the bypass registers of all TAPs between the TDI pin of the debug connector and the addressed TAP.
• DR_PRE usually is the sum of the bypass registers of all TAPs between the addressed TAP and the TDO pin of the debug connector.
• TAP State is the neutral parking position where a host instance hands over control of the JTAG chain to another host instance or another debug tool.
The following code are available for the neutral parking position:

Training JTAG Interface的更多相关文章
- HappyJTAG2 - JTAG AND SPI AVR8 interface EMBEDDED JTAG ! EMBEDDED SPI !
New version released ! V2.45 (Check version list for details) This construction is based on HappyJTA ...
- ST40 自制 JTAG 适配器
// 文章首发于 https://zhuanlan.zhihu.com/p/28762429 // 但是不知道为什么搜索引擎还没有收录,便在博客再次发布. 0. 引言 意法半导体生产的 SH4 架构的 ...
- JTAG 引脚自动识别 JTAG Finder, JTAG Pinout Tool, JTAG Pin Finder, JTAG pinout detector, JTAGULATOR, Easy-JTAG, JTAG Enumeration
JTAG Finder Figuring out the JTAG Pinouts on a Device is usually the most time-consuming and frustra ...
- ARM JTAG 信号 RTCK 应该如何处理?
用户在调试内嵌可综合内核的 CPU 如 ARM7TDMI-S 时,需要通过打开仿真器的自适应时钟功能. 此时,ARM仿真器根据 RTCK 时钟信号的频率,产生可用于 CPU 内核当前时钟主频的最快的 ...
- Serial Wire Debug (SWD) Interface -- PSoc5
PSoC 5 supports programming through the serial wire debug (SWD) interface. There are two signals in ...
- JTAG Simplified
JTAG Simplified So the other day, I explored the JTAG bus interface which is frequently found in CPL ...
- JTAG – A technical overview and Timing
This document provides you with interesting background information about the technology that underpi ...
- Implementation of Serial Wire JTAG flash programming in ARM Cortex M3 Processors
Implementation of Serial Wire JTAG flash programming in ARM Cortex M3 Processors The goal of the pro ...
- Turtelizer 2 provide JTAG Flash programming and debugging of ARM based boards via USB
http://www.ethernut.de/en/hardware/turtelizer/ Introducing Turtelizer 2 Overview Turtelizer 2 had be ...
随机推荐
- java学习第05天(数组常见操作、数组中的数组)
(4)数组常见操作 a.遍历取值 class ArrayDemo3 { public static void main(String[] args) { //System.out.println(&q ...
- 第12月第1天 MASConstraintMaker crash
1. crash [valueLabel mas_makeConstraints:^(PAKitMASConstraintMaker *make) { make.left.equalTo(finish ...
- 【干货】使用EnCase来分析windows 7文件系统------认识元数据记录$MFT,数据恢复
来源:Unit 6: Windows File Systems and Registry 6.1 Windows File Systems and Registry Windows NTFS File ...
- js实现避免浏览器拦截弹出新页面的方法
1 问题描述 点击button按钮,提交页面的form表单,后台执行完毕后返回参数,前台页面需要该参数实现跳转,如何实现保留该原来的页面,并在浏览器选项卡新建一个页面,且不被浏览器拦截? 2 方法及问 ...
- if语句引起的bug
最近维护高手留下的api项目,客户端反馈一个bug过来,然后查找到可能出错的代码位置,是一个if语句,乍一看好像没什么问题,代码如下: if (company.UserId != userId || ...
- H2内嵌数据库使用步骤
1.找到h2数据库的jar包 D:\repositories\com\h2database\h2\1.4.187\h2-1.4.187.jar 2.双击jar包,配置连接信息 Driver Class ...
- 阿里云RDS的mysql数据库占用空间超过90%的处理
阿里云RDS数据库最大支持2T,目前已经占用了90%,如果进行分库或者迁移比较麻烦,思路是找出占用空间过大的日志或不重要的文件进行删除操作 查询所有数据库占用磁盘空间大小的SQL语句: show bi ...
- centos7 部署 open-falcon 0.2.0
=============================================== 2019/4/29_第3次修改 ccb_warlock 更新 ...
- KNN算法的感受 1
本来预计的打算是一天一个十大挖掘算法,然而由于同时要兼顾数据结构面试的事情,所以 很难办到,但至少在回家前要把数据挖掘十大算法看完,过个好年,在course上学习老吴的课程还是帮了我很大的忙,虽然浪费 ...
- crontab挂定时任务
Linux shell基本知识 a)">" 与 ">>" 的作用是不一样的,前者使用本次输出内容替换原有文件的内容,后者则是把本次输出追加 ...