JTAG学习笔记 (3)

article/2025/10/25 22:17:04

因为WIGGLER的一些不可避免的缺点,我们现在将精力集中在JLink上。

JLink是大家都能够买的起的仿真器(当然是D版),已经是白菜价了,可以参考淘宝。他真的是仿真器,虽然目前只能支持ARM系列的芯片,和WIGGLER的区别是TCK的频率可以到12MHz,从逻辑分析仪上看到的情况是接近13MHz

 

基于JLink2次开发,

可参考的资料有2个:

1.    官方的协议文档:RM08001_JLinkUSBProtocol.pdf

2.    OpenOCD的代码openocd-0.4.0-rc1/src/jtag/drivers/jlink.c

 

首先在Cygwin的环境下编译最新的openocd的代码,具体的编译过程官方的网站上有详细的描述。

下面是我编译的Image的运行情况:

I:/Study/JTAG/bin>openocd -f jlink.cfg

Open On-Chip Debugger 0.4.0-rc1 (2010-02-05-00:04)

For bug reports, read

        http://openocd.berlios.de/doc/doxygen/bugs.html

Info : J-Link initialization started / target CPU reset initiated

Info : J-Link ARM V7 compiled Apr  1 2009 12:02:10

Info : JLink caps 0x39ff7bbf

Info : JLink hw version 70000

Info : JLink max mem block 9120

Info : Vref = 0.0 TCK = 1 TDI = 0 TDO = 0 TMS = 0 SRST = 1 TRST = 1

 

Error: Vref too low. Check Target Power

 

Info : J-Link JTAG Interface ready

Error: jlink_usb_message failed with result=5)

Error: jlink_tap_execute, wrong result -107 (expected 1)

Info : RCLK (adaptive clock speed)

Warn : There are no enabled taps.  AUTO PROBING MIGHT NOT WORK!!

Error: jlink_usb_message failed with result=5)

Error: jlink_tap_execute, wrong result -107 (expected 1)

Error: jlink_usb_message failed with result=5)

Error: jlink_tap_execute, wrong result -107 (expected 1)

Command handler execution failed

Warn : jtag initialization failed; try 'jtag init' again.

Warn : gdb services need one or more targets defined

 

需要说明的是因为OpenOCD使用的是libusb的库,所以相应的JLink官方提供的驱动也就不能用了,下面这段也来自官方网站。

 

Gene Smith wrote:

> I now get a successful build under cygwin. When I plug the jlink usb to

> windows and run openocd I see the the "Cannot find jlink Interface!"

> error as printed below. Do I need another special windows driver when

> running jlink in cygwin? To build I only copied usb.h and libusb.a as

> directed from libusb-win32 project. There is quite a bit of stuff in the

> libusb-win32-device-bin.tar.gz that I haven't used. Should this be

> installed?

>

Yes.

 

I had the segger jlink commander installed so its driver ran when I

plugged in the jlink and didn't work with openocd. I had to replace it

with the driver from libusb-win32-device-bin on sourceforge. (A "no

driver found dialog" would have popped up if I didn't have segger

installed already, I think.) Uninstalling segger jlink tools did not

remove the segger driver. Had to go into Control Panel/System/Device

Manager and update the jlink driver to point at the new jlink.inf file I

had made with the libusb-win32/bin inf-wizard. Then I browsed to the

actual unsigned driver pointed to by the inf, libusb0.dll from the

libusb-win32-device-bin distribution to complete the installation. I did

not try to use the "filter" driver which I think can coexist with the

segger driver (according to a post by Xiaofan which seems to be the only

mention of whether this 3rd party driver is really needed by openocd).

 

Note: the segger driver appeared under "Universal Serial Bus

Controllers" in Device Manager (winXP) while the libusb-win32 driver

appears as new top level Dev Mgr category "LibUSB-Win32 Devices".

 

-gene

 

这样我们就具备了一个JLink的学习环境了。

 

OpenOCD主要精力在ARMx Technical Reference Manual里描述PRIVATE INSTRUCTION的使用,和调试命令的实现上,所以这里我只是用了openocd-0.4.0-rc1/src/jtag/drivers/jlink.c这个文件。

最需要了解的是2点:

1.      JLink内部有3Buffer,大小都是2048Bytes,用来存放TDI TMSTDO的信号,其中每个信号的状态都是以Bit来存放的,所以最长可以支持到16384TCK

Jlink.c里的void jlink_tap_append_step(int tms, int tdi)函数就描述了如何填充TDI TMS buffer的。

2.         就是USB通信命令里的EMU_CMD_HW_JTAG3,因为的确很重要我把他们从RM08001_JLinkUSBProtocol.pdf里复制出来。

Jlink.c里的int jlink_tap_execute(void)函数就描述了这个命令执行的过程。

 

EMU_CMD_HW_JTAG3

Description

Handles the JTAG connection. It receives data for TDI and TMS and sends TDO data

back.

Command

Direction             Data                                  Name                  Explanation

H->E           1 * U8          Cmd            Command: 0xCF

H->E           1 * U8          DUMMY        Dummy data in order to word align data transfers.

H->E           1 * U16         NumBits       Number of bits to transfer.

H->E           <NumBytes>* U8  TMS            Data for TMS. NumBytes calculates as follows: NumBytes = (NumBits + 7) >> 3

H->E           <NumBytes>* U8  TDI             Data for TDI. NumBytes calculates as follows: NumBytes = (NumBits + 7) >> 3

 

Direction             Data                                  Name                  Explanation

H<-E            <NumBytes>* U8  TDO           TDO data. NumBytes calculates as follows: NumBytes = (NumBits + 7) >> 3

H<-E                1 * U8       Return         Return value:     0: O.K. Everything else: Error occured.

 

Response

Additional information

How the JTAG sequence is generated is beyond the scope of this manual.

This command is available for J-Links with hardware version 5 and above only.

The hardware version can be retrieved using the command

EMU_CMD_GET_HW_VERSION on page 32.

 

Sample communication

Output Command and JTAG TDI, TMS data to halt ARM7 CPU.

H->E: CF 00 48 00 86 E3 71 C0 01 00 00 00 0C 20 00 18 02 00 00 00 00 00

Returns TDO data.

H<-E: 20 00 08 00 48 00 00 00 00

Returns O.K.

H<-E: 00

 

下面做了一些简单的封装,以及在逻辑分析仪上的抓图:

1.      复位JTAG逻辑

CODE:

int testLogicReset(void)

{

       int i = 0;

       jlink_tap_init();

 

       for (i = 0; i < 8; i++) {

              jlink_tap_append_step(1, 0);

       }

       jlink_tap_execute();

       jlink_tap_init();

}

WAVE:

URL:http://hi.csdn.net/attachment/201002/9/3466916_1265731414dFif.jpg

 

 

2.      扫描JTAG链:

CODE:

unsigned int dcScan(void)

{

       unsigned int idcode = 0xffffffff;

       testLogicReset();

       sendData(INT_ID_CODE_LEN, (char *)&idcode, false);

       idcode = buf_get_u32(tdo_buffer,8,32);

       return idcode;

}

WAVE:

注释:testLogicReset()对应的波形在7ms以前,样子和上图一样

 

 

 

URL:

http://hi.csdn.net/attachment/201002/9/3466916_12657353076oWz.jpg

 

 

3.         BYPASS指令测试:

CODE:

unsigned int doBypass(unsigned val)

{

       unsigned int ret = 0;

       testLogicReset();

       sendInstruction(8, STR_PQ27E_INSTRU_BYPASS);

       sendData(INT_ID_CODE_LEN, (char *)&val, false);

       ret = buf_get_u32(tdo_buffer,8,32);

}

WAVE:

sendInstruction(8, STR_PQ27E_INSTRU_BYPASS);

URL:

http://hi.csdn.net/attachment/201002/9/3466916_12657317989YCr.jpg

 

sendData(INT_ID_CODE_LEN, (char *)&val, false);

URL:

http://hi.csdn.net/attachment/201002/9/3466916_1265731915j78v.jpg

 

 

 

 

 


http://chatgpt.dhexx.cn/article/slNiBA8N.shtml

相关文章

嵌入式系统设计笔记

难点&#xff1a;第五章&#xff0c;第十章三级流水线组织&#xff0c;第十一章 第一章 嵌入式系统导论 1、ARM是RISC架构 2、Cortex&#xff0c;ARM11以后的产品使用Cortex命名&#xff0c;并分为A/R/M三类 3、ARM指令分为数据处理、数据传递、控制指令 4、CM 2835 在树莓派上…

JTAG接口无法连接的问题

题目&#xff1a;JTAG接口无法连接问题 本文包含两部分内容&#xff1a;1&#xff09;续写TI DSP连接不上的问题&#xff1b;2&#xff09;顺便提一下Xilinx FPGA的JTAG口连接不上的问题。 一、TI DSP为啥连接不上&#xff1f; 半年前发过一篇博文《DSP为啥连接不上&#xff1…

STM32夺命100问!你知道几个?

点击上方“小麦大叔”&#xff0c;选择“置顶/星标公众号” 福利干货&#xff0c;第一时间送达 1、AHB系统总线分为APB1&#xff08;36MHz&#xff09;和APB2&#xff08;72MHz&#xff09;&#xff0c;其中2>1&#xff0c;意思是APB2接高速设备 2、Stm32f10x.h相当于reg52.…

智能教室控制系统

智能教室控制系统 引言 概述 该系统通过上位机C#控制下位机STM32&#xff0c;实现教室打卡考勤功能&#xff0c;通过打卡对数据库SQLserver进行增删改查&#xff0c;同时能将数据库的数据导出表格&#xff0c;下位机用到RFID的RC522模块&#xff0c;舵机、风扇&#xff0c;w…

基于stm32电梯管理系统设计

基于stm32电梯管理系统设计 这里记录一下以前自己做的嵌入式课程设计&#xff0c;报告中的图片和文字太多了&#xff0c;全部一个一个把搬过来太麻烦了,需要完整文本和代码自行主页私我 摘要关键词一、课题概述1.1市场调研1.2 需求分析 二、课题实施方案2.1 硬件总体方案2.2 性…

基于Xilinx的Kintex-7系列XC7K325T的硬件加速卡

产品型号: B-PCIE-K7F5XILINX的Kintex-7系列FPGA处理器 B-PCIE-K7F5是一款基于PCI Express总线架构的高性能FPGA算法加速卡&#xff0c;该板卡采用Xilinx的高性能28nm 7系列FPGA作为运算节点。Xilinx的28nm 7系列FPGA通过对资源、接口以及时钟的优化&#xff0c;在高性能计算&a…

基于STM32设计的车库监控报警系统

一、前言 随着社会的发展,人们的生活水平不断提高对安防问题的关注度越来越高,因而各类防盗设备也层出不穷,本文采用红外测距传感器、摄像头、STM32单片机以及ESP8266无线通信模块设计一种车库防盗报警器,其可安装在车库的里,通过红外线测距检测是否有人入侵,产生报警信号…

dnw驱动更新,支持全系统(xp,win7,win8/win10)

前言: 本文用于解决win7以上系统使用dnw难装驱动问题&#xff0c;使用新驱动: zadig-2.3.exe&#xff0c;支持xp&#xff0c;win7/win8/win10系统&#xff0c;安装方便、高效&#xff0c;欢迎试用。 对于裸板开发&#xff0c;我们一般使用JTAG工具&#xff0c;比如OpenJTAG、…

jz2440s3c2440 jtag口、串口、usb devices 使用

1.串口&#xff1a; 串口类型&#xff1a; 针串口 、usb串口的使用 1. usb 串口 插入电脑&#xff0c;计算机上设备管理器中其他设备下出现新设备 设备管理器 中查看 2. 安装串口驱动 &#xff0c;安装驱动以后 系统分配com4 串口 3. windows下载串口连接软件 MobaXterm&…

基于STM32设计的城市绿化云端监控系统(华为云IOT)

一、设计需求 1.1 项目背景 随着科技的蓬勃发展改变了很多传统行业的作业方式,当我们用移动支付代替现金交易时,当我们足不出户就能满足饥饿的身体时,我们的生活方式因为科技而发生了改变;同样科技也在改变着我们周围的点点滴滴,城市绿化养护亦是如此。 通过智慧控制系统…

FPGA的调试-虚拟JTAG

对于FPGA调试&#xff0c;主要以Intel FPGA为例&#xff0c;在win10 Quartus ii 17.0环境下进行仿真和调试&#xff0c;开发板类型EP4CE15F17。主要包括一下几个部分&#xff1a; - FPGA的调试-虚拟JTAG&#xff08;Virtual JTAG&#xff09; - FPGA的调试-在线存储器内容编辑…

Win7、Win8、Win10系统USB-Blaster驱动程序无法安装的解决办法

这篇博文是我转载dezhihuang的博文&#xff0c;原文名称和地址如下&#xff0c;并对内容做了适当调整&#xff1a; [原]Win7、Win8系统USB-Blaster驱动程序无法安装的解决办法 第一次用Markdown编辑博客&#xff0c;格式方面真是捉急啊&#xff01; Win7、Win8、Win10操作系…

avr+开发环境+linux,win7下avr单片机开发环境的搭建

操作系统&#xff1a;win7 professional x86 开发软件&#xff1a;avr studio 4.19 首先下载avr studio 4.19&#xff0c;因为貌似这是atmel官方最后支持jtag ice的开发环境。而且也就只有这个4的版本才支持win7&#xff0c;正好本人有个jtag&#xff0c;所以果断选择这个版本…

IBM Spectrum LSF RTM

IBM Spectrum LSF RTM IBM Spectrum LSF RTM是IBM Spectrum LSF环境的操作仪表板&#xff0c;提供全面的工作负载监视、报告和管理。它使集群管理员在日常活动中更加高效&#xff0c;并提供所需的信息和工具&#xff0c;以提高集群效率&#xff0c;实现更好的用户生产力&#…

IBM Spectrum LSF Suites

IBM Spectrum LSF Suites 高性能计算(HPC)不再仅仅适用于大型组织和技术熟练的用户。在当今竞争激烈的商业环境中&#xff0c;几乎每个行业都需要更短的设计周期和更高质量的结果&#xff0c;HPC适用于任何规模的组织。它是为那些需要从大量数据中进行分析和回答的用户而设计的…

LSF_SPAN

span字符串指定并行作业运行的位置。如果省略span, LSF将从可用的处理器中为作业分配所需的处理器。 一、语法 span[host1]&#xff1a;指示分配给作业的处理器必须位于同一个主机上。 span[blockvalue]&#xff1a;对并行作业来说&#xff0c;LSF将根据block size来分配slot…

集群调度LSF-学习笔记

集群-------多台设备 HPC集群----多台用于计算的设备 集群调度-LSF&#xff1a;LSF 是一种强大的工作负载管理平台&#xff0c;提供基于各种策略的智能调度功能&#xff0c;利用分布式的基础架构资源来提高整体的系统性能。用户通过 LSF可以实现集群间的负载均衡&#xff0c;扩…

IBM Platform LSF在IC行业内的使用

LSF在&#xff29;&#xff23;设计中有哪些值得匹配的 1、管理低利用率Job •针对short normal这类队列&#xff0c;查询20分钟以后&#xff0c;Job利用率依然很低的Job信息。 •$bjobs -u all -q short -o ‘id user queue stat ugroup first_host sla idle_factor slots …

IBM Spectrum LSF-手册

在所有规模的企业中&#xff0c;应用程序能力和数据量持续显著增长&#xff0c;推动了对更多计算能力和高性能管理和分析工具的需求。即使在传统的高性能计算(HPC)环境中&#xff0c;多个计算竖井、不均匀处理、设计周期泄漏和延迟结果也是常见的。面对日益严格的经济压力&…

LSF - 提交GUI应用到LSF无法运行,报错Failed to connect to socket /tmp/dbus-xxxxxxxxx: Connection refused

问题描述 提交GUI应用到LSF无法运行&#xff0c;如下所示 问题分析 这种GUI应用&#xff0c;不能以交互式的方式提交。提交命令换成bsub firefox即可。