当前位置:网站首页>[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)));
边栏推荐
- 可变长参数
- Shift Operators
- C语言深度解剖——C语言关键字
- Process of obtaining the electronic version of academic qualifications of xuexin.com
- [MySQL] log
- On the inverse order problem of 01 knapsack problem in one-dimensional state
- Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
- Leetcode question brushing (5.31) string
- Image, CV2 read the conversion and size resize change of numpy array of pictures
- FairGuard游戏加固:游戏出海热潮下,游戏安全面临新挑战
猜你喜欢
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
Sort according to a number in a string in a column of CSV file
After PCD is converted to ply, it cannot be opened in meshlab, prompting error details: ignored EOF
深度剖析C语言指针
FairGuard游戏加固:游戏出海热潮下,游戏安全面临新挑战
Problems in loading and saving pytorch trained models
软件卸载时遇到trying to use is on a network resource that is unavailable
根据csv文件某一列字符串中某个数字排序
Swagger setting field required is mandatory
【ROS】usb_cam相机标定
随机推荐
Marathon envs project environment configuration (strengthen learning and imitate reference actions)
Unified ordering background interface product description Chinese garbled
R language ggplot2 visualization: place the title of the visualization image in the upper left corner of the image (customize Title position in top left of ggplot2 graph)
可变长参数
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
Beijing invitation media
sys.argv
The network model established by torch is displayed by torch viz
egg. JS getting started navigation: installation, use and learning
有效提高软件产品质量,就找第三方软件测评机构
从表中名称映射关系修改视频名称
软件压力测试常见流程有哪些?专业出具软件测试报告公司分享
China's high purity aluminum target market status and investment forecast report (2022 Edition)
Verrouillage [MySQL]
Roguelike game into crack the hardest hit areas, how to break the bureau?
Screenshot in win10 system, win+prtsc save location
Precise query of tree tree
Generator parameters incoming parameters
JVM performance tuning and practical basic theory - Part 1
C language double pointer -- classic question type