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.

RTOS/CC1310: Wanted to increase the size of system stack, but it doesn't work.

Part Number: CC1310

Tool/software: TI-RTOS

Hi,
I have a problem. I developed an application based on the routines(rfWsnConcentrator) in the CC1310 LAUNCHXL development board, I wanted to increase the size of the System stack ,but a compilation error occurred.
I increased the stack size by setting parameters in CCS under Project->Properties->C/C++ Build->Linker->Basic Options, --stack_size from the default 4096 to 4240 and a task stack from 1024 to 1120.
CCS hints below:
<Linking>
"../CC1310_LAUNCHXL_TIRTOS.cmd", line 95: error #10099-D: program will not fit into available memory. run placement with alignment fails for section ".stack" size 0x428 . Available memory ranges:
SRAM size: 0x5000 unused: 0x706 max hole: 0x3ed
error #10010: errors encountered during linking; "rfWsnConcentrator_MODBUS_V1.2.out" not built

Before modification, the memory usage during normal compilation is as follows:

******************************************************************************
TI ARM Linker PC v18.1.4
******************************************************************************
>> Linked Fri Jan 25 11:39:13 2019
OUTPUT FILE NAME: <rfWsnConcentrator_MODBUS_V1.2.out>
ENTRY POINT SYMBOL: "ResetISR" address: 0000a911
MEMORY CONFIGURATION
name origin length used unused attr fill
---------------------- -------- --------- -------- -------- ---- --------
FLASH 00000000 00020000 00013e96 0000c16a R X
SRAM 20000000 00005000 00004cc2 0000033e RW X

I feel the size of system stack has not been modified. And then I add a statement("Program.stack =4240;") to the "cc1310_lanunchxl_tirtos.cmd" file or "release.cfg" file, It also doesn't work.

How to solve this problem?

Best,

Stone

  • Hi Stone88,

    I'm not sure where you are getting that the default system stack size is 4096, as it should be 1024.

    Either way, you can change the the system stack by either:
    * Setting Program.stack = /* to some value */ in your "*.cfg" file, which is found under a separate TI-RTOS project for rfWsnConcentrator.
    * OR, setting --stack_size parameter in your project's linker options under the project properties.
    * OR, setting --stack_size=/* to some value */ in you project's linker file (CCS specific). Should be at the top of the linker file.

    After some quick testing, it seems that setting --stack_size in the linker file will override the other options, so you should only use one configuration method.

    Also, why do you want the system stack to be 4240 bytes? That seems like overkill. Setting the system stack to 4240 causes a linker error for me, which essentially means the program will not fit into RAM. Either decrease the system stack, or decrease the heap allocation.
  • Hi Severin,

    Thank you very much for your reply.

    It is mentioned in a pdf file that the default system stack size is 4096. The name of this pdf file is:
    TI-RTOS Kernel (SYS/BIOS) User's Guide
    Literature Number: SPRUEX3U
    February 2018 .

    In chapter :
    3.5.3 Software Interrupt Priorities and System Stack Size
    The default system stack size is 4096 bytes. You can set the system stack size by adding the following
    line to your config script:Program.stack = yourStackSize;

    Now in my program, the stack size of all tasks added together is 3944 (including idle tasks).
    I want to increase the system stack size in order to prevent the task stack overflow or be able to add a new task.

    I tested both of these methods, and neither worked.
    Is the unused memory space prompted in the memory file accurate? (unused: 33e)

    Best,

    Stone88
  • The default value of Program.stack in your project's *.cfg file (if not specified) is 4096, yes. However, if you open up your *.cfg you will see it is (most likely) set to 0.

    I'm not sure you understand what the system stack is used for. You say "in order to prevent the task stack overflow or be able to add a new task". Unless you are allocating task stacks on the system stack (which I do not recommend) then this is not an issue. If you are experiencing task overflows for a particular task then increase that task's stack, not the system stack. If you are allocating the task's stack statically, then the linker will complain if not enough memory is available. If you are allocating the task's stack dynamically, then the heap will run out of memory if you haven't allocated enough heap.
  • Hi Severin,

    Yes, I made a mistake. The task stack is independent of the system stack.

    The file(.map)prompt also has 830(0x33e) bytes unused , but only 70 bytes are actually available when tested. Where can I apply to see the correct free memory prompt?

    Best,

    Stone88
  • 830 bytes where? In flash or RAM?

    It depends on a lot of things, such as size of the object, alignment requirements of that object, available contiguous memory in flash or RAM, etc. Are you aware of the Memory Allocation view in CCS? Founder under View -> Memory Allocation.
  • In "Memory Allocation",it shows 830 byte unused in SRAM. (SRAM: 96% used)

    The hint of 830 bytes unused that misled me into increasing the stack size failure.

    But only 70 bytes are actually available when tested.

    How can I increase the stack size by more than 70 bytes?

    Best,

    Stone88
  • As a side note, I can't add more than 70 bytes to an array.

    Best,

    Stone88
  • Are you sure that your issue is really a stack overflow? Have you verified this with ROV?
  • Not sure it's a stack overflow.

    After about a minute of running the program, ROV prompts that one task stack is 80% used and the others are about 60% used.

    The program restarts about five or six times a day. So I want to add a task stack to test it.

    Best,
    Stone88
  • Could you share the project with me?
  • The project notes are in Chinese and the PCB is different from the development board.

    Does it affect your analysis? Your E-mail address?

    Thank you so much

    Best,

    Stone88
  • Thank you very much.

    The project notes are in Chinese. The circuit board is different from the development board.

    Does that affect your analysis?

    Your E-mail address?

    Tomorrow is the most important Spring Festival in China.There will be a week's holiday.

    Happy Spring Festival, although you do not Spring Festival.

    Best,
    Stone88
  • I sent you a private message on E2E, you can send me the CCS project there.
  • Hi,Severin,

    I have sent the CCS project to you through the way you sent it.

    Best,
    Stone88
  • I'm unable to run your application locally on my CC1310-LAUNCHXL as you most likely intend it to, but I'm able to at least compile and run the application. By looking at the allocated Task stacks, System stack and Heap, and comparing it to stack peaks and heap used, you can easily see what is both unnecessarily allocating memory and what requires more memory allocations.

    In CCS, you can open ROV in debug view under Tools -> Runtime Object View, and you can open Memory Allocation under View -> Memory Allocation..