当前位置:网站首页>[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)));
边栏推荐
- win10系统中的截图,win+prtSc保存位置
- Warning in install. packages : package ‘RGtk2’ is not available for this version of R
- 2022.02.13 - NC003. Design LRU cache structure
- On the inverse order problem of 01 knapsack problem in one-dimensional state
- Crash problem of Chrome browser
- Trying to use is on a network resource that is unavailable
- Restful API design specification
- 移位运算符
- Synchronized solves problems caused by sharing
- China vanadium battery Market Research and future prospects report (2022 Edition)
猜你喜欢

CISP-PTE实操练习讲解

Light of domestic games destroyed by cracking

egg. JS project deployment online server

2022.02.13 - NC002. sort

深度剖析C语言指针

C语言双指针——经典题型

Excellent software testers have these abilities

被破解毁掉的国产游戏之光

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Fairguard game reinforcement: under the upsurge of game going to sea, game security is facing new challenges
随机推荐
JS pure function
China high purity silver nitrate Market Research and investment strategy report (2022 Edition)
[NVIDIA development board] FAQ (updated from time to time)
软件卸载时遇到trying to use is on a network resource that is unavailable
按位逻辑运算符
MySQL learning record 07 index (simple understanding)
被破解毁掉的国产游戏之光
根据csv文件某一列字符串中某个数字排序
Research Report on supply and demand and development prospects of China's high purity aluminum market (2022 Edition)
优秀的软件测试人员,都具备这些能力
Bottom up - physical layer
【刷题】牛客网面试必刷TOP101
C language double pointer -- classic question type
tree树的精准查询
同一局域网的手机和电脑相互访问,IIS设置
egg. JS project deployment online server
sys.argv
【MySQL】日志
China polyether amine Market Forecast and investment strategy report (2022 Edition)
Roguelike game into crack the hardest hit areas, how to break the bureau?