Size of tasks control blocks (TCB)

leschge
Posts: 37
Joined: Fri May 06, 2022 1:38 pm

Size of tasks control blocks (TCB)

Postby leschge » Fri Jul 29, 2022 11:55 am

I want to save the core dump to flash for postmortem analysis.

The reference goes with a partition table example of 64k for this dump, however I want to use a custom partition table and therefore would like to calculate the needed size as precise as possible.

From https://docs.espressif.com/projects/esp ... _dump.html
"So partition size should be at least 20 + max tasks number x (12 + TCB size + max task stack size) bytes."

But where do I get the TCB size from?

From freertos I use

Code: Select all

    static inline IRAM_ATTR TaskHandle_t xTaskCreateStatic(
                                    TaskFunction_t pvTaskCode,
                                    const char * const pcName,   
                                    const uint32_t ulStackDepth,
                                    void * const pvParameters,
                                    UBaseType_t uxPriority,
                                    StackType_t * const puxStackBuffer,
                                    StaticTask_t * const pxTaskBuffer) PRIVILEGED_FUNCTION
with default

Code: Select all

typedef struct xSTATIC_TCB
{
    void * pxDummy1;
    #if ( portUSING_MPU_WRAPPERS == 1 )
        xMPU_SETTINGS xDummy2;
    #endif
    StaticListItem_t xDummy3[ 2 ];
    UBaseType_t uxDummy5;
    void * pxDummy6;
    uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
    BaseType_t xDummyCore;
    #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
        void * pxDummy8;
    #endif
    #if ( portCRITICAL_NESTING_IN_TCB == 1 )
        UBaseType_t uxDummy9;
    #endif
    #if ( configUSE_TRACE_FACILITY == 1 )
        UBaseType_t uxDummy10[ 2 ];
    #endif
    #if ( configUSE_MUTEXES == 1 )
        UBaseType_t uxDummy12[ 2 ];
    #endif
    #if ( configUSE_APPLICATION_TASK_TAG == 1 )
        void * pxDummy14;
    #endif
    #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
        void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
    #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
        void            *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
    #endif
    #endif
    #if ( configGENERATE_RUN_TIME_STATS == 1 )
        uint32_t ulDummy16;
    #endif
    #if ( configUSE_NEWLIB_REENTRANT == 1 )
        struct  _reent xDummy17;
    #endif
    #if ( configUSE_TASK_NOTIFICATIONS == 1 )
        uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
        uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
    #endif
    #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
        uint8_t uxDummy20;
    #endif

    #if ( INCLUDE_xTaskAbortDelay == 1 )
        uint8_t ucDummy21;
    #endif
    #if ( configUSE_POSIX_ERRNO == 1 )
        int iDummy22;
    #endif
} StaticTask_t;
Additional: Is it possible to save the core dump in the file system as well?

markevens
Posts: 38
Joined: Sat Aug 01, 2020 6:31 am

Re: Size of tasks control blocks (TCB)

Postby markevens » Mon May 15, 2023 6:20 am

Hey did find any solution?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: Size of tasks control blocks (TCB)

Postby ESP_Dazz » Mon May 15, 2023 7:02 am

The size of the TCB depends on configuration, so use `sizeof(StaticTask_t)` to get the TCB size at compile/run time

Who is online

Users browsing this forum: No registered users and 234 guests