[RT595] Porting JLink RTT to RT595

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

[RT595] Porting JLink RTT to RT595

[RT595] Porting JLink RTT to RT595

Porting JLink RTT to RT595

Porting JLink RTT to RT595
       
1. Introduction
       
2. RTT (Real-Time Terminal)
       
3. Porting
                
Steps for Porting
       
4. Conclusion

1. Introduction

For most beginners learning MCU or embedded systems, the first step often involves simple tasks like "lighting up an LED" or a "Hello World" program. Today, we will discuss a topic closely related to "Hello World."

Serial output is a highly effective debugging tool, allowing developers to monitor program states, interact with the program, and diagnose issues. This is a familiar friend to anyone engaged in embedded development.

The most common approach, as seen in NXP SDK examples, uses a UART peripheral for logging:

  1. Initialize the MCU's UART:
    • Configure clock frequency, pin multiplexing, pin settings, baud rate, etc.
  2. Open a serial tool on the PC and configure the correct baud rate.
  3. Use the UART driver in the project to enable serial logging.

This is the simplest and most widely used method for serial output. However, what if the precious UART resource is already occupied? Here's a great alternative: porting SEGGER's RTT (Real-Time Terminal) driver and using the JLink RTT functionality for logging. The biggest advantage of this approach is conserving UART resources!

Next, let’s explore the powerful capabilities of JLink RTT.

2. RTT (Real-Time Terminal)

RTT, developed by SEGGER, is a real-time terminal solution for interactive communication in embedded applications. Beyond conserving UART resources, RTT offers significant advantages over semi-hosting methods provided by tools like MCUXpresso IDE. RTT allows for high-speed bidirectional data transfer between the MCU and the host without compromising real-time performance.

Key features of JLink RTT include:

  • Low Overhead: Efficient data transfer mechanisms ensure minimal impact on target system performance.
  • Real-Time Capability: Developers can output debugging information or receive data from the target system in real time without halting execution.
  • Flexibility: Supports multiple channels for transmitting different types of data, such as debugging logs and performance metrics.
  • OS Independence: Unlike traditional printf debugging methods, RTT can be used on embedded systems without an operating system.

JLink RTT typically pairs with JLink debuggers and SEGGER's development tools, providing powerful support for debugging and tracking embedded systems. To try out this functionality, a JLink debugger is essential.

Using the classic RT595-EVK as an example, we will demonstrate how to port RTT.

3. Porting

The development environment includes the MCUXpresso IDE and the hello_world project from the SDK. The SDK version is not critical.

Steps for Porting

  1. Locate RTT Resources
    According to SEGGER's official documentation, RTT resources can be found in the JLink installation directory:
  • Gavin_Jia_0-1733385872441.png

     

  • C:\Program Files\SEGGER\JLink\Samples\RTT
  1. Copy Required Files
    Copy the following files to the
    source folder of the hello_world project:
    • SEGGER_RTT_Syscalls_GCC.c
    • SEGGER_RTT_Conf.h
    • SEGGER_RTT_printf.c
    • SEGGER_RTT.c
    • SEGGER_RTT.h
  • Copy these source files to the source folder of the hello_world project:
  • Gavin_Jia_1-1733385872639.png

     

  1. Integrate into Project
    If using Keil or IAR, you may need to add header file dependencies. However, since the RTT files are placed directly in the MCUXpresso project’s
    source folder, you only need to call the relevant RTT functions in hello_world.c.
  • Gavin_Jia_2-1733385872721.png

     

  1. Initialize and Configure Buffers
    Add the following code to initialize RTT and create up/down buffers:
  • SEGGER_RTT_Init();
    uint8_t rx_buffer[32], tx_buffer[32];
    SEGGER_RTT_ConfigUpBuffer(0, "RTTUP", rx_buffer, sizeof(rx_buffer), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
    SEGGER_RTT_ConfigDownBuffer(0, "RTTDOWN", tx_buffer, sizeof(tx_buffer), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
    SEGGER_RTT_SetTerminal(0);
    SEGGER_RTT_printf(0, "hello world\r\n");
  • Use RTT for sending:
  • SEGGER_RTT_SetTerminal(0);
    SEGGER_RTT_printf(0, "hello world\r\n");
  • Here, after we port the file and add the RTT operation to the source code of hello_world, the code part is ready to be completed.
  1. Use JLink RTT Viewer
    Launch the JLink RTT Viewer program, select the appropriate device number, run the program, and open "Terminal 0" to view the output.
  • Gavin_Jia_3-1733385872826.png

     

4. Conclusion

Compared to traditional UART-based logging, utilizing the debugger’s built-in RTT functionality reduces peripheral usage and eliminates the need for UART initialization and configuration. With JLink, RTT is essentially plug-and-play, providing convenient and fast logging and interaction.

In addition to basic functionality, SEGGER offers advanced features such as changing font colors. Explore more on SEGGER's official website:
SEGGER RTT Documentation

 

For Chinese version and demo project, please check this link:
https://www.nxpic.org.cn/module/forum/forum.php?mod=viewthread&tid=803638&fromuid=3253523

附件
无评分
版本历史
最后更新:
‎12-05-2024 01:07 AM
更新人: