This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/CC2640: Linker fails but there is RAM available

Part Number: CC2640

Tool/software: TI C/C++ Compiler

Hello,

I'm working on a project based on the SimpleBLEPeripheral, and when increasing the stack size of one of my tasks, I run into this error.

cc26xx_ble_app_oad.cmd", line 119: error #10099-D: program will not fit into available memory.  run placement with alignment fails for section ".stack" size 0x258 .  Available memory ranges:
   SRAM         size: 0x44bf       unused: 0x553        max hole: 0x23b    


What I found weird about the error is that an allocation for 0x258 (600) bytes fails, there are 1363 (0x553) bytes free, and the biggest hole is only 0x23b (571) bytes long. Why is this happening? Is there any way to make the linker rearrange the RAM so that a bigger hole is created and I can use the remaining RAM?

This is my linker script:

#ifndef APP_BASE
#define APP_BASE                0x00000000
#endif //APP_BASE

#define FLASH_SIZE              0x20000
#define PAGE_SIZE               0x1000
#define RAM_BASE                0x20000000
#define RAM_SIZE                0x5000


/* System memory map */

MEMORY
{
    /* Application stored in and executes from internal flash starting at 0x0 */
    /* Flash Size 128 KB */
    #ifdef ICALL_STACK0_ADDR
        FLASH (RX) : origin = APP_BASE, length = ICALL_STACK0_ADDR - APP_BASE - 1
    #else // default
        FLASH (RX) : origin = APP_BASE, length = 0x0000CFFF
    #endif

    /* Application uses internal RAM for data */
    /* RAM Size 16 KB */
    #ifdef ICALL_RAM0_ADDR
        SRAM (RWX) : origin = RAM_BASE, length = ICALL_RAM0_ADDR - RAM_BASE - 1
    #else //default
        SRAM (RWX) : origin = RAM_BASE, length = 0x00002CFF
    #endif
}

/* Section allocation in memory */

SECTIONS
{
    .intvecs        :   > APP_BASE
    .text           :   > FLASH
    .const          :   > FLASH
    .constdata      :   > FLASH
    .rodata         :   > FLASH
    .cinit          :   > FLASH
    .pinit          :   > FLASH
    .init_array     :   > FLASH
    .emb_text       :   > FLASH

    .vtable         :   > SRAM
    .vtable_ram     :   > SRAM
     vtable_ram     :   > SRAM
    .data           :   > SRAM
    .bss            :   > SRAM
    .sysmem         :   > SRAM
    .stack          :   > SRAM (HIGH)
    .nonretenvar    :   > SRAM
}

/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties    */
__STACK_TOP = __stack + __STACK_SIZE;

Thanks!