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.

CCS/MSP432P401R: How to increase stack size of the RTOS application.

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hello All,

I'm working on MSP432P401R TI-RTOS application. I'm unable to increase stack size for my application thread.

I have tried changing from linker options, MSP_EXP432P401R_TIRTOS.cmd file and THREADSTACKSIZE as well but nothing worked. It's showing 504 all the time. When I hover the cursor on mainThread it shows 504 out of 504 bytes used (100%).

Please correct me if I am wrong.

Please find the attached screenshots.

Regards,

Keshav Aggarwal

  • Hi Keshav,

    First let's make sure we are talking about the right stack. There are two different types of stacks with TI-RTOS:

    • System stack: Used by interrupts
    • Task stacks: each task gets a dedicated stack.

    Another point: a POSIX thread is really just a TI-RTOS task. 

    System Stack

    The system stack can be set in two different methods:

    1. Via the Program.stack setting in the .cfg file. Note: if this value is 0, the next method is used...

    2. Via the --stack_size linker option. Note: we include this setting in the linker files for the examples and it overrides the project properties setting.

    Task Stacks

    Task stacks cannot be set via a compiler setting or via the linker file. The task stack size of a task is set at creation. For example:

        Task_Params_init(&taskParams);
        taskParams.stackSize = THREADSTACKSIZE;
        taskParams.priority = 1;
        consoleHandle = Task_create((Task_FuncPtr)consoleThread, &taskParams, Error_IGNORE);

    Or if you are using the pthread APIS:

        pthread_attr_init(&attrs);
    
        ...
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
        ...
        retc = pthread_create(&thread, &attrs, mainThread, NULL);

    Unless a task stack is provided (via Task_Params's stack or via pthread_attr_setstack), a stack will be allocated, by default, from the system heap. 

    Here is some more training about stack usage: https://training.ti.com/debugging-common-application-issues-ti-rtos

    Todd