Segger RTT : Real Time Terminal SRAM 調試解決方法

http://segger.com/jlink-real-time-terminal.htmlhtml

Real Time Terminal

SEGGER's Real Time Terminal (RTT) is the new technology for interactive user I/O in embedded applications.
With RTT it is possible to output information from the target microcontroller as well as sending input to the application at a very high speed without affecting the target's real time behaviour.app

RTT supports multiple up (to the host) and down (to the target) channels to write and read data of different kinds. The default implementation uses one channel per direction:ide

Channel Typical Purpose
Up-channel 0 Terminal output
Down-Channel 0 Keyboard input

SEGGER RTT can be used with any J-Link model and any supported target processor which allows background memory access, which are Cortex-M and RX targets.函數

Data from Up-channel 0 can be read via a Telnet connection to localhost:19021, which is opened by the J-Link software locally on the computer, when the J-Link is active. The Telnet connection also receives keyboard input for Down-channel 0.post

 

The J-Link RTT Client, which automatically connects and re-connects to an open J-Link connection is part of the J-Link Software and Documentation Pack and can be used instead of a simple Telnet client.spa

With J-Link RTT Logger, data from Up-Channel 1 can be read and logged to a file. This channel can for example be used to send performance analysis data to the host.debug

J-Link RTT Logger opens a dedicated connection to J-Link and can be used stand-alone, without running a debugger.調試

The application is part of the J-Link Software and Documentation Pack.orm

 

//
// Allocate buffers for channel 0
//
static char _acUpBuffer  [BUFFER_SIZE_UP];
static char _acDownBuffer[BUFFER_SIZE_DOWN];
//
// Initialize SEGGER Real-time-Terminal control block (CB)
//
static SEGGER_RTT_CB _SEGGER_RTT = {
  "SEGGER RTT",
  SEGGER_RTT_MAX_NUM_UP_BUFFERS,
  SEGGER_RTT_MAX_NUM_DOWN_BUFFERS,
  {{ "Terminal", &_acUpBuffer[0],   sizeof(_acUpBuffer),   0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }},
  {{ "Terminal", &_acDownBuffer[0], sizeof(_acDownBuffer), 0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }},
};

_SEGGER_RTT 會有兩個副本, 第一個副本用來初始化第二個副本
當在FLASH中運行, 第一個副本位於FLASH, 第二個副本位於SRAM, 程序啓動時, 從第一個副本複製到第二個副本.
這樣在SRAM中只有一個字符串 "SEGGER RTT" RTT 能夠正肯定位 _SEGGER_RTT 在 SRAM 中的地址 ( 搜索整個SRAM區域 )


當在SRAM中運行, 兩個副本均在 SRAM, 這樣 RTT 可能錯誤定位 _SEGGER_RTT 於用來初始化第二個副本的第一個副本
用來初始化第二個副本的第一個副本的 RING_BUFFER 的 WrOff 和 RdOff 一直是 0, 因此沒有數據可讀取.

修改 static SEGGER_RTT_CB _SEGGER_RTT = {  "SEGGER RTT", ... 
成爲 static SEGGER_RTT_CB _SEGGER_RTT = {  "SEGGER_RTT", ... 

而後添加函數

void SEGGER_RTT_Init( void )
{
  _SEGGER_RTT.acID[6] = ' '; // SEGGER RTT
}

而後

  SEGGER_RTT_Init(); // 初始化以後, RTT 能夠正肯定位 _SEGGER_RTT 在 SRAM 中的地址 ( 搜索整個SRAM區域 )

  SEGGER_RTT_ConfigUpBuffer( 0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL );
  SEGGER_RTT_WriteString( 0, "SEGGER Real-Time-Terminal Sample\r\n\r\n" );

在SRAM調試解決方法htm

修改 static SEGGER_RTT_CB _SEGGER_RTT = {  "SEGGER RTT", ... 
成爲 static SEGGER_RTT_CB _SEGGER_RTT = {  "SEGGER_RTT", ... 

而後添加函數

void SEGGER_RTT_Init( int UpFlags, int DownFlags )
{
  _SEGGER_RTT.acID[6] = ' '; // SEGGER RTT  _SEGGER_RTT.aUp[ 0 ].Flags = UpFlags;
  _SEGGER_RTT.aDown[ 0 ].Flags = DownFlags;
}

  // 初始化以後, RTT 能夠正肯定位 _SEGGER_RTT 在 SRAM 中的地址 ( 搜索整個SRAM區域 )
  SEGGER_RTT_Init( SEGGER_RTT_MODE_NO_BLOCK_SKIP, SEGGER_RTT_MODE_NO_BLOCK_SKIP );
  SEGGER_RTT_WriteString( 0, "SEGGER Real-Time-Terminal Sample\r\n\r\n" );

 

 

JLINK RTT 新版本 SRAM 調試解決方案

新版本 SRAM 調試解決方案  : RTT_Implementation_140925.zip

// ******************************* SEGGER_RTT_Conf.h ************************************
//
// Define SEGGER_RTT_IN_RAM as 1
// when using RTT in RAM targets (init and data section both in RAM).
// This prevents the host to falsly identify the RTT Callback Structure
// in the init segment as the used Callback Structure.
//
// When defined as 1,
// the first call to an RTT function will modify the ID of the RTT Callback Structure.
// To speed up identifying on the host,
// especially when RTT functions are not called at the beginning of execution,
// SEGGER_RTT_Init() should be called at the start of the application.
//
#define SEGGER_RTT_IN_RAM                         (1)

// ******************************* SEGGER_RTT.c ************************************
//
// Initialize SEGGER Real-time-Terminal control block (CB)
//
static SEGGER_RTT_CB _SEGGER_RTT = {
#if SEGGER_RTT_IN_RAM
  "SEGGER RTTI",
#else
  "SEGGER RTT",
#endif
  SEGGER_RTT_MAX_NUM_UP_BUFFERS,
  SEGGER_RTT_MAX_NUM_DOWN_BUFFERS,
  {{ "Terminal", &_acUpBuffer[0],   sizeof(_acUpBuffer),   0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }},
  {{ "Terminal", &_acDownBuffer[0], sizeof(_acDownBuffer), 0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }},
};


/*********************************************************************
*
*       _Init
*
*  Function description
*    In case SEGGER_RTT_IN_RAM is defined,
*    _Init() modifies the ID of the RTT CB to allow identifying the
*    RTT Control Block Structure in the data segment.
*/
static void _Init(void) {
#if SEGGER_RTT_IN_RAM  if (_SEGGER_RTT.acID[10] == 'I') {    _SEGGER_RTT.acID[10] = '\0';  }#endif}
相關文章
相關標籤/搜索