当前位置:网站首页>[embedded] print log using JLINK RTT
[embedded] print log using JLINK RTT
2022-07-06 08:42:00 【Curious baby · Quan】
It can be used without serial port JLINK Of RTT namely Real Time Transfer function .RTT The working principle of is to create a in memory RTT Control block RTT Control Block, namely SEGGER_RTT_CB Structure . There are several uplink and downlink channels stored in this structure , Each channel has a data buffer And read and write pointers , Constitute a data queue . towards RTT Write... In the data queue of any uplink channel in the control block log Information , then JLINK Able to read and write RAM Content , Get the data of the queue buffer And write the contents of the pointer , And update the read pointer . If the data written is too fast ,JLINK If the refresh rate of is too late to read the contents of the queue , The queue may be full , Data loss , You can appropriately increase the length of the upload queue :BUFFER_SIZE_UP, In profile SEGGER_RTT_Conf.h in .
stay JLINK In the installation directory of RTT Code for :
You can use it directly SEGGER_RTT_Write Function to write a string :
SEGGER_RTT_Write(0, "0123456789", 10);
Or use SEGGER_RTT_printf Format and print :
SEGGER_RTT_printf(0, "%s\n", "test");
Use RTTViewer Tools can be passed through JLINK Real time reading RAM Get the data content of the upload channel :
Due to the need to obtain chips RAM Data in , Then you have to know what to read RAM Address , That is to say RTT Control Block The address of .RTT Control Block The structure of is defined as :
typedef struct {
char acID[16]; // Initialized to "SEGGER RTT"
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
} SEGGER_RTT_CB;
The program defines a RTT Control Block Variable :_SEGGER_RTT
SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT));
among acID Will be initialized to a fixed string value :“SEGGER RTT”, You can use this string as Magic Number, Throughout RAM Search in the space RTT Control Block The location of , But a little silly . Find the compiled map file , lookup _SEGGER_RTT The location of :
And then in RTT Viewer Inside connect When setting RTT control block The address is _SEGGER_RTT The address of :
Running results :
RTT Viewer The terminal supports the display of different character colors and screen emptying instructions ,SEGGER_RTT.h There are control instruction definitions in , Examples of usage :
SEGGER_RTT_Write(0, RTT_CTRL_BG_BLACK RTT_CTRL_TEXT_RED "0123456789", 20);
SEGGER_RTT_printf(0, RTT_CTRL_BG_GREEN RTT_CTRL_TEXT_YELLOW "%s\n", "test");
Running results :
It's a little inconvenient to be in data When adding variables to the segment , The memory address of the data may change , that _SEGGER_RTT Your address will change , In this way, you should check every time _SEGGER_RTT The address of , More trouble , have access to attribute Keyword assignment _SEGGER_RTT Variables are stored in memory , Be careful to avoid the default allocation in the startup file stack Address area and heap Address area , For example, here I change it to :
//SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT));
SEGGER_RTT_CB _SEGGER_RTT __attribute__ ((at(0x1FFE4000)));
边栏推荐
- Precise query of tree tree
- PC easy to use essential software (used)
- Cisp-pte practice explanation
- Hutool gracefully parses URL links and obtains parameters
- 2022.02.13 - NC004. Print number of loops
- Purpose of computer F1-F12
- R language uses the principal function of psych package to perform principal component analysis on the specified data set. PCA performs data dimensionality reduction (input as correlation matrix), cus
- Charging interface docking tutorial of enterprise and micro service provider platform
- ROS compilation calls the third-party dynamic library (xxx.so)
- 【ROS】usb_cam相机标定
猜你喜欢
Target detection - pytorch uses mobilenet series (V1, V2, V3) to build yolov4 target detection platform
企微服务商平台收费接口对接教程
【ROS】usb_cam相机标定
Detailed explanation of heap sorting
PC easy to use essential software (used)
Process of obtaining the electronic version of academic qualifications of xuexin.com
C language double pointer -- classic question type
Restful API design specification
可变长参数
Roguelike游戏成破解重灾区,如何破局?
随机推荐
【嵌入式】Cortex M4F DSP库
China polyether amine Market Forecast and investment strategy report (2022 Edition)
Marathon envs project environment configuration (strengthen learning and imitate reference actions)
【MySQL】日志
Image, CV2 read the conversion and size resize change of numpy array of pictures
TCP/IP协议
Purpose of computer F1-F12
ROS compilation calls the third-party dynamic library (xxx.so)
China's high purity aluminum target market status and investment forecast report (2022 Edition)
【ROS】usb_ Cam camera calibration
JVM quick start
2022.02.13 - NC003. Design LRU cache structure
Crash problem of Chrome browser
[MySQL] lock
vb.net 随窗口改变,缩放控件大小以及保持相对位置
Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
C語言雙指針——經典題型
同一局域网的手机和电脑相互访问,IIS设置
延迟初始化和密封类
Generator parameters incoming parameters