mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 00:36:01 -04:00
Merge branch 'bugfix/fix_stack_overflow_on_s3_with_freertos_smp' into 'master'
freertos-smp: Fixed stack overflow on esp32s3 with FreeRTOS SMP Closes IDF-5509 and IDF-4982 See merge request espressif/esp-idf!20932
This commit is contained in:
commit
98ff59b394
@ -98,7 +98,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
|
|||||||
#define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
|
#define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
|
||||||
#define configTICK_RATE_HZ CONFIG_FREERTOS_HZ
|
#define configTICK_RATE_HZ CONFIG_FREERTOS_HZ
|
||||||
#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
|
#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
|
||||||
#define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL )
|
#define configMINIMAL_STACK_SIZE ( CONFIG_FREERTOS_IDLE_TASK_STACKSIZE + configSTACK_OVERHEAD_TOTAL )
|
||||||
#define configUSE_TIME_SLICING 1
|
#define configUSE_TIME_SLICING 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
#define configIDLE_SHOULD_YIELD 0 //Todo: Check this
|
#define configIDLE_SHOULD_YIELD 0 //Todo: Check this
|
||||||
@ -271,20 +271,6 @@ Default values for trace macros added by ESP-IDF and are not part of Vanilla Fre
|
|||||||
#define configTASKLIST_INCLUDE_COREID 1
|
#define configTASKLIST_INCLUDE_COREID 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ---------------------- Features -------------------------
|
|
||||||
|
|
||||||
/* These currently aren't required, but could be useful additions in the future */
|
|
||||||
#if 0
|
|
||||||
#ifndef configIDLE_TASK_STACK_SIZE
|
|
||||||
#define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE
|
|
||||||
#endif
|
|
||||||
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
|
|
||||||
#define configCHECK_MUTEX_GIVEN_BY_OWNER 1
|
|
||||||
#else
|
|
||||||
#define configCHECK_MUTEX_GIVEN_BY_OWNER 0
|
|
||||||
#endif
|
|
||||||
#endif //0
|
|
||||||
|
|
||||||
// -------------------- Compatibility ----------------------
|
// -------------------- Compatibility ----------------------
|
||||||
|
|
||||||
// backward compatibility for 4.4
|
// backward compatibility for 4.4
|
||||||
|
@ -473,41 +473,61 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
|||||||
{
|
{
|
||||||
StackType_t *pxStackBufferTemp;
|
StackType_t *pxStackBufferTemp;
|
||||||
StaticTask_t *pxTCBBufferTemp;
|
StaticTask_t *pxTCBBufferTemp;
|
||||||
/* Stack always grows downwards (from high address to low address) on all
|
|
||||||
* ESP RISC-V targets. Given that the heap allocator likely allocates memory
|
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||||
* from low to high address, we allocate the stack first and then the TCB so
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||||
* that the stack does not grow downwards into the TCB.
|
* the TCB then the stack. */
|
||||||
*
|
#if (portSTACK_GROWTH > 0)
|
||||||
* Allocate TCB and stack buffer in internal memory. */
|
{
|
||||||
pxStackBufferTemp = pvPortMalloc(CONFIG_FREERTOS_IDLE_TASK_STACKSIZE);
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
|
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
|
||||||
|
}
|
||||||
|
#else /* portSTACK_GROWTH */
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
|
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
|
||||||
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
|
}
|
||||||
|
#endif /* portSTACK_GROWTH */
|
||||||
|
|
||||||
assert(pxStackBufferTemp != NULL);
|
assert(pxStackBufferTemp != NULL);
|
||||||
assert(pxTCBBufferTemp != NULL);
|
assert(pxTCBBufferTemp != NULL);
|
||||||
// Write back pointers
|
// Write back pointers
|
||||||
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
||||||
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
||||||
*pulIdleTaskStackSize = CONFIG_FREERTOS_IDLE_TASK_STACKSIZE;
|
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
||||||
StackType_t **ppxTimerTaskStackBuffer,
|
StackType_t **ppxTimerTaskStackBuffer,
|
||||||
uint32_t *pulTimerTaskStackSize )
|
uint32_t *pulTimerTaskStackSize )
|
||||||
{
|
{
|
||||||
StackType_t *pxStackBufferTemp;
|
|
||||||
StaticTask_t *pxTCBBufferTemp;
|
StaticTask_t *pxTCBBufferTemp;
|
||||||
/* Stack always grows downwards (from high address to low address) on all
|
StackType_t *pxStackBufferTemp;
|
||||||
* ESP RISC-V targets. Given that the heap allocator likely allocates memory
|
|
||||||
* from low to high address, we allocate the stack first and then the TCB so
|
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||||
* that the stack does not grow downwards into the TCB.
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||||
*
|
* the TCB then the stack. */
|
||||||
* Allocate TCB and stack buffer in internal memory. */
|
#if (portSTACK_GROWTH > 0)
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
|
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
||||||
|
}
|
||||||
|
#else /* portSTACK_GROWTH */
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
||||||
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
assert(pxStackBufferTemp != NULL);
|
}
|
||||||
|
#endif /* portSTACK_GROWTH */
|
||||||
|
|
||||||
assert(pxTCBBufferTemp != NULL);
|
assert(pxTCBBufferTemp != NULL);
|
||||||
|
assert(pxStackBufferTemp != NULL);
|
||||||
//Write back pointers
|
//Write back pointers
|
||||||
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
|
|
||||||
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
|
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
|
||||||
|
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
|
||||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||||
}
|
}
|
||||||
#endif //( configSUPPORT_STATIC_ALLOCATION == 1 )
|
#endif //( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
|
@ -131,7 +131,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
|
|||||||
#define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
|
#define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
|
||||||
#define configTICK_RATE_HZ CONFIG_FREERTOS_HZ
|
#define configTICK_RATE_HZ CONFIG_FREERTOS_HZ
|
||||||
#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
|
#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
|
||||||
#define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL )
|
#define configMINIMAL_STACK_SIZE ( CONFIG_FREERTOS_IDLE_TASK_STACKSIZE + configSTACK_OVERHEAD_TOTAL )
|
||||||
#define configUSE_TIME_SLICING 1
|
#define configUSE_TIME_SLICING 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
#define configIDLE_SHOULD_YIELD 0 //Todo: Check this
|
#define configIDLE_SHOULD_YIELD 0 //Todo: Check this
|
||||||
@ -312,20 +312,6 @@ extern volatile uint32_t port_switch_flag[portNUM_PROCESSORS];
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ---------------------- Features -------------------------
|
|
||||||
|
|
||||||
/* These currently aren't required, but could be useful additions in the future */
|
|
||||||
#if 0
|
|
||||||
#ifndef configIDLE_TASK_STACK_SIZE
|
|
||||||
#define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE
|
|
||||||
#endif
|
|
||||||
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
|
|
||||||
#define configCHECK_MUTEX_GIVEN_BY_OWNER 1
|
|
||||||
#else
|
|
||||||
#define configCHECK_MUTEX_GIVEN_BY_OWNER 0
|
|
||||||
#endif
|
|
||||||
#endif //0
|
|
||||||
|
|
||||||
// -------------------- Compatibility ----------------------
|
// -------------------- Compatibility ----------------------
|
||||||
|
|
||||||
// backward compatibility for 4.4
|
// backward compatibility for 4.4
|
||||||
|
@ -537,20 +537,30 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
|||||||
{
|
{
|
||||||
StackType_t *pxStackBufferTemp;
|
StackType_t *pxStackBufferTemp;
|
||||||
StaticTask_t *pxTCBBufferTemp;
|
StaticTask_t *pxTCBBufferTemp;
|
||||||
/* Stack always grows downwards (from high address to low address) on all
|
|
||||||
* ESP Xtensa targets. Given that the heap allocator likely allocates memory
|
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||||
* from low to high address, we allocate the stack first and then the TCB so
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||||
* that the stack does not grow downwards into the TCB.
|
* the TCB then the stack. */
|
||||||
*
|
#if (portSTACK_GROWTH > 0)
|
||||||
* Allocate TCB and stack buffer in internal memory. */
|
{
|
||||||
pxStackBufferTemp = pvPortMalloc(CONFIG_FREERTOS_IDLE_TASK_STACKSIZE);
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
|
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
|
||||||
|
}
|
||||||
|
#else /* portSTACK_GROWTH */
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
|
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
|
||||||
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
|
}
|
||||||
|
#endif /* portSTACK_GROWTH */
|
||||||
|
|
||||||
assert(pxStackBufferTemp != NULL);
|
assert(pxStackBufferTemp != NULL);
|
||||||
assert(pxTCBBufferTemp != NULL);
|
assert(pxTCBBufferTemp != NULL);
|
||||||
// Write back pointers
|
// Write back pointers
|
||||||
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
||||||
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
||||||
*pulIdleTaskStackSize = CONFIG_FREERTOS_IDLE_TASK_STACKSIZE;
|
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
||||||
@ -559,19 +569,29 @@ void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
|||||||
{
|
{
|
||||||
StaticTask_t *pxTCBBufferTemp;
|
StaticTask_t *pxTCBBufferTemp;
|
||||||
StackType_t *pxStackBufferTemp;
|
StackType_t *pxStackBufferTemp;
|
||||||
/* Stack always grows downwards (from high address to low address) on all
|
|
||||||
* ESP Xtensa targets. Given that the heap allocator likely allocates memory
|
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||||
* from low to high address, we allocate the stack first and then the TCB so
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||||
* that the stack does not grow downwards into the TCB.
|
* the TCB then the stack. */
|
||||||
*
|
#if (portSTACK_GROWTH > 0)
|
||||||
* Allocate TCB and stack buffer in internal memory. */
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
|
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
||||||
|
}
|
||||||
|
#else /* portSTACK_GROWTH */
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
||||||
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
||||||
assert(pxStackBufferTemp != NULL);
|
}
|
||||||
|
#endif /* portSTACK_GROWTH */
|
||||||
|
|
||||||
assert(pxTCBBufferTemp != NULL);
|
assert(pxTCBBufferTemp != NULL);
|
||||||
|
assert(pxStackBufferTemp != NULL);
|
||||||
//Write back pointers
|
//Write back pointers
|
||||||
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
|
|
||||||
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
|
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
|
||||||
|
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
|
||||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||||
}
|
}
|
||||||
#endif //( configSUPPORT_STATIC_ALLOCATION == 1 )
|
#endif //( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
|
@ -171,12 +171,12 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
|||||||
{
|
{
|
||||||
//Allocate TCB and stack buffer in internal memory
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||||
pxStackBufferTemp = pvPortMallocStackMem(configIDLE_TASK_STACK_SIZE);
|
pxStackBufferTemp = pvPortMallocStackMem(configMINIMAL_STACK_SIZE);
|
||||||
}
|
}
|
||||||
#else /* portSTACK_GROWTH */
|
#else /* portSTACK_GROWTH */
|
||||||
{
|
{
|
||||||
//Allocate TCB and stack buffer in internal memory
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxStackBufferTemp = pvPortMallocStackMem(configIDLE_TASK_STACK_SIZE);
|
pxStackBufferTemp = pvPortMallocStackMem(configMINIMAL_STACK_SIZE);
|
||||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||||
}
|
}
|
||||||
#endif /* portSTACK_GROWTH */
|
#endif /* portSTACK_GROWTH */
|
||||||
@ -186,7 +186,7 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
|||||||
//Write back pointers
|
//Write back pointers
|
||||||
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
||||||
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
||||||
*pulIdleTaskStackSize = configIDLE_TASK_STACK_SIZE;
|
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2355,7 +2355,7 @@ void vTaskStartScheduler( void )
|
|||||||
/* The Idle task is being created using dynamically allocated RAM. */
|
/* The Idle task is being created using dynamically allocated RAM. */
|
||||||
xReturn = xTaskCreatePinnedToCore( prvIdleTask,
|
xReturn = xTaskCreatePinnedToCore( prvIdleTask,
|
||||||
configIDLE_TASK_NAME,
|
configIDLE_TASK_NAME,
|
||||||
configIDLE_TASK_STACK_SIZE,
|
configMINIMAL_STACK_SIZE,
|
||||||
( void * ) NULL,
|
( void * ) NULL,
|
||||||
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
|
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
|
||||||
&xIdleTaskHandle[ xCoreID ],
|
&xIdleTaskHandle[ xCoreID ],
|
||||||
|
@ -111,7 +111,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
|
|||||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) (0x4000 + 40) / sizeof(portSTACK_TYPE) )
|
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) (0x4000 + 40) / sizeof(portSTACK_TYPE) )
|
||||||
#else
|
#else
|
||||||
#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
|
#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
|
||||||
#define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL )
|
#define configMINIMAL_STACK_SIZE ( CONFIG_FREERTOS_IDLE_TASK_STACKSIZE + configSTACK_OVERHEAD_TOTAL )
|
||||||
#endif
|
#endif
|
||||||
#define configUSE_TIME_SLICING 1
|
#define configUSE_TIME_SLICING 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
@ -267,9 +267,6 @@ Note: Include trace macros here and not above as trace macros are dependent on s
|
|||||||
// ---------------------- Features -------------------------
|
// ---------------------- Features -------------------------
|
||||||
|
|
||||||
#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS
|
#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS
|
||||||
#ifndef configIDLE_TASK_STACK_SIZE
|
|
||||||
#define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
|
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
|
||||||
#define configCHECK_MUTEX_GIVEN_BY_OWNER 1
|
#define configCHECK_MUTEX_GIVEN_BY_OWNER 1
|
||||||
|
Loading…
Reference in New Issue
Block a user