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.

Parents
  • In the make file you can adjust the stack and the heap size:

    ASMFLAGS += -D__STACK_SIZE=16392
    ASMFLAGS += -D__HEAP_SIZE=16392
    

    then in the SDK folder nRF5_SDK_11_0_0_89a8197\components\toolchain\gcc there is file called gcc_startup_nrf52.s. I am always just making sure that the heap and stack settings in there are the same as in the makefile. However, I am not sure about the correlation though.

    If you do very very fancy printf things you might be running out of stack. Quiet unlikely since the default value is actually set to 8kb. Anyway still worth trying.

Reply Children
No Data
Related