fix(freertos): fix riscv pxEndOfStack offset alignment

Closes https://github.com/espressif/esp-idf/issues/18256
This commit is contained in:
Konstantin Kondrashov
2026-02-20 12:16:08 +02:00
parent 29ab31c587
commit fa9b7843bc
3 changed files with 25 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -27,10 +27,27 @@ uxPriority (4)
#define PORT_OFFSET_PX_STACK 0x30
#endif /* #if CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES */
#if ( configNUMBER_OF_CORES > 1 )
#define PORT_TCB_CORE_FIELDS_SIZE 8
#else
#define PORT_TCB_CORE_FIELDS_SIZE 0
#endif
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
#define PORT_TCB_PREEMPT_DISABLE_FIELD_SIZE 4
#else
#define PORT_TCB_PREEMPT_DISABLE_FIELD_SIZE 0
#endif
/* Align the value up to the nearest multiple of 4 */
#define PORT_ALIGN_UP_TO_4(value) (((value) + 3) & ~3)
#define PORT_OFFSET_PX_END_OF_STACK ( \
PORT_OFFSET_PX_STACK \
+ 4 /* StackType_t * pxStack */ \
+ CONFIG_FREERTOS_MAX_TASK_NAME_LEN /* pcTaskName[ configMAX_TASK_NAME_LEN ] */ \
+ PORT_TCB_CORE_FIELDS_SIZE /* BaseType_t xDummy23 + UBaseType_t uxDummy24 */ \
+ PORT_ALIGN_UP_TO_4(configMAX_TASK_NAME_LEN) /* pcTaskName[ configMAX_TASK_NAME_LEN ] */ \
+ PORT_TCB_PREEMPT_DISABLE_FIELD_SIZE /* BaseType_t xDummy25 */ \
)
#ifndef __ASSEMBLER__
@@ -6,7 +6,7 @@
*
* SPDX-License-Identifier: MIT
*
* SPDX-FileContributor: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -49,10 +49,13 @@
#define CORE_ID_SIZE 4
#endif
/* Align the value up to the nearest multiple of 4 */
#define PORT_ALIGN_UP_TO_4(value) (((value) + 3) & ~3)
#define PORT_OFFSET_PX_END_OF_STACK ( \
PORT_OFFSET_PX_STACK \
+ 4 /* void * pxDummy6 */ \
+ CONFIG_FREERTOS_MAX_TASK_NAME_LEN /* uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ] */ \
+ PORT_ALIGN_UP_TO_4(configMAX_TASK_NAME_LEN) /* uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ] */ \
+ CORE_ID_SIZE /* BaseType_t xDummyCoreID */ \
)
@@ -6,3 +6,4 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=7
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3000
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=17