JLink和JFlash使用方法笔记
这段时间在用jlink调试freescale的mx51板子,下面将使用jlink的方法在此做一个笔记。
jlink是segger公司的产品,由于正版的工具巨贵,所以现在大部分人都喜欢用山寨版的jlink,幸运的是我的山寨版jlink支持arm cortex a8,所以能调试mx51板子。
jlink的官方提供调试软件和驱动,调试软件有jlink commander(j-tag调试)、j-mem(内存查看)、j-flash(flash烧写)等。我主要用到的是jlink commander,以下是它的命令集:
SEGGER J-Link Commander V4.20h ('?' for help)
Compiled Oct 5 2010 19:11:57
DLL version V4.20h, compiled Oct 5 2010 19:11:41
Firmware: J-Link ARM V8 compiled Oct 5 2010 08:59:59
Hardware: V8.00
S/N: 20100214
Feature(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTarget = 3.280V
Info: TotalIRLen = ?, IRPrint = 0x..FFFFFFFFFFFFFFFFFFFFFFF1
WARNING: CPU core not found.
No devices found on JTAG chain. Trying to find device on SWD.
WARNING: CPU core not found.
****** Error: Parity error (Data = 0xFFFFFFFF, ReceivedParity = 1)
No device found on SWD.
Did not find any core.
Info: TotalIRLen = 9, IRPrint = 0x0011
Found 2 JTAG devices, Total IRLen = 5:
#0 Id: 0x2B900F0F, IRLen: 04, IRPrint: 0x0, ARM ETB
#1 Id: 0x07B76F0F, IRLen: 05, IRPrint: 0x1, ARM1176 Core
ARM11 identified.
J-Link>
Available commands are:
----------------------
f Firmware info
h halt
g go
Sleep Waits the given time (in milliseconds). Syntax: Sleep
s Single step the target chip
st Show hardware status
hwinfo Show hardware info
mem Read memory. Syntax: mem , (hex)
mem8 Read 8-bit items. Syntax: mem8 , (hex)
mem16 Read 16-bit items. Syntax: mem16 , (hex)
mem32 Read 32-bit items. Syntax: mem32 , (hex)
w1 Write 8-bit items. Syntax: w1 , (hex)
w2 Write 16-bit items. Syntax: w2 , (hex)
w4 Write 32-bit items. Syntax: w4 , (hex)
wm Write test words. Syntax: wm
is Identify length of scan chain select register
ms Measure length of scan chain. Syntax: ms
mr Measure RTCK react time. Syntax: mr
q Quit
qc Close JLink connection and quit
r Reset target (RESET)
rx Reset target (RESET). Syntax: rx
RSetType Set the current reset type. Syntax: RSetType
Regs Display contents of registers
wreg Write register. Syntax: wreg ,
SetBP Set breakpoint. Syntax: SetBP [A/T] [S/H]
SetWP Set Watchpoint. Syntax: [R/W] [ [] [A-Mask]]
ClrBP Clear breakpoint. Syntax: ClrBP
ClrWP Clear watchpoint. Syntax: ClrWP
VCatch Write vector catch. Syntax: VCatch
loadbin Load binary file into target memory.
Syntax: loadbin ,
savebin Saves target memory into binary file.
Syntax: savebin , ,
SetPC Set the PC to specified value. Syntax: SetPC
le Change to little endian mode
be Change to big endian mode
log Enables log to file. Syntax: log
unlock Unlocks a device. Syntax: unlock
Type unlock without to get a list
of supported device names.
nRESET has to be connected
---- CP15 ------------
rce Read CP15. Syntax: rce , , ,
wce Write CP15. Syntax: wce , , , ,
---- ICE -------------
Ice Show state of the embedded ice macrocell (ICE breaker)
ri Read Ice reg. Syntax: ri (hex)
wi Write Ice reg. Syntax: wi , (hex)
---- ETM -------------
etm Show ETM status
re Read ETM reg. Syntax: re
we Write ETM reg. Syntax: we , (hex)
es Start trace
---- ETB -------------
etb Show ETB status
rb Read ETB register. Syntax: rb
wb Write ETB register. Syntax: wb , (hex)
---- TRACE -----------
TAddBranch TRACE - Add branch instruction to trace buffer. Paras:,
TAddInst TRACE - Add (non-branch) instruction to trace buffer. Syntax:
TClear TRACE - Clear buffer
TSetSize TRACE - Set Size of trace buffer
TSetFormat TRACE - SetFormat
TSR TRACE - Show Regions (and analyze trace buffer)
TStart TRACE - Start
TStop TRACE - Stop
---- SWO -------------
SWOSpeed SWO - Show supported speeds
SWOStart SWO - Start
SWOStop SWO - Stop
SWOStat SWO - Display SWO status
SWORead SWO - Read and display SWO data
SWOShow SWO - Read and analyze SWO data
SWOFlush SWO - Flush data
---- File I/O --------
fwrite Write file to emulator
fread Read file from emulator
fshow Read and display file from emulator
fdelete Delete file on emulator
fsize Display size of file on emulator
---- Test ------------
thg Run go/halt 1000 times
ts Run step 1000 times
testwspeed Test download speed. Syntax: testwspeed [ []]
testrspeed Test upload speed. Syntax: testrspeed [ [] [<numblock< div="" style="word-wrap: break-word;">
s>]]
testcspeed Test CPU speed. Syntax: testcspeed []
---- JTAG ------------
Config Set number of IR/DR bits before ARM device.
Syntax: Config ,
speed Set JTAG speed. Syntax: speed |auto|adaptive, e.g. speed 2000,
speed a
i Read JTAG Id (Host CPU)
wjc Write JTAG command (IR). Syntax: wjc (hex)
wjd Write JTAG data (DR). Syntax: wjd (hex), (dec)
RTAP Reset TAP Controller using state machine (111110)
wjraw Write Raw JTAG data. Syntax: wjraw , ,
rt Reset TAP Controller (nTRST)
---- JTAG-Hardware ---
c00 Create clock with TDI = TMS = 0
c Clock
0 Clear TDI
1 Set TDI
t0 Clear TMS
t1 Set TMS
trst0 Clear TRST
trst1 Set TRST
r0 Clear RESET
r1 Set RESET
---- Connection ------
usb Connect to J-Link via USB. Syntax: usb , where port is 0..3
ip Connect to J-Link ARM Pro or J-Link TCP/IP Server via TCP/IP.
Syntax: ip
---- Configuration ---
si Select target interface. Syntax: si ,
where 0=JTAG and 1=SWD.
power Switch power supply for target. Syntax: power [perm],
where State is either On or Off. Example: power on perm
wconf Write configuration byte. Syntax: wconf ,
rconf Read configuration bytes. Syntax: rconf
usbaddr Assign usb address to the connected J-Link: Syntax: usbaddr =
ipaddr Show/Assign IP address and subnetmask of/to the connected J-Link.
gwaddr Show/Assign network gateway address of/to the connected J-Link.
dnsaddr Show/Assign network DNS server address of/to the connected J-Link.
conf Show configuration of the connected J-Link.
ecp Enable the J-Link control panel.
calibrate Calibrate the target current measurement.
----------------------
NOTE: Specifying a filename in command line
will start J-Link Commander in script mode.
总结一下我们使用的最多的命令:
usb--------连接目标板
r----------重启目标板
halt-------停止cpu运行的程序
loadbin----加载可执行的二进制文件
g----------跳到代码段地址执行
s----------单步执行(调试用)
setpc-----设置pc寄存器的值(调试用)
setbp-----设置断点
Regs-------读寄存器组织
wreg-------写寄存器
mem--------读内存
w4---------写内存
power off mmu---关闭mmu,这个对于裸板调试很重要
w4 cpsr,0x0000001f------切换到系统模式
speed------设置jtag的传输速率
rce 0,c0,c0,0-----设置cp15寄存器的第1个寄存器为0
完结。
Jlink Commander的使用例子:其中输入的地址和数据大小都是默认十进制来的,
windows 中
下载运行特制的程序
对于S3C2410、S3C2440处理器,它们内部有4K的SRAM,当使用Nor Flash启动时,地址为0x40000000;当使用Nand Flash启动时,地址为0。
对于S3C2410、S3C2440开发板,一般都外接64M的SDRAM。SDRAM能被使用之前,需要经过初始化。
所以,先把一个init.bin下载到内部SRAM去运行,它执行SDRAM的初始化;然后再下载一个比较大的程序,比如u-boot到SDRAM去动行,它将实现对Nor、Nand Flash的操作。
以下是在J-Link commander里的命令,假设init.bin、u-boot.bin在e:盘下。
1. speed 12000 //设置TCK为12M,下载程序时会很快
2. 下载并运行init.bin,这是用来初始化SDRAM的
### 如果是NAND启动:
loadbin e:\init.bin 0
setpc 0
g
### 如果是Nor启动:
loadbin e:\init.bin 0x40000000
setpc 0x40000000
g
### 下载特制的uboot:
h
loadbin e:\u-boot.bin 0x33f80000
setpc 0x33f80000
g
现在,u-boot已经启动了,在串口工具上可以看到如图6所示界面,以后就可以通过网络、串口下载文件,然后使用u-boot里的命令进行烧写。
当然,如果没有网络,也不想忍受串口的速率,也可以通过jlink commander下载,比如:
h
loadbin your_file.bin 0x30000000
g
这时,你的文件已经被下载到SDRAM 0x30000000去了。
后面的操作就是u-boot的命令了。
###使用u-boot烧写Flash
以例子为例,假设需要烧写一个名为leds.bin的程序到Nor、Nand Flash,那么请参考
(1).通过Jlink下载:
在J-Link commander里执行:
h
loadbin e:\leds.bin 0x30000000
g
注意leds.bin的大小
(2).通过u-boot烧写到Nor Flash:
在u-boot里执行:
protect off all // 解锁
erase 0 2ffff // 擦除从0地址开始的大小为0x30000的NOR Flash扇区(大小为可擦除块的整数倍,可以运行flash info命令查看)
cp.b 0x30000000 0 30000 // 把前面下载到0x30000000的程序烧写到NOR去
(3).通过u-boot烧写到Nand Flash:
在u-boot里执行:
nand erase 0 30000 // 擦除从0地址开始的大小为0x30000的Nnad Flash扇区
nand write.jffs2 30000000 0 30000 // 把前面下载到0x30000000的程序烧写到Nand去
注意,上面用的2ffff、30000等数字是192K,如果你的程序比较小,请自行设置
ubuntu中使用JLinkExe
J-Link>device arm9 (arm9是必须要加的,否则J-link会识别不出设备内核会报错)
Disconnecting from J-Link...O.K.
Device "ARM9" selected.
TotalIRLen = 4, IRPrint = 0x01
CP15.0.0: 0x41129200: ARM, Architecure 4T
CP15.0.1: 0x0D172172: ICache: 16kB (64*8*32), DCache: 16kB (64*8*32)
Cache type: Separate, Write-back, Format A
Found 1 JTAG device, Total IRLen = 4:
#0 Id: 0x0032409D, IRLen: 04, IRPrint: 0x1, ARM9 Core
ARM9 identified.
J-Link>loadbin /mnt/hgfs/ShareFolder/leds.bin 40000000
Halting CPU for downloading file.
Downloading file [/mnt/hgfs/ShareFolder/leds.bin]...
O.K.
J-Link>setpc 40000000(等效于0x40000000)
J-Link>g
J-Link>
JFlash的使用
windows中用命令行cmd的方式 使用JFlash来给开发板烧写程序
"D:\Program Files (x86)\SEGGER\JLink_V512f\JFlash.exe" -openprjG:\s3c2440.jflash -openG:\leds.bin,0 -auto -startapp -exit
注意1:cmd中对路径中包含空格的不能识别
D:\>D:\Program/ Files/ /(x86/)\SEGGER\JLink_V512f\JFlash.exe
'D:\Program/' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
解决办法:如上所示,将包含空格路径的用“”包含起来即可。
注意2:JFlash.exe 使用-openprj"*.jflash的工程路径" -open"*.bin的二进制程序路径",0(烧写的起始地址) 选项来指定烧写参数。-openprj与后面的路径不能有空格,-open与后面的路径不能有空格,逗号“,”前后不能有空格,否则烧写不成功。
可以写成一个批处理 内容和上面输入的内容一样
转自:https://blog.csdn.net/hexiechina2010/article/details/51473326
JLink和JFlash使用方法笔记相关推荐
- Windows 2003不同域之间迁移密码方法笔记截图
Windows 2003不同域之间迁移密码方法笔记截图 ([url]http://godoha.blog.51cto.com[/url]_ by Weihu_Yan 2009-1-22) (详见附件) ...
- 计算机网络-自顶向下方法-笔记【第3章-传输层】
计算机网络-自顶向下方法-笔记[第3章-传输层] 学习的课程及图片来源:中科大郑烇.杨坚全套<计算机网络(自顶向下方法 第7版,James F.Kurose,Keith W.Ross)>课 ...
- 计算机网络:自顶向下方法 笔记
计算机网络:自顶向下方法 笔记 综述 因特网部件图例 交换方式 分组交换 电路交换 频分复用 时分复用 对比 五层/七协议 一个传输实例 攻击 DOS攻击 应用层 应用程序结构 客户-服务器结构 P2 ...
- python串口控制8通道继电器方法笔记
python串口控制8通道继电器方法笔记 保存当前文件为RelayControl.py,在其他py文件引用时,使用from RelayControl import relay 格式导入 调用时,使用 ...
- 计算机网络-自顶向下方法-笔记【第2章-应用层】
计算机网络-自顶向下方法-笔记[第2章-应用层] 学习的课程及图片来源:中科大郑烇.杨坚全套<计算机网络(自顶向下方法 第7版,James F.Kurose,Keith W.Ross)>课 ...
- 【Jlink烧录自动化】一台电脑连接 多个Jlink 用 J-flash批处理程序烧写多个单片机(生产批量烧录)
项目描述 最近一些设备需要进行预生产(小批量生产),虽然是小批量但是数量也是很多,单靠人力烧录设备比较耗费时间 因此需要做一个烧录治具批量烧录. 软件与物料准备 软件 由于设备的MCU是arm cor ...
- 转 Applocale:非Unicode程序界面乱码解决方法笔记
转 Applocale:非Unicode程序界面乱码解决方法笔记 2008年11月25日 星期二 下午 1:33 注: 为了不让 pAppLocale 消失 我也做了个下载备份 地址: http:// ...
- 预习计算机组成原理之计算机的运算方法——笔记4
系列文章目录 第六章--计算机的运算方法 文章目录 系列文章目录 前言 一.无符号数和有符号数 1.1 无符号数 1.2 有符号数 1.2.1 机器数与真值 1.2.2 原码表示法 (考试的时候注意写 ...
- 【R - 代码书写习惯、代码注释方法笔记】
前言 本篇笔记将总结R的注释方法.代码书写规范建议.干货满满! 今天突然发现自己写的代码可读性不是那么强,有的地方乱糟糟,有的时候还写一大堆注释,没有清晰的区块和条理.知错能改,善莫大焉,我去上网搜索 ...
- 计算机网络自顶向下方法笔记01
<计算机网络自顶向下方法>学习笔记.之前学习过计算机网络微课,已经对计网中的很多概念都有了印象和一定的了解了,这时候再读自顶向下感觉比较轻松了.这本书没有涉及太多物理层的内容,第一章为概述 ...
最新文章
- Docker将容器制作成镜像并提交到远程仓库
- (二)spring cloud微服务分布式云架构 - 整合企业架构的技术点
- 搭建网站必不可少的知识3
- 嵌入式C语言基础教程一
- 神经网络入门——12梯度下降代码
- 子弹短信新发布,支付宝即将入驻
- 技术动态 | 事理图谱,下一代知识图谱
- easypoi 如何合并相同的列_easy_poi合并行以及样式调整
- python:就喜欢看你看不惯我又干不掉我的样子
- 脑子瓦特?记忆力受损?试试AI调控的闭环电击颞叶疗法
- InfluxDB学习之InfluxDB常用函数(三)变换类函数
- hp服务器开机进系统黑屏,开机黑屏卡住?有办法了!
- 史上最全的程序员常用英语词汇 珍藏版
- 计算机桌面图标如何变小,电脑屏幕图标怎么变小_桌面图标太大怎么调小
- 关于lib文件夹和报java.lang.NoClassDefFoundError解决办法
- 三年老Android经验面经,写给正在求职的安卓开发
- php股票t 0,股票T+0是什么意思?如何看懂股票T+0?
- 伽罗华域(Galois Field)理解、基于伽罗华域的四则运算(附详细python代码)
- OpenX系列标准介绍(2):OpenDRIVE实例分析
- c语言指针数组分配内存,指针数组数组指针的分配内存及函数参数 C语言版
热门文章
- Android 开源项目和文章集合(更新:2022.03.21)
- 使用 Arduino Uno 与MQTT,echarts,java自己手动撸一个IOT平台
- 计算机显卡驱动不匹配,显卡驱动与系统不兼容?尤其是老电脑
- 【SAP-FICO详细教程】
- 【Steam】各种Steam致命错误-Steam需要在线进行更新什么意思。请确保你的网络连接正常,请重试。
- 编辑PDF文档无需购买会员;流失与版式分别是什么,PDF与OFD又有什么区别
- 什么是网络通信协议?(七层功能介绍)
- AR地图与虚拟现实技术
- 前端开发_开发软件Hbuilder简介
- PHP安卓获取gpgga,对于GPS模块数据接收和提取的问题分析