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. */

GROUP(-lgcc -lc -lnosys)

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

  .fs_data :
    PROVIDE(__start_fs_data = .);
    PROVIDE(__stop_fs_data = .);
  } > RAM

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.

No Data
  • RTT breaks by no longer printing out to the console. Here are the #defines I see in my SEGGER_RTT_Conf.h file:

    #define SEGGER_RTT_MAX_NUM_UP_BUFFERS             (2)     // Max. number of up-buffers (T->H) available on this target    (Default: 2)
    #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS           (2)     // Max. number of down-buffers (H->T) available on this target  (Default: 2)
    #define BUFFER_SIZE_UP                            (1024)  // Size of the buffer for terminal output of target, up to host (Default: 1k)
    #define BUFFER_SIZE_DOWN                          (16)    // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
    #define SEGGER_RTT_PRINTF_BUFFER_SIZE             (64u)    // Size of buffer for RTT printf to bulk-send chars via RTT     (Default: 64)
    #define SEGGER_RTT_MODE_DEFAULT                   SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
No Data