Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Easy way to merge bootloader and application RTT output

In general, it's not a question, but the only suggestion for SDK developers how to improve debugging way.

So, while implementing DFU upgrade in my project I faced to the minor problem: RTT logging can work in application, or in bootloader, but not in both parts of firmware together.

This trouble occurs from the RTT nature when debugger looking for "SEGGER RTT" string in RAM to use this address as buffer start. Simplest solution - fix RTT buffer position on predefined address in app and bootloader.

Steps how to do this in GCC/Eclipse:

1) in the top of file SEGGER_RTT_conf.h put define 

#define SEGGER_RTT_SECTION ".rtt"

preprocessor will convert _SEGGER_RTT into 

__attribute__ ((section (".rtt"))) SEGGER_RTT_CB _SEGGER_RTT
this directive instructs linker to put RTT structure to ".rtt" section of RAM

2)  Allocate section in linker script file. In nrf5x_common.ld put

.rtt:
{
} > RAM

before section .data (in SDK 14.2: before line 92)

Now rtt buffer locates exactly at RAM begin.

Also check both local *.ld files for similar RAM settings. To give enough RAM for SoftDevice I set both projects with extra RAM space:

RAM (rwx) :  ORIGIN = 0x20003000, LENGTH = 0xd000

You can tune this value later, to avoid "NOT_ENOUGH_MEMORY" error from SD

3) Synchronize RTT settings between application and bootloader. I did it by moving RTT-related defines from both sdk_config.h into common rtt_config.h and put this file into commonly accessed folder inside SDK, actually in SDK/external/segger_rtt

After recompiling both projects I can see continuous log after sending "DFU update" command:

As you see, bootloader warns me about extra RAM settings. Thank you, bootloader, but I'll keep this.

So, my question to SDK developers: is it possible to add this functionality to next SDK release?

Parents
  • Additionally, on app start SEGGER_RTT_Init is run again which leads to loss of output from bootloader. To prevent this, you can modify SEGGER_RTT_INIT in SEGGER_RTT.c to check the memory is initialised (just first character here but you could check the string equals "SEGGER"):

    void SEGGER_RTT_Init (void) {
        if(_SEGGER_RTT.acID[0] != 'S') {
            _DoInit();
        }
    }

Reply
  • Additionally, on app start SEGGER_RTT_Init is run again which leads to loss of output from bootloader. To prevent this, you can modify SEGGER_RTT_INIT in SEGGER_RTT.c to check the memory is initialised (just first character here but you could check the string equals "SEGGER"):

    void SEGGER_RTT_Init (void) {
        if(_SEGGER_RTT.acID[0] != 'S') {
            _DoInit();
        }
    }

Children
No Data
Related