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.

Linux/CC3200MODLAUNCHXL: How to handle the stack

Intellectual 290 points

Replies: 4

Views: 601

Part Number: CC3200MODLAUNCHXL

Tool/software: Linux

Hello,

I'm using the gcc compiler for linux, openOCD for emulation and UniFlash for Flash file loading.

My code is getting too big and the linker says: section `.heap' will not fit in region `SRAM'

For a while I worked around this issue by allocating less heap size: from 64kB to 32kB.

Before continue coding I need to know the max allowable size of mcuimage.

I haven't found where to set the allocated stack size in RAM.

My questions are:

0- How and where do I handle the stack?

1- Are the static variables allocated at run time in the stack or are they allocated in the data section?

2- Does the linker dynamically allocate space for stack in RAM or should I need to specify it somewhere?

3- How can I generate the RAM .map file while compiling?

4- Where can I find more information about the SRAM management?

Thanks,

Rosario

4 Replies

  • Moving this to the SimpleLink CC31xx/CC32xx Forum.

    Best Regards,
    Yordan

     


     Please make sure you read the forum guidelines first.

  • Guru 37655 points

    In reply to Yordan Kovachev:

    Hi Rosario,

    I think for CC3200 development is better to use Code Composer Studio. It is developed by TI and fully supported by TI, it it free and works well with Linux.

    Because CC3200 haven't on chip flash memory for code executing, you need fit your code and RAM stuff into 256kB of RAM memory. You have two regions of RAM - SRAM_DATA (contains read/write data) and SRAM_CODE (your code). Inside SRAM_DATA is bigger section .bss. The .bss section contains .heap for your dynamic allocations.

    Answers to your questions:
    - Stack can be located at two places. Inside section SRAM_DATA is located stack for main. If is used RTOS (TI-RTOS, FreeRTOS) and tasks are created dynamically, then stack for task is located in .heap.
    - Static variables are not located in .heap or .stack. Static variables are located in .bss or .data section in SRAM_DATA area.
    - Stack size and heap size need to be set before compiling. Compiler is not able determine your requirements for stack.
    - I don't know can you do that with gcc. But in CCS you have rich tools like Memory Allocation tool, RTOS Object View, etc. With only gcc you will not have this tools and your works will be much harder.
    - Information about memory management of gcc you find at documentation for gcc. But I am not able say where you need search.

    Jan


    Please click to "Verify Answer", if your question was answered.

  • In reply to Jan D:

    Thank you Jan,
    I managed to run CCS and compiled my project with the TI compiler so I was able to see the memory allocation section.
    My application use FreeRTOS.
    With GCC I have to declare the heap section in the linker script, but with CCS do I have to declare it in properties->Build->ARM Linker->Basic Options->Heap Size?
    From the comparison between GCC and TI compiler I see that GCC linker script allows me to allocate only .heap section and (apparently) manage all other sections from the output of the builder, CCS allows me to declare stack size, heap size and the dimensions of the sections SRAM_CODE and SRAM_DATA.

    I would like to know if I have to allocate a .heap section "arbitrary" big enough or if there is a method to know the space needed by the application.

    Here I post the two linker scripts:

    cc3200.ld (GCC) from TI blinky example
    *********************************************
    HEAP_SIZE = 0x00008000;

    MEMORY
    {
    /* SRAM size of 240KB for cc3200 ES 1.33 device onward */
    SRAM (rwx) : ORIGIN = 0x20004000, LENGTH = 0x3C000
    }

    SECTIONS
    {
    .text :
    {
    _text = .;
    KEEP(*(.intvecs))
    *(.text*)
    *(.rodata*)
    *(.ARM.extab* .gnu.linkonce.armextab.*)
    . = ALIGN(8);
    _etext = .;
    } > SRAM

    .ARM : {
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
    } > SRAM

    __init_data = .;

    .data : AT(__init_data)
    {
    _data = .;
    *(.data*)
    . = ALIGN (8);
    _edata = .;
    } > SRAM

    .bss :
    {
    _bss = .;
    *(.bss*)
    *(COMMON)
    _ebss = .;
    } > SRAM

    .heap :
    {
    _heap = .;
    . = . + HEAP_SIZE;
    . = ALIGN(8);
    _eheap = .;

    }
    }
    *********************************************

    cc3200R1.cmd (TI)
    *********************************************
    #define RAM_BASE 0x20004000

    /* System memory map */

    MEMORY
    {
    /* Application uses internal RAM for program and data */
    /* RAM section devided into CODE and DATA sections equally (120kb each) */
    /* user can change these values as per application's need */
    SRAM_CODE (RWX) : origin = 0x20004000, length = 0x29000
    SRAM_DATA (RWX) : origin = 0x2002D000, length = 0x13000
    }

    /* Section allocation in memory */

    SECTIONS
    {
    .intvecs: > RAM_BASE
    .init_array : > SRAM_CODE
    .vtable : > SRAM_CODE
    .text : > SRAM_CODE
    .const : > SRAM_CODE
    .cinit : > SRAM_CODE
    .pinit : > SRAM_CODE
    .data : > SRAM_DATA
    .bss : > SRAM_DATA
    .sysmem : > SRAM_DATA
    .stack : > SRAM_DATA(HIGH)
    }
    *********************************************

    Thanks,
    Rosario
  • Guru 37655 points

    In reply to Rosario Borsellino:

    Hi Rosario,

    Because .heap is used for dynamic allocations, compiler itself cannot determine proper size. This is on you. You need select reasonable size according requirements of your application.
    CCS contains some tool which can help you with selection of your .heap size. This tool is called RTOS Object View (max heap value). Unfortunately FreeRTOS is not supported. RTOS Object View is supported only by TI-RTOS.

    I haven't experienced with gcc toolchain for CC3200. From this reason I am not able help you with gcc much. But information, that is not possible set size and location of CODE and DATA in RAM sounds me unbelievable. Because this is very important thing for every a little bigger project with CC3200.

    Jan


    Please click to "Verify Answer", if your question was answered.

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.