当前位置:网站首页>[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)));
边栏推荐
- Rviz仿真时遇到机器人瞬间回到世界坐标原点的问题及可能原因
- Delay initialization and sealing classes
- gcc动态库fPIC和fpic编译选项差异介绍
- Deep analysis of C language pointer
- ROS compilation calls the third-party dynamic library (xxx.so)
- FairGuard游戏加固:游戏出海热潮下,游戏安全面临新挑战
- CISP-PTE实操练习讲解
- JS native implementation shuttle box
- 深度剖析C语言数据在内存中的存储
- The network model established by torch is displayed by torch viz
猜你喜欢
JS inheritance method
Indentation of tabs and spaces when writing programs for sublime text
sublime text的编写程序时的Tab和空格缩进问题
Bottom up - physical layer
Screenshot in win10 system, win+prtsc save location
Warning in install. packages : package ‘RGtk2’ is not available for this version of R
What is CSRF (Cross Site Request Forgery)?
Crash problem of Chrome browser
Sort according to a number in a string in a column of CSV file
生成器参数传入参数
随机推荐
JS pure function
Warning in install. packages : package ‘RGtk2’ is not available for this version of R
Colorlog combined with logging to print colored logs
2022.02.13 - NC001. Reverse linked list
2022.02.13 - NC002. sort
Restful API design specification
PLT in Matplotlib tight_ layout()
Report on Market Research and investment prospects of China's silver powder industry (2022 Edition)
Image,cv2读取图片的numpy数组的转换和尺寸resize变化
Modify the video name from the name mapping relationship in the table
Current situation and trend of character animation
2022.02.13 - 238. Maximum number of "balloons"
China high purity silver nitrate Market Research and investment strategy report (2022 Edition)
自动化测试框架有什么作用?上海专业第三方软件测试公司安利
Excellent software testers have these abilities
704 binary search
C语言双指针——经典题型
如何有效地进行自动化测试?
电脑清理,删除的系统文件
Colorlog结合logging打印有颜色的日志