This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RTT waste more ram than you thought

In the function log_rtt_init(), the SEGGER_RTT_ConfigUpBuffer()/SEGGER_RTT_ConfigDownBuffer() can't config the customize buffer if the parameter buffer index equal to 0 ( BUT LOG_TERMINAL_NORMAL is 0 ). So the static buf_normal_up[]/buf_down[] are useless. And you should use SEGGER_RTT_Init() instead.

PS. The RTT buffer index isn't terminal index. Terminal data should always store in the buffer 0, and the terminal index is a special two bytes identifier (0xFF + ASCII 0-F). In this way, the NRF_LOG_ERROR() will not print anything in the terminal, because LOG_TERMINAL_ERROR is 1. BTW, the buffer channel 1 is used by SYSTEM VIEWER.

  • Hi,

    I also use RTT in my application, running on an nRF51 chip with 16k RAM. I use RTT only to send trace messages to a PC client (SEGGER_RTT_BUFFER_UP) and I do not need the SEGGER_RTT_BUFFER_DOWN buffer at all.

    In the latest RTT implementation given by Segger (RTT version 5.12b), the buffer are declared 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;
    

    Depending on the compiler, it is not allowed to declare an array with a length of '0'. Is there a Nordic implementation of RTT which allow to disable the down buffer ? I have a limited amount of RAM and I do not like to lost bytes for a buffer I do no use.

  • Did you remove the buf_normal_up[] and buf_down[] ? and try this config:

    #define SEGGER_RTT_MAX_NUM_UP_BUFFERS             (1)     // Max. number of up-buffers (T->H) available on this target    (Default: 2)
    #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS           (1)     // Max. number of down-buffers (H->T) available on this target  (Default: 2)
    
    #define BUFFER_SIZE_UP                            (64)   // Size of the buffer for terminal output of target, up to host (Default: 1k)
    #define BUFFER_SIZE_DOWN                          (1)    // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
    
  • Yes, I can patch the files provided by Segger/Nordic, but I think this is more like a bug.

Related