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
  • I've done something similar for Segger Studio and it works.
    However, the power on scenario seems to only show the app's output. Any other reset and I see the merged output. Any insights into this ?
    Steps for Segger Studio:
    1. Add the .rtt section in RAM in flash_placement.xml for both projects (bootloader and app). Make sure its just after the .vectors_ram section:
    <ProgramSection alignment="4" load="No" name=".rtt" address_symbol="__start_rtt" end_symbol="__stop_rtt" />
    2. Make sure both projects have the same RAM_START address in *.emProject
    3. Refactor out the Segger configuration from both sdk_config.h's to a new file and add the following #define to the new file. Then include the file into both sdk_config.h's.
    #define SEGGER_RTT_SECTION ".rtt"
    4. Since the Segger buffers were previously in a zeroed section and now they are not, add two lines to the main.c of both projects:
    NRF_SECTION_DEF(rtt, uint8_t);

    int main(void)
    {
    memset(NRF_SECTION_START_ADDR(rtt), 0, NRF_SECTION_LENGTH(rtt));
    ...
  • I'm not familiar with Segger Studio, but every time when you observe different behaviour in power-on and reset sequences - you should check variables initialization. Ensure all your global variables have "static" type.

Reply Children
No Data
Related