2 Jlink¶
2.1 How to print log information using JLINK RTT??¶
The current default software Hcpu log is output from uart1 PA17/PA19 (SF32LB555), PA49/51 (SF32LB551)
The Lcpu log is output from uart3,
The customer only leads out uart3 PB45/PB46, or Uart1 is occupied
Solution:
考虑到uart3是连接到lcpu,后面lcpu也需要输出log,
可以采用menuconfig改成swd输出log
Modification method for Jlink swd printing hcpu log:
Enter the SDK\example\rt_driver\project\ec-lb555 directory
menuconfig->Third party packages->Select Segger RTT package
menuconfig->RTOS -> RT-Thread Kernel->Kernel Device Object->Change the devices name for console to segger
Connect jlink。 Method1:OpenC:\Program Files (x86)\SEGGER\JLink\jlink.exe -> connect ->? ->s->默认4000khz->连接成功,As shown in the figure below:
Method2:OpenC:\Program Files (x86)\SEGGER\JLink\JLinkRTTViewer.exe配置和菜单File -> Connect, 连接成功能看到如下的 LOG: RTT Viewer connected.提示连接成功。
Run Xshell, secureCRT and other software, connect to jlink RTT viewer via telnet (hostname: 127.0.0.1 port: 19021), view logs support output input,As shown in the figure below:
注意 If Hcpu wakes up from standby or restarts, it is necessary to reconnect jlink RTT viewer.
F,如果按照如上配置,Segger还是没有打印,可以参考#2.2排查
2.2 Hcpu’s log cannot be printed through Jlink segger¶
根本原因:
The new version of sdk optimizes memory, Jlink’s Control block address: _SEGGER_RTT variable is changed from HPSYS SRAM0x20000000 to memory area HPSYS ITCM RAM0x00010000 0x0001FFFF 64*1024
As shown in the figure below:
And Jlink’s default memory search starts from 0x20000000, so it cannot be found and the connection fails,
The address compiled by the old version 0.9.7 is after 0x20000000, and jlink can automatically connect and search。
Solution1:
Specify the address in J-Link RTT Viewer.exe, which can be searched from the map file,As shown in the figure below:
Solution2:
改用Ozone.exe,Ozone.exe能通过axf文件中找到该地址,As shown in the figure below,存在SetRTTAddr地址命令:
Solution3:
Make a JLinkScript command, which will automatically call to set or search the Control block address range when jlink starts,As shown in the figure below命令:
可以自己进行修改选择:
Corresponding: xml file modification:
JLink.exe,J-Link RTT Viewer.exe ,还是像之前一样自动能连接上,方便很多.
It is recommended to use rttview.exe and telnet 127.0.0.1 to view log usage!
文件patch如附件,复制到Jlink对应安装目录:
Program Files (x86).7z
2.3 Reading and writing flash content using J-Link,¶
After jlink is successfully connected, use mem32 to read, w4 to write, and erase to erase
mem32 0x40014000 1 #读1个32bit的寄存器值
mem32 0x64000000 10 #读10个byte从flash2地址0x64000000开始,
w4 0x64000000 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f #写内存或者寄存器值 从flash2地址0x64000000开始, 写入后续的数据
用jflash读写
In the same directory as jlink.exe, there is a jflash tool,As shown in the figure below菜单读取flash内容,Read with savebin command
savebin d:\1.bin 0x101b4000 0x100000
As above, 0x101b4000 is the memory address, 0x100000 is the read-write memory size in bytes d,The method to burn the saved bin back
loadbin d:\1.bin 0x101b4000
2.4 JlinkOther common commands¶
halt, go commands
Enter command h, you can stop the CPU and check the location of the PC pointer
Enter command g, you can let the CPU continue running,设置PC指针
常用于配合 __asm(“B .”); 指令来用,当代码中执行到该指令后,会停住,
如上图,如果此时PC指针在0x10140D28,此时PC指针加2,输入setpc 0x10140D2A, 可以跳过 __asm(“B .”);指令,继续往下运行。其他指令
Erase 0x00000000.0x0000FFFF
loadbin– Download filename file to address
usb——–Connect target board
r———Restart the target board
halt——-Stop the program running on the cpu
loadbin—-Load executable binary file
g——-Jump to the code segment address to execute
s——-Single step execution (for debugging)
setpc
setbp—–设置断点,断点停后可以指令g继续运行
Regs——-读寄存器组织
wreg——-写寄存器
mem——–读内存
w4——–写内存
2.5 没有SWD口用SiFliUsartServer连接JlinkMethod¶
52系列之后MCU没有了SWD接口,如果要用Jlink或者Ozone来debug,可以采用SiFliUsartServer.exe工具,Jlink使用MethodAs shown in the figure below设置: