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

RTT logging from application started by bootloader

Hello, Is it possible to get logs (RTT) from an application started by a bootloader? As of now I don't get anything after the bootloader has jumped to the application start address.

If I run the application separately it works.

Thanks, Jacob

Parents
  • Hi Jacob,

    If you have a look here at the section on how RTT work. You can find that it was not the different channel caused the problem, it's the different allocation of RAM area for the RTT Control Block and the RTT buffer location caused the problem.

    If we match the Control Block address and the RTT buffers location the same on the bootloader and the application, then everything works.

    This is the modification I did to SEGGER_RTT.c from line 135:

    static char _acUpBuffer  [BUFFER_SIZE_UP] __attribute__((at(0x20003C00)));
    static char _acDownBuffer[BUFFER_SIZE_DOWN]__attribute__((at(0x20003F00))); ;
    //
    // Initialize SEGGER Real-time-Terminal control block (CB)
    //
    SEGGER_RTT_CB _SEGGER_RTT __attribute__((at(0x20002C00))); 
    

    I used attribute to force the linker to put the buffer is defined location. You don't have to use the same addresses, it can be any where in RAM (of course in the application RAM range).

Reply
  • Hi Jacob,

    If you have a look here at the section on how RTT work. You can find that it was not the different channel caused the problem, it's the different allocation of RAM area for the RTT Control Block and the RTT buffer location caused the problem.

    If we match the Control Block address and the RTT buffers location the same on the bootloader and the application, then everything works.

    This is the modification I did to SEGGER_RTT.c from line 135:

    static char _acUpBuffer  [BUFFER_SIZE_UP] __attribute__((at(0x20003C00)));
    static char _acDownBuffer[BUFFER_SIZE_DOWN]__attribute__((at(0x20003F00))); ;
    //
    // Initialize SEGGER Real-time-Terminal control block (CB)
    //
    SEGGER_RTT_CB _SEGGER_RTT __attribute__((at(0x20002C00))); 
    

    I used attribute to force the linker to put the buffer is defined location. You don't have to use the same addresses, it can be any where in RAM (of course in the application RAM range).

Children
  • Cool - got it working now with GCC like this:

    static char __attribute__((section(".rtt_ac_up"))) _acUpBuffer  [BUFFER_SIZE_UP];
    static char __attribute__((section(".rtt_ac_down"))) _acDownBuffer[BUFFER_SIZE_DOWN];
    SEGGER_RTT_CB __attribute__((section(".rtt_segger"))) _SEGGER_RTT;
    

    and corresponding .ld file:

    SECTIONS
    {
      .rtt_ac_up 0x20003000 :
      {
        KEEP(*(.rtt_ac_up))
      } > RAM
      .rtt_ac_down 0x20003800 :
      {
        KEEP(*(.rtt_ac_down))
      } > RAM
      .rtt_segger 0x20003880 :
      {
        KEEP(*(.rtt_segger))
      } > RAM
    }
    

    Thank you so much for the help!

  • What is recomended place for RAM and what are the sizes needed?

  • Ok here is what i have found in `sdk_config.h`:

    `#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 1024`
    `#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16`

    which is used for `BUFFER_SIZE_UP` and `BUFFER_SIZE_DOWN`.

    so if start location is `0x20006000` then:

    ```

    >>> hex(int('20006000', 16) + 1024)
    '0x20006400'
    >>> hex(int('20006000', 16) + 1024 + 16)
    '0x20006410'

    ```

    would be the next two.

    But then i get the error:

    `/home/work/software/arm/gcc-arm-none-eabi-4_9-2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: section .rtt_ac_down loaded at [20006400,2000640f] overlaps section .rtt_ac_up loaded at [20006000,20006fff]`

    The i have moved to:

    `0x20006000`, `0x20007000`, `0x20007010`.

    It compiles but the issue is not fixed. I still have to use connect in jlinkexe to see the application code.

  • Please state what exactly you did to assign the address of the segger rtt buffer. I would suggest you to create a new case with the link to this case. 

  • For anyone encountering this problem now, since at least SDK 16 (haven't looked back further), you can simply define a few macros in your app/sdk_config.h:

    #define SEGGER_RTT_ALIGNMENT 4
    #define SEGGER_RTT_BUFFER_ALIGNMENT 4
    #define SEGGER_RTT_SECTION ".rtt_cb"
    #define SEGGER_RTT_BUFFER_SECTION ".rtt_buffers"

    and add the corresponding sections to your linker files:

    MEMORY
    {
      ...
      /* Put RTT data at top of RAM. */
      /* RTT_CB LENGTH = 24 + SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS * 24
                            + SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS * 24 */
      RTT_CB (rw) : ORIGIN = 0x2003ff88, LENGTH = 0x78
      /* RTT_BUFFERS LENGTH = + SEGGER_RTT_CONFIG_BUFFER_SIZE_UP
                              + SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN */
      /* RTT_BUFFERS ORIGIN = 0x20040000 - CB LENGTH - BUFFERS LENGTH */
      RTT_BUFFERS (rw) : ORIGIN = 0x2003ef78, LENGTH = 0x1010
    }
    
    SECTIONS
    {
      .rtt_buffers :
      {
        KEEP(*(.rtt_buffers))
      } > RTT_BUFFERS
      .rtt_cb :
      {
        KEEP(*(.rtt_cb))
      } > RTT_CB
    }
    
    

Related