# How To Print Module Logs Through JLink

#1. Introduction

Segger's RTT technology is a method used for real-time debugging in embedded systems through JTAG/SWD, and currently supports Cortex M-series processors. He is used for real-time data interaction with PC through emulators. The main purpose is for debugging printing and CLI command interaction.

Although our current mxos systems all have a debug serial port that can be used for log output and Cli interaction, RTT has the following advantages:

Although our current mxos systems all have a debug serial port that can be used for log output and Cli interaction, RTT has the following advantages:

  1. The interaction speed of RTT is fast, which can avoid the interference of printf on system performance. Because for MCU, RTT only accesses a section of RAM area and does not affect the system's timing, while debug uart is affected by baud rate and has interference with the system;
  2. RTT can support up to 3 outputs and can print to 3 different terminals, achieving graded debugging;
  3. Some systems may use debug uart for other purposes and cannot use it. We can also debug through the JTAG/SWD interface.

Turn off standard input and output in MXOS

At mxos_ Add the following definition to config. h:

#Define MXOS_ DISABLE_ STDIO

Most logs can be closed, but the printing in the protocol stack cannot be completely removed. Therefore, if you want to send data through the log serial port, remember to add integrity verification.

#2. How to use RTT debugging under MXOS

  • Import RTT components under mxos: git clone git@code.aliyun.com : mxos/SEGGER_ RTT.git
  • The system includes SEGGER_ RTT component: $(NAME) Components+=SEGGERRTT
  • Using SEGGER_ RTT_ Printf implements log output. Prototype of this function: int SEGGER_ RTT_ Printf (unsigned BufferIndex, const char * sFormat,...), the first parameter is the output path, usually using 0.
  • If you need to use RTT for CLI interaction, you need to modify mxos_ Config.h file, add: # define MXOS_ CLI_ ENABLE 0. Close the system's CLI and call rtt_ Cli_ Init() opens the CLI function of RTT; Call mxos_ System_ Cli_ Cmds_ Add () adds the system CLI command for mxos.

#3. How to Implement RTT Debugging on PC

Software and driver installation

Kit for installing jlink: https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack (opens new window)

Run PC tool:Jlink RTT Viewer

Software Configuration:

  • Select Target Device:CORTEX-M4、CORTEX-M3 and so on。Tips:the parameter can get through Datasheet or contact with IC provider.
  • Select Target Interface:JTAG or SWD.
  • Input the address of RTT Control Block. This Address needs to be obtained by querying the map table compiled by mxos. In the build directory, the suffix is. map

Demo:

As above,If the address of . bss_ SEGGER_ RTT in the map table is 0x1000ea60, enter this address in Jlink RTT Viewer.

Click OK.

By completing the RTT connection through the above steps, the print information of mxos will be displayed on the PC.

Small Mechanism:

When using the CLI for interaction, please select 'Input ->Sending' in the menu bar and select 'Send On Enter'. This will allow RTT to wait for me to input the complete CLI command before sending it to the module. If separate multi output is required, you can select 'Terminals ->' Add next terminal 'in the menu bar to add.

#4. References

https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/ (opens new window)

#5. Update Record

Version

Update

Date

V1.0

Initial

2021.12.27

V1.1

Add content to disable standard input/output streams in mxos.

2022.2.10

Last Updated: 11/29/2023, 1:52:34 PM