diff --git a/components/esp_gdbstub/src/port/riscv/gdbstub_riscv.c b/components/esp_gdbstub/src/port/riscv/gdbstub_riscv.c index 7a405d6edb..9e2d1b7846 100644 --- a/components/esp_gdbstub/src/port/riscv/gdbstub_riscv.c +++ b/components/esp_gdbstub/src/port/riscv/gdbstub_riscv.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -85,8 +85,15 @@ void esp_gdbstub_int(__attribute__((unused)) void *frame) /* Pointer to saved frame is in pxCurrentTCB * See rtos_int_enter function */ - extern void *pxCurrentTCB; - dummy_tcb_t *tcb = pxCurrentTCB; + /* Todo: Provide IDF interface for getting pxCurrentTCB (IDF-8182) */ + int core_id = esp_cpu_get_core_id(); +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + extern void **pxCurrentTCBs; + dummy_tcb_t *tcb = pxCurrentTCBs[core_id]; +#else + extern void **pxCurrentTCB; + dummy_tcb_t *tcb = pxCurrentTCB[core_id]; +#endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ gdbstub_handle_uart_int((esp_gdbstub_frame_t *)tcb->top_of_stack); } diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index 9ac34ce96a..39a9634432 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -32,7 +32,7 @@ if(CONFIG_FREERTOS_SMP) set(kernel_impl "FreeRTOS-Kernel-SMP") else() if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) - message(FATAL_ERROR "FreeRTOS v10.5.1 is not buildable yet. Still under development") + set(kernel_impl "FreeRTOS-Kernel-V10.5.1") else() set(kernel_impl "FreeRTOS-Kernel") endif() @@ -71,30 +71,54 @@ list(APPEND srcs "${kernel_impl}/queue.c" "${kernel_impl}/tasks.c" "${kernel_impl}/timers.c" - "${kernel_impl}/croutine.c" "${kernel_impl}/event_groups.c" "${kernel_impl}/stream_buffer.c") +if(NOT CONFIG_FREERTOS_USE_KERNEL_10_5_1) + list(APPEND srcs "${kernel_impl}/croutine.c") +endif() # Add port source files -list(APPEND srcs - "${kernel_impl}/portable/${arch}/port.c") - -if(arch STREQUAL "linux") +if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) list(APPEND srcs - "${kernel_impl}/portable/${arch}/utils/wait_for_event.c") - if(kernel_impl STREQUAL "FreeRTOS-Kernel") - list(APPEND srcs - "${kernel_impl}/portable/${arch}/port_idf.c") - endif() + "FreeRTOS-Kernel/portable/${arch}/port.c") else() list(APPEND srcs - "${kernel_impl}/portable/${arch}/portasm.S") + "${kernel_impl}/portable/${arch}/port.c") +endif() + +if(arch STREQUAL "linux") + if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) + list(APPEND srcs + "FreeRTOS-Kernel/portable/${arch}/utils/wait_for_event.c" + "FreeRTOS-Kernel/portable/${arch}/port_idf.c") + else() + list(APPEND srcs + "${kernel_impl}/portable/${arch}/utils/wait_for_event.c") + if(kernel_impl STREQUAL "FreeRTOS-Kernel") + list(APPEND srcs + "${kernel_impl}/portable/${arch}/port_idf.c") + endif() + endif() +else() + if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) + list(APPEND srcs + "FreeRTOS-Kernel/portable/${arch}/portasm.S") + else() + list(APPEND srcs + "${kernel_impl}/portable/${arch}/portasm.S") + endif() endif() if(arch STREQUAL "xtensa") - list(APPEND srcs - "${kernel_impl}/portable/${arch}/xtensa_init.c" - "${kernel_impl}/portable/${arch}/xtensa_overlay_os_hook.c") + if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) + list(APPEND srcs + "FreeRTOS-Kernel/portable/${arch}/xtensa_init.c" + "FreeRTOS-Kernel/portable/${arch}/xtensa_overlay_os_hook.c") + else() + list(APPEND srcs + "${kernel_impl}/portable/${arch}/xtensa_init.c" + "${kernel_impl}/portable/${arch}/xtensa_overlay_os_hook.c") + endif() endif() # Add ESP-additions source files @@ -127,9 +151,15 @@ list(APPEND include_dirs "${kernel_impl}/include") # FreeRTOS headers via `#include "freertos/xxx.h"` # Add port public include directories -list(APPEND include_dirs - "${kernel_impl}/portable/${arch}/include" # For port headers via `#include "freertos/...h"` - "${kernel_impl}/portable/${arch}/include/freertos") # For port headers via `#include "...h"` +if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) + list(APPEND include_dirs + "FreeRTOS-Kernel/portable/${arch}/include" # For port headers via `#include "freertos/...h"` + "FreeRTOS-Kernel/portable/${arch}/include/freertos") # For port headers via `#include "...h"` +else() + list(APPEND include_dirs + "${kernel_impl}/portable/${arch}/include" # For port headers via `#include "freertos/...h"` + "${kernel_impl}/portable/${arch}/include/freertos") # For port headers via `#include "...h"` +endif() # Add ESP-additions public include directories list(APPEND include_dirs @@ -151,8 +181,13 @@ list(APPEND private_include_dirs # Add port private include directories if(arch STREQUAL "linux") - list(APPEND private_include_dirs - "${kernel_impl}/portable/${arch}/") # Linux port `#include "utils/wait_for_event.h"` + if(CONFIG_FREERTOS_USE_KERNEL_10_5_1) + list(APPEND private_include_dirs + "FreeRTOS-Kernel/portable/${arch}/") # Linux port `#include "utils/wait_for_event.h"` + else() + list(APPEND private_include_dirs + "${kernel_impl}/portable/${arch}/") # Linux port `#include "utils/wait_for_event.h"` + endif() endif() # Add ESP-additions private include directories diff --git a/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/FreeRTOS.h b/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/FreeRTOS.h index ea168b1e9f..dd8a67905a 100644 --- a/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/FreeRTOS.h +++ b/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/FreeRTOS.h @@ -1474,6 +1474,46 @@ typedef StaticStreamBuffer_t StaticMessageBuffer_t; #ifdef ESP_PLATFORM +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + +/* + * Default values for trace macros added by ESP-IDF and are not part of Vanilla FreeRTOS + */ + + #ifndef traceISR_EXIT_TO_SCHEDULER + #define traceISR_EXIT_TO_SCHEDULER() + #endif + + #ifndef traceISR_EXIT + #define traceISR_EXIT() + #endif + + #ifndef traceISR_ENTER + #define traceISR_ENTER( _n_ ) + #endif + + #ifndef traceQUEUE_SEMAPHORE_RECEIVE + #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) + #endif + + #ifndef traceQUEUE_GIVE_FROM_ISR + #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) + #endif + + #ifndef traceQUEUE_GIVE_FROM_ISR_FAILED + #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) + #endif + +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + /* * Include ESP-IDF API additions implicitly for compatibility reasons. * diff --git a/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/projdefs.h b/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/projdefs.h index c234d4f2a4..eac820910b 100644 --- a/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/projdefs.h +++ b/components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/projdefs.h @@ -46,6 +46,15 @@ typedef void (* TaskFunction_t)( void * ); #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) ) #endif +/* Converts a time in ticks to milliseconds. This macro can be + * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the + * definition here is not suitable for your application. + * + * Todo: Upstream this macro (IDF-8181) */ +#ifndef pdTICKS_TO_MS + #define pdTICKS_TO_MS( xTicks ) ( ( TickType_t ) ( ( uint64_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) ) +#endif + #define pdFALSE ( ( BaseType_t ) 0 ) #define pdTRUE ( ( BaseType_t ) 1 ) diff --git a/components/freertos/FreeRTOS-Kernel-V10.5.1/queue.c b/components/freertos/FreeRTOS-Kernel-V10.5.1/queue.c index faa22ca5a5..32e787a26d 100644 --- a/components/freertos/FreeRTOS-Kernel-V10.5.1/queue.c +++ b/components/freertos/FreeRTOS-Kernel-V10.5.1/queue.c @@ -1448,7 +1448,8 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, const int8_t cTxLock = queueUNLOCKED; #endif /* queueUSE_LOCKS == 1 */ - traceQUEUE_SEND_FROM_ISR( pxQueue ); + /* Todo: Reconcile tracing differences (IDF-8183) */ + traceQUEUE_GIVE_FROM_ISR( pxQueue ); /* A task can only have an inherited priority if it is a mutex * holder - and if there is a mutex holder then the mutex cannot be @@ -1557,7 +1558,8 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, } else { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); + /* Todo: Reconcile tracing differences (IDF-8183) */ + traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ); xReturn = errQUEUE_FULL; } } @@ -1782,7 +1784,8 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, * must be the highest priority task wanting to access the queue. */ if( uxSemaphoreCount > ( UBaseType_t ) 0 ) { - traceQUEUE_RECEIVE( pxQueue ); + /* Todo: Reconcile tracing differences (IDF-8183) */ + traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ); /* Semaphores are queues with a data size of zero and where the * messages waiting is the semaphore's count. Reduce the count. */ diff --git a/components/freertos/FreeRTOS-Kernel-V10.5.1/tasks.c b/components/freertos/FreeRTOS-Kernel-V10.5.1/tasks.c index 5c25e0c129..2644f5c1e4 100644 --- a/components/freertos/FreeRTOS-Kernel-V10.5.1/tasks.c +++ b/components/freertos/FreeRTOS-Kernel-V10.5.1/tasks.c @@ -4197,6 +4197,10 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) } #endif /* configUSE_IDLE_HOOK */ + /* Call the esp-idf idle hook system. Todo IDF-8180 */ + extern void esp_vApplicationIdleHook( void ); + esp_vApplicationIdleHook(); + /* This conditional compilation should use inequality to 0, not equality * to 1. This is to ensure portSUPPRESS_TICKS_AND_SLEEP() is called when * user defined low power mode implementations require diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h index 08e489d3c0..b026bf49b9 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h @@ -444,6 +444,11 @@ void vPortTCBPreDeleteHook( void *pxTCB ); * - Maps to forward declared functions * ------------------------------------------------------------------------------------------------------------------ */ +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 +#define portGET_CORE_ID() xPortGetCoreID() +#define portYIELD_CORE( x ) vPortYieldOtherCore( x ) +#endif + // --------------------- Interrupts ------------------------ #define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK_FROM_ISR() diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S b/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S index 214303e4f8..2b215156c7 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S @@ -8,6 +8,13 @@ #include "freertos/FreeRTOSConfig.h" #include "soc/soc_caps.h" +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 +#define pxCurrentTCB pxCurrentTCBs +.extern pxCurrentTCBs +#else +.extern pxCurrentTCB +#endif + #if CONFIG_ESP_SYSTEM_HW_STACK_GUARD #include "esp_private/hw_stack_guard.h" #endif diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h index 6a44c2817a..2c107da027 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h @@ -427,6 +427,11 @@ void vPortTCBPreDeleteHook( void *pxTCB ); * - Maps to forward declared functions * ------------------------------------------------------------------------------------------------------------------ */ +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 +#define portGET_CORE_ID() xPortGetCoreID() +#define portYIELD_CORE( x ) vPortYieldOtherCore( x ) +#endif + // --------------------- Interrupts ------------------------ /** diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S b/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S index b7fe0f36a7..931aa3dc31 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT * - * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2016-2023 Espressif Systems (Shanghai) CO LTD */ /* * Copyright (c) 2015-2019 Cadence Design Systems, Inc. @@ -33,7 +33,13 @@ #define TOPOFSTACK_OFFS 0x00 /* StackType_t *pxTopOfStack */ +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 +#define pxCurrentTCB pxCurrentTCBs +.extern pxCurrentTCBs +#else .extern pxCurrentTCB +#endif + #if XCHAL_CP_NUM > 0 /* Offsets used to get a task's coprocessor save area (CPSA) from its TCB */ .extern offset_pxEndOfStack diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 678ba052fc..ebe716b483 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -4,11 +4,12 @@ menu "FreeRTOS" # Upstream FreeRTOS configurations go here config FREERTOS_USE_KERNEL_10_5_1 - bool "Use v10.5.1 Kernel (EXPERIMENTAL)" - depends on IDF_EXPERIMENTAL_FEATURES + bool "Use v10.5.1 Kernel (BETA)" default n help - Hidden option for development/testing purposes to enable building with the v10.5.1 kernel + This option enables building for FreeRTOS v10.5.1 kernel. + + Note: The v10.5.1 kernel is still in BETA, thus is not production ready. config FREERTOS_SMP bool "Run the Amazon SMP FreeRTOS kernel instead (FEATURE UNDER DEVELOPMENT)" diff --git a/components/freertos/config/include/freertos/FreeRTOSConfig.h b/components/freertos/config/include/freertos/FreeRTOSConfig.h index bc92aad523..83f337af7d 100644 --- a/components/freertos/config/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/config/include/freertos/FreeRTOSConfig.h @@ -199,6 +199,7 @@ #define INCLUDE_xTaskResumeFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 /* -------------------- Trace Macros ----------------------- */ diff --git a/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h b/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h index 4530bc0fd3..bd0276b06b 100644 --- a/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h +++ b/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h @@ -52,7 +52,7 @@ /* -------------------- API Includes ----------------------- */ -#define INCLUDE_xTaskGetCurrentTaskHandle 0 /* not defined in POSIX simulator */ +/* Todo: Reconcile INCLUDE_option differences (IDF-8186) */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_uxTaskGetStackHighWaterMark2 0 diff --git a/components/freertos/config/riscv/include/freertos/FreeRTOSConfig_arch.h b/components/freertos/config/riscv/include/freertos/FreeRTOSConfig_arch.h index 75e4e75948..e0288dd5c8 100644 --- a/components/freertos/config/riscv/include/freertos/FreeRTOSConfig_arch.h +++ b/components/freertos/config/riscv/include/freertos/FreeRTOSConfig_arch.h @@ -28,20 +28,31 @@ /* ---------------- Amazon SMP FreeRTOS -------------------- */ #if CONFIG_FREERTOS_SMP - #define configUSE_CORE_AFFINITY 1 + #define configUSE_CORE_AFFINITY 1 /* This is always enabled to call IDF style idle hooks, by can be "--Wl,--wrap" * if users enable CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK. */ - #define configUSE_MINIMAL_IDLE_HOOK 1 + #define configUSE_MINIMAL_IDLE_HOOK 1 - /* IDF Newlib supports dynamic reentrancy. We provide our own __getreent() - * function. */ - #define configNEWLIB_REENTRANT_IS_DYNAMIC 1 +/* IDF Newlib supports dynamic reentrancy. We provide our own __getreent() + * function. */ + #define configNEWLIB_REENTRANT_IS_DYNAMIC 1 #endif /* ----------------------- System -------------------------- */ -#define configUSE_NEWLIB_REENTRANT 1 +#define configUSE_NEWLIB_REENTRANT 1 +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + +/* - FreeRTOS provides default for configTLS_BLOCK_TYPE. + * - We simply provide our own INIT and DEINIT functions + * - We set "SET" to a blank macro since there is no need to set the reentrancy + * pointer. All newlib functions calls __getreent. */ + #define configINIT_TLS_BLOCK( xTLSBlock ) esp_reent_init( &( xTLSBlock ) ) + #define configSET_TLS_BLOCK( xTLSBlock ) + #define configDEINIT_TLS_BLOCK( xTLSBlock ) _reclaim_reent( &( xTLSBlock ) ) + +#endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 @@ -61,9 +72,9 @@ /* -------------------- API Includes ----------------------- */ -#define INCLUDE_xTaskDelayUntil 1 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_uxTaskGetStackHighWaterMark2 1 +/* Todo: Reconcile INCLUDE_option differences (IDF-8186) */ +#define INCLUDE_xTaskDelayUntil 1 +#define INCLUDE_uxTaskGetStackHighWaterMark2 1 /* ------------------------------------------------ ESP-IDF Additions -------------------------------------------------- * diff --git a/components/freertos/config/xtensa/include/freertos/FreeRTOSConfig_arch.h b/components/freertos/config/xtensa/include/freertos/FreeRTOSConfig_arch.h index c93bb977e5..2349c6d49b 100644 --- a/components/freertos/config/xtensa/include/freertos/FreeRTOSConfig_arch.h +++ b/components/freertos/config/xtensa/include/freertos/FreeRTOSConfig_arch.h @@ -55,20 +55,31 @@ /* ---------------- Amazon SMP FreeRTOS -------------------- */ #if CONFIG_FREERTOS_SMP - #define configUSE_CORE_AFFINITY 1 + #define configUSE_CORE_AFFINITY 1 /* This is always enabled to call IDF style idle hooks, by can be "--Wl,--wrap" * if users enable CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK. */ - #define configUSE_MINIMAL_IDLE_HOOK 1 + #define configUSE_MINIMAL_IDLE_HOOK 1 - /* IDF Newlib supports dynamic reentrancy. We provide our own __getreent() - * function. */ - #define configNEWLIB_REENTRANT_IS_DYNAMIC 1 +/* IDF Newlib supports dynamic reentrancy. We provide our own __getreent() + * function. */ + #define configNEWLIB_REENTRANT_IS_DYNAMIC 1 #endif /* ----------------------- System -------------------------- */ -#define configUSE_NEWLIB_REENTRANT 1 +#define configUSE_NEWLIB_REENTRANT 1 +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + +/* - FreeRTOS provides default for configTLS_BLOCK_TYPE. + * - We simply provide our own INIT and DEINIT functions + * - We set "SET" to a blank macro since there is no need to set the reentrancy + * pointer. All newlib functions calls __getreent. */ + #define configINIT_TLS_BLOCK( xTLSBlock ) esp_reent_init( &( xTLSBlock ) ) + #define configSET_TLS_BLOCK( xTLSBlock ) + #define configDEINIT_TLS_BLOCK( xTLSBlock ) _reclaim_reent( &( xTLSBlock ) ) + +#endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 @@ -88,9 +99,9 @@ /* -------------------- API Includes ----------------------- */ -#define INCLUDE_xTaskDelayUntil 1 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_uxTaskGetStackHighWaterMark2 1 +/* Todo: Reconcile INCLUDE_option differences (IDF-8186) */ +#define INCLUDE_xTaskDelayUntil 1 +#define INCLUDE_uxTaskGetStackHighWaterMark2 1 /* ------------------------------------------------ ESP-IDF Additions -------------------------------------------------- * diff --git a/components/freertos/esp_additions/freertos_tasks_c_additions.h b/components/freertos/esp_additions/freertos_tasks_c_additions.h index c7e08d0af1..e0266a53ef 100644 --- a/components/freertos/esp_additions/freertos_tasks_c_additions.h +++ b/components/freertos/esp_additions/freertos_tasks_c_additions.h @@ -20,6 +20,11 @@ * additional API. */ +#if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + #define pxCurrentTCB pxCurrentTCBs +#else +#endif + /* ------------------------------------------------- Static Asserts ------------------------------------------------- */ /* @@ -222,10 +227,23 @@ _Static_assert( offsetof( StaticTask_t, pxDummy8 ) == offsetof( TCB_t, pxEndOfSt if( pxNewTCB != NULL ) { - /* Allocate space for the stack used by the task being created. - * The base of the stack memory stored in the TCB so the task can - * be deleted later if required. */ - pxNewTCB->pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + #if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + { + memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) ); + + /* Allocate space for the stack used by the task being created. + * The base of the stack memory stored in the TCB so the task can + * be deleted later if required. */ + pxNewTCB->pxStack = ( StackType_t * ) pvPortMallocStack( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } + #else /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + { + /* Allocate space for the stack used by the task being created. + * The base of the stack memory stored in the TCB so the task can + * be deleted later if required. */ + pxNewTCB->pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + } + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ if( pxNewTCB->pxStack == NULL ) { @@ -239,8 +257,17 @@ _Static_assert( offsetof( StaticTask_t, pxDummy8 ) == offsetof( TCB_t, pxEndOfSt { StackType_t * pxStack; - /* Allocate space for the stack used by the task being created. */ - pxStack = pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */ + #if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + { + /* Allocate space for the stack used by the task being created. */ + pxStack = pvPortMallocStack( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */ + } + #else /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + { + /* Allocate space for the stack used by the task being created. */ + pxStack = pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */ + } + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ if( pxStack != NULL ) { @@ -249,6 +276,12 @@ _Static_assert( offsetof( StaticTask_t, pxDummy8 ) == offsetof( TCB_t, pxEndOfSt if( pxNewTCB != NULL ) { + #if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + { + memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) ); + } + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + /* Store the stack location in the TCB. */ pxNewTCB->pxStack = pxStack; } @@ -256,7 +289,15 @@ _Static_assert( offsetof( StaticTask_t, pxDummy8 ) == offsetof( TCB_t, pxEndOfSt { /* The stack cannot be used as the TCB was not created. Free * it again. */ - vPortFree( pxStack ); + #if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + { + vPortFreeStack( pxStack ); + } + #else /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + { + vPortFree( pxStack ); + } + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ } } else @@ -356,6 +397,13 @@ _Static_assert( offsetof( StaticTask_t, pxDummy8 ) == offsetof( TCB_t, pxEndOfSt /* The memory used for the task's TCB and stack are passed into this * function - use them. */ pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + + #if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + { + memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) ); + } + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer; #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ @@ -892,7 +940,15 @@ uint8_t * pxTaskGetStackStart( TaskHandle_t xTask ) else { /* We have a task; return its reentrant struct. */ - ret = &pxCurTask->xNewLib_reent; + #if CONFIG_FREERTOS_USE_KERNEL_10_5_1 + { + ret = &pxCurTask->xTLSBlock; + } + #else /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + { + ret = &pxCurTask->xNewLib_reent; + } + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ } return ret; diff --git a/components/freertos/esp_additions/include/freertos/idf_additions.h b/components/freertos/esp_additions/include/freertos/idf_additions.h index 3b39afe808..0da84064d6 100644 --- a/components/freertos/esp_additions/include/freertos/idf_additions.h +++ b/components/freertos/esp_additions/include/freertos/idf_additions.h @@ -208,6 +208,17 @@ TaskHandle_t xTaskGetCurrentTaskHandleForCPU( BaseType_t xCoreID ) */ configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercentForCore( BaseType_t xCoreID ); +#else /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ + +/* CMock Workaround: CMock currently doesn't preprocess files, thus functions + * guarded by ifdef still get mocked. We provide a dummy define here so that + * functions using configRUN_TIME_COUNTER_TYPE can still be mocked. + * + * Todo: Will be removed when V10.5.1 becomes the default kernel. */ + #ifndef configRUN_TIME_COUNTER_TYPE + #define configRUN_TIME_COUNTER_TYPE unsigned int + #endif + #endif /* CONFIG_FREERTOS_USE_KERNEL_10_5_1 */ /** diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index 39ddc16643..2167932fe2 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -12,6 +12,7 @@ components/freertos/FreeRTOS-Kernel/include/freertos/ components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/ components/freertos/FreeRTOS-Kernel-SMP/include/freertos/ components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/ +components/freertos/FreeRTOS-Kernel-V10.5.1/include/freertos/ components/log/include/esp_log_internal.h