JTAG (一)杂谈

  • jtag标准
jtag 是一个标准, IEEE1149.1,标准文件可以在 http://standards.ieee.org 获取
JTAG refers to IEEE Std 1149.1-2013. 

It is a standard that defines 
    test logic that can be included in an integrated circuit 
    	to test the interconnections between integrated circuits, test the integrated circuit itself, 
		and observe or modify circuit activity during the components normal operation. 

This specification uses the latter functionality. //  observe ...
The JTAG standard defines a Test Access Port (TAP) that can be used to read and write a few custom registers, 
which can be used to communicate with debug hardware in a component.
jtag 定义了什么
    1. 硬件接口
    标准JTAG采用四线方式,分别是TCK、TMS、TDI和TDO,有一个可选的TRST引脚  // 实测 andes 不支持 TRST
    	tck 是时钟,用来驱动
    	tms 用来状态机切换
    	tdo 用来 芯片 -> 外部 的通信
    	tdi 用于 外部 -> 芯片 的通信
    2.寄存器
        2. 指令寄存器  //用 SHIFT-IR 时序 与 SHIFT-DR 时序 来写
            BSR
            BYPASS
            IDCODES
            EXTEST
            SAMPLE/PRELOAD
            INTEST
        3. 多个数据寄存器 //用 SHIFT-DR 时序 与 SHIFT-DR 时序 来写
    3. 芯片内部的jtag状态机
    4. 一个简单的 TAP(测试访问端口)
		riscv 以该TAP为基础,添加,减少了一些寄存器,改造出来了JTAG-DTM // JTAG-DTM 与 TAP 不完全兼容
		arm   以该TAP为基础,添加,减少了一些寄存器,改造出来了JTAG-DP  // JTAG-DTM 与 TAP 不完全兼容
    
IEEE 1149.1a-1993 - Supplement to Standard Test Access Port and Boundary-Scan Architecture (1149.1)
jtag标准是 jtag组织提出的,arm芯片只是使用了该标准

jtag 定义了jtag 有几个线, 以及 线上的时序
但是没有定义 芯片与调试器的接口为什么,但是如果用了jtag协议,接口中的5个线是少不了的(nrst tck tms tdi tdo)

jtag 定义了 DR 和 IR 和 边界扫描链
	1.边界扫描链用于捕获输入(TDI的输出),并输出(TDO的输出)
	2.IR 和 DR 是 用于 选中debug模块的寄存器, 读写debug模块的寄存器,而 debug 模块就会根据 这些 这些寄存器的读写 做动作
		当 TDI 获取输入的时候, IO 口 会 和外界连接的片外 外设断掉,而只连 TDI
		TDI 获取的输入(例如连续的6个bit) 直接展示在 IO口(例如6个为一个扫描链), 然后 debug模块 会 读取该 6bit
		IR 和 DR  以 边界扫描链 为基础 获取输入


ARM 和 risc-v 和 mips 都会 根据这两点来 往上封装,以 读写 debug模块寄存器为基础封装出来的功能有
	1. halt 住 核心
	2. 读写 cpu 核心 通用寄存器
	3. 读写 内存
现在多数的高级器件都支持JTAG协议,如DSP、FPGA器件等
  • 作用
芯片内部测试/边界扫描

一个含有JTAG Debug接口模块的CPU,只要时钟正常,就可以通过JTAG接口访问
	CPU的内部寄存器
	挂在CPU总线上的设备,如FLASH,RAM,SOC(比如4510B,44Box,AT91M系列)内置模块的寄存器,象UART,Timers,GPIO等等的寄存器。
	查询处理器的生产厂家.处理器类型及版本号.
	
	JTAG接口还常用于实现ISP(In-System Programmable;在线编程),对FLASH等器件进行编程。

如今 JTAG 接口的连接有两种标准,即 14 针接口和 20 针接口
准的JTAG接口是4线:TMS、TCK、TDI、TDO,分别为模式选择、时钟、数据输入和数据输出线。

TMS为测试模式选择,TMS用来设置JTAG接口处于某种特定的测试模式;上升沿锁存
TCK为测试时钟输入;
TDI为测试数据输入,数据通过TDI引脚输入JTAG接口;
TDO为测试数据输出,数据通过TDO引脚从JTAG接口输出;

TRST为测试复位,输入引脚,低电平有效。

MCU的JTAG电路在TCK的上升沿采样TDI的信号,在下降沿在TDO输出数据

时钟TCK的每个上升沿锁存数据,上文所述的TAP控制器有16个不同的状态,TMS的值控制着当前的状态变化。上电伊始,TAP处于TEST_LOGIC/RESET状态,然后每个TCK上升沿锁存到的TMS值相应的决定着TAP控制器的下一个状态。后缀_IR和_DR分别指指令寄存器和数据寄存器。
The Test Access Port

The JTAG Test Access Port (TAP) contains four pins that drive the circuit blocks and control the operations specified. The TAP facilitates the serial loading and unloading of instructions and data. The four pins of the TAP are: TMS, TCK, TDI and TDO. The function of each TAP pin is as follows:

TCK - this pin is the JTAG test clock. It sequences the TAP controller as well as all of the JTAG registers.

TMS - this pin is the mode input signal to the TAP Controller. The TAP controller is a 16-state FSM that provides the control logic for JTAG. The state of TMS at the rising edge of TCK determines the sequence of states for the TAP controller. TMS has an internal pull-up resistor on it to provide a logic 1 to the system if the pin is not driven.

TDI - this pin is the serial data input to all JTAG instruction and data registers. The state of the TAP controller as well as the particular instruction held in the instruction register determines which register is fed by TDI for a specific operation. TDI has an internal pull-up resistor on it to provide a logic 1 to the system if the pin is not driven. TDI is sampled into the JTAG registers on the rising edge of TCK.

TDO - this pin is the serial data output for all JTAG instruction and data registers. The state of the TAP controller as well as the particular instruction held in the instruction register determines which register feeds TDO for a specific operation. Only one register (instruction or data) is allowed to be the active connection between TDI and TDO for any given operation. TDO changes state on the

falling edge of TCK and is only active during the shifting of data through the device. This pin is three-stated at all other times.

JTAG最初是用来对芯片进行测试的,基本原理是在器件内部定义一个TAP(Test Access Port测试访问口)通过专用的JTAG测试工具对进行内部节点进行测试。

IEEE1149.1标准中规定对应于数字集成电路芯片的每个引脚都设有一个移位寄存单元,称为边界扫描单元BSC。它将JTAG电路与内核逻辑电路联系起来,同时隔离内核逻辑电路和芯片引脚。由集成电路的所有边界扫描单元构成边界扫描寄存器BSR。边界扫描寄存器电路仅在进行JTAG测试时有效,在集成电路正常工作时无效,不影响集成电路的功能。
  • 如何使用

一般来说,会将其强制要求的四根线引出到一个插座上去,然后 通过 jlink ulink jlink-ob 等仿真器进行 控制这几个引脚.

这些仿真器的设计原理基本上都是 基于mcu 做的, mcu 控制 四根线序,从而控制被调试的芯片

那如果想用mcu 控制 这四根线,程序怎么写呢?这是下次讨论的内容
可以从 https://github.com/wuxx/nanoDAP.git 这里着手

其他

JTAG测试允许多个器件通过JTAG接口串联在一起,形成一个JTAG链,能实现对各个器件分别测试。现在,
ARM内核原生支持2种业界通用的接口标准,分别是JTAG和SWD。

TI还定义了一种叫SBW-JTAG的接口,用来在引脚较少的芯片上通过最少的利用引脚实现JTAG接口,它只有两条线,SBWTCK,SBWTDIO。实际使用时一般通过四条线连接,VCC,SBWTCK,SBTDIO,GND,这样就可以很方便的实现连接,又不会占用大量引脚。
  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值