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

Weird Problem where Segger RTT breaks if using more than 8kB of RAM

I started a new software project on the nRF52832 a couple of weeks ago. I've been using Segger RTT for a lot of debugging with no problem throughout the beginning of the process. I've recently hit an issue where the Segger RTT printf statements stop showing up when I use more than 8kB of RAM. I should have almost 49,000 bytes of RAM remaining, so I'm nowhere near close to running out of RAM.

I've gotten to the point where I can compile my code with or without a single global uint32_t variable and if that variable is included the Segger RTT stuff will not work properly (note that as far as I can tell, everything else appears to work properly).

I'm using the S132 Soft Device and am using GCC to compile the code.

Here are the code size results from compilation:

   text	   data	    bss	 
  40860	    176	   7828	

This uses 8004 Bytes of RAM, and that's when the Segger RTT breaks.

Here's the linker script that I'm using:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000	/* 397312 Bytes */ 
  RAM (rwx) :  ORIGIN = 0x20002128, LENGTH = 0xded8	/* 57048 Bytes */ 
}

SECTIONS
{
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM
} INSERT AFTER .data;

INCLUDE "nrf5x_common.ld"

EDIT: I realized it might be worth mentioning that I'm allocating 4608 Bytes of RAM via the SDK provided memory manager.

  • That actually worked, but I'm not quite sure why. I'm not printing a lot (just a version number, the BT advertising name, and then some data in a callback. Also, it was commenting or uncommenting other variables (unrelated to the Segger RTT) which caused it to stop working.

    Either way it works now, so thank you very much for the suggestion!

Related