From 66e585d72c38ae00eb765fbc3a0687b34547eef5 Mon Sep 17 00:00:00 2001 From: WCX1024979076 Date: Sun, 16 Jul 2023 11:21:52 +0000 Subject: [PATCH 1/5] =?UTF-8?q?[bsp][esp32-c3]=20Preliminary=20realization?= =?UTF-8?q?=20of=20scons=20compilation=20of=20ESP32-C3=20|=20=E5=88=9D?= =?UTF-8?q?=E6=AD=A5=E5=AE=9E=E7=8E=B0ESP32-C3=E7=9A=84scons=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeRTOS/SConscript | 19 +- .../riscv/include/freertos/FreeRTOSConfig.h | 270 ++++++++++++ .../freertos/freertos_tasks_c_additions.h | 399 ++++++++++++++++++ .../riscv/include/freertos/task_snapshot.h | 80 ++++ SConscript | 3 - 5 files changed, 765 insertions(+), 6 deletions(-) create mode 100644 FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h create mode 100644 FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h create mode 100644 FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h diff --git a/FreeRTOS/SConscript b/FreeRTOS/SConscript index 0586c3c..6fff18e 100644 --- a/FreeRTOS/SConscript +++ b/FreeRTOS/SConscript @@ -3,10 +3,23 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') -src += Glob(os.path.join("portable", "rt-thread", "*.c")) -src += Glob(os.path.join("portable", "MemMang", "heap_3.c")) -CPPPATH = [os.path.join(cwd, "include", "freertos"), os.path.join(cwd, "portable", "rt-thread")] +if (GetDepend(['PKG_USING_ESP_IDF']) or GetDepend(['BSP_USING_LOCAL_ESP_IDF'])): + src += Split(""" + portable/esp-idf/port_rt.c + portable/esp-idf/riscv/port.c + portable/esp-idf/port_common.c + """) + CPPPATH = Split(""" + include + include/freertos + portable/esp-idf/riscv/include + portable/esp-idf/riscv/include/freertos + """) +else : + src += Glob(os.path.join("portable", "rt-thread", "*.c")) + src += Glob(os.path.join("portable", "MemMang", "heap_3.c")) + CPPPATH = [os.path.join(cwd, "include", "freertos"), os.path.join(cwd, "portable", "rt-thread")] group = DefineGroup('FreeRTOS', src, depend = [''], CPPPATH = CPPPATH) diff --git a/FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h b/FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h new file mode 100644 index 0000000..5065a78 --- /dev/null +++ b/FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h @@ -0,0 +1,270 @@ +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +#include "sdkconfig.h" + +/* +This file get's pulled into assembly sources. Therefore, some includes need to be wrapped in #ifndef __ASSEMBLER__ +*/ + +#ifndef __ASSEMBLER__ +#include //For configASSERT() +#endif /* def __ASSEMBLER__ */ + +#ifdef CONFIG_FREERTOS_SMP + +// Pull in the SMP configuration +#include "freertos/FreeRTOSConfig_smp.h" + +#else // CONFIG_FREERTOS_SMP + +// The arch-specific FreeRTOSConfig_arch.h in port//include. +#include "freertos/FreeRTOSConfig_arch.h" + +#if !(defined(FREERTOS_CONFIG_XTENSA_H) \ + || defined(FREERTOS_CONFIG_RISCV_H) \ + || defined(FREERTOS_CONFIG_LINUX_H)) +#error "Needs architecture-speific FreeRTOSConfig.h!" +#endif + +/* ----------------------------------------------------- Helpers ------------------------------------------------------- + * - Macros that the FreeRTOS configuration macros depend on + * ------------------------------------------------------------------------------------------------------------------ */ + +/* Higher stack checker modes cause overhead on each function call */ +#if CONFIG_STACK_CHECK_ALL || CONFIG_STACK_CHECK_STRONG +#define STACK_OVERHEAD_CHECKER 256 +#else +#define STACK_OVERHEAD_CHECKER 0 +#endif + +/* with optimizations disabled, scheduler uses additional stack */ +#if CONFIG_COMPILER_OPTIMIZATION_NONE +#define STACK_OVERHEAD_OPTIMIZATION 320 +#else +#define STACK_OVERHEAD_OPTIMIZATION 0 +#endif + +/* apptrace mdule increases minimum stack usage */ +#if CONFIG_APPTRACE_ENABLE +#define STACK_OVERHEAD_APPTRACE 1280 +#else +#define STACK_OVERHEAD_APPTRACE 0 +#endif + +/* Stack watchpoint decreases minimum usable stack size by up to 60 bytes. + See FreeRTOS FREERTOS_WATCHPOINT_END_OF_STACK option in Kconfig. */ +#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK +#define STACK_OVERHEAD_WATCHPOINT 60 +#else +#define STACK_OVERHEAD_WATCHPOINT 0 +#endif + +#define configSTACK_OVERHEAD_TOTAL ( \ + STACK_OVERHEAD_CHECKER + \ + STACK_OVERHEAD_OPTIMIZATION + \ + STACK_OVERHEAD_APPTRACE + \ + STACK_OVERHEAD_WATCHPOINT \ + ) + +/* ------------------------------------------------- FreeRTOS Config --------------------------------------------------- + * - All Vanilla FreeRTOS configuration goes into this section + * - Keep this section in-sync with the corresponding version of single-core upstream version of FreeRTOS + * - Don't put any SMP or ESP-IDF exclusive FreeRTOS configurations here. Those go into the next section + * - Not all FreeRTOS configuration are listed. Some configurations have default values set in FreeRTOS.h thus don't + * need to be explicitly defined. + * ------------------------------------------------------------------------------------------------------------------ */ + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +// ------------------ Scheduler Related -------------------- + +#define configUSE_PREEMPTION 1 +#define configUSE_TICKLESS_IDLE CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if configUSE_TICKLESS_IDLE +#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP +#endif //configUSE_TICKLESS_IDLE +#define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000) +#define configTICK_RATE_HZ CONFIG_FREERTOS_HZ +#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority +#define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL ) +#define configUSE_TIME_SLICING 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configKERNEL_INTERRUPT_PRIORITY 1 //Todo: This currently isn't used anywhere + +// ------------- Synchronization Primitives ---------------- + +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_QUEUE_SETS 1 +#define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE +#define configUSE_TASK_NOTIFICATIONS 1 +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 + +// ----------------------- System -------------------------- + +#define configMAX_TASK_NAME_LEN CONFIG_FREERTOS_MAX_TASK_NAME_LEN +#define configNUM_THREAD_LOCAL_STORAGE_POINTERS CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS +#ifndef CONFIG_IDF_TARGET_LINUX +#define configSTACK_DEPTH_TYPE uint32_t +#define configUSE_NEWLIB_REENTRANT 1 +#endif +#if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY +#define configENABLE_BACKWARD_COMPATIBILITY 1 +#else +#define configENABLE_BACKWARD_COMPATIBILITY 0 +#endif +#define configASSERT(a) assert(a) +#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 + +// ----------------------- Memory ------------------------- + +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +//We define the heap to span all of the non-statically-allocated shared RAM. ToDo: Make sure there +//is some space left for the app and main cpu when running outside of a thread. +#define configTOTAL_HEAP_SIZE (&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) ) +#define configAPPLICATION_ALLOCATED_HEAP 1 +#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 + +// ------------------------ Hooks -------------------------- + +#define configUSE_IDLE_HOOK CONFIG_FREERTOS_USE_IDLE_HOOK +#define configUSE_TICK_HOOK CONFIG_FREERTOS_USE_TICK_HOOK +#if CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE +#define configCHECK_FOR_STACK_OVERFLOW 0 +#elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL +#define configCHECK_FOR_STACK_OVERFLOW 1 +#elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY +#define configCHECK_FOR_STACK_OVERFLOW 2 +#endif +#define configRECORD_STACK_HIGH_ADDRESS 1 + +// ------------------- Run-time Stats ---------------------- + +#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS +#define configGENERATE_RUN_TIME_STATS 1 /* Used by vTaskGetRunTimeStats() */ +#endif +#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY +#define configUSE_TRACE_FACILITY 1 /* Used by uxTaskGetSystemState(), and other trace facility functions */ +#endif +#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */ +#endif + +// -------------------- Co-routines ----------------------- + +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES 2 + +// ------------------- Software Timer ---------------------- + +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY CONFIG_FREERTOS_TIMER_TASK_PRIORITY +#define configTIMER_QUEUE_LENGTH CONFIG_FREERTOS_TIMER_QUEUE_LENGTH +#define configTIMER_TASK_STACK_DEPTH CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH + +// -------------------- API Includes ----------------------- + +#if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY +#define configENABLE_BACKWARD_COMPATIBILITY 1 +#else +#define configENABLE_BACKWARD_COMPATIBILITY 0 +#endif + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_xTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_uxTaskGetStackHighWaterMark2 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTaskResumeFromISR 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +//Unlisted +#define INCLUDE_pxTaskGetStackStart 1 + +// -------------------- Trace Macros ----------------------- + +/* +For trace macros. +Note: Include trace macros here and not above as trace macros are dependent on some of the FreeRTOS configs +*/ +#ifndef __ASSEMBLER__ +#if CONFIG_SYSVIEW_ENABLE +#include "SEGGER_SYSVIEW_FreeRTOS.h" +#undef INLINE // to avoid redefinition +#endif //CONFIG_SYSVIEW_ENABLE +#endif /* def __ASSEMBLER__ */ + +/* ------------------------------------------------ ESP-IDF Additions -------------------------------------------------- + * - All FreeRTOS related configurations no part of Vanilla FreeRTOS goes into this section + * - FreeRTOS configurations related to SMP and ESP-IDF additions go into this section + * ------------------------------------------------------------------------------------------------------------------ */ + +// ------------------------- SMP --------------------------- + +#ifndef CONFIG_FREERTOS_UNICORE +#define portNUM_PROCESSORS 2 +#else +#define portNUM_PROCESSORS 1 +#endif +#define configNUM_CORES portNUM_PROCESSORS +#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID +#define configTASKLIST_INCLUDE_COREID 1 +#endif + +// ---------------------- Features ------------------------- + +#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1 +#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 + +#ifndef __ASSEMBLER__ +#if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP +extern void vPortCleanUpTCB ( void *pxTCB ); +#define portCLEAN_UP_TCB( pxTCB ) vPortCleanUpTCB( pxTCB ) +#endif +#endif + +// -------------------- Compatibility ---------------------- + +// backward compatibility for 4.4 +#define xTaskRemoveFromUnorderedEventList vTaskRemoveFromUnorderedEventList + +#endif // CONFIG_FREERTOS_SMP + +#endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h b/FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h new file mode 100644 index 0000000..96fc4f7 --- /dev/null +++ b/FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h @@ -0,0 +1,399 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +/** + * This file will be included in `tasks.c` file, thus, it must NOT be included + * by any (other) file. + * The functions below only consist in getters for the static variables in + * `tasks.c` file. + * The only source files that should call these functions are the ones in + * `/additions` directory. + */ + +/* ----------------------------------------------------- Newlib -------------------------------------------------------- + * + * ------------------------------------------------------------------------------------------------------------------ */ + +#if ( configUSE_NEWLIB_REENTRANT == 1 ) +/** + * @brief Get reentrancy structure of the current task + * + * - This funciton is required by newlib (when __DYNAMIC_REENT__ is enabled) + * - It will return a pointer to the current task's reent struct + * - If FreeRTOS is not running, it will return the global reent struct + * + * @return Pointer to a the (current taks's)/(globa) reent struct + */ +struct _reent *__getreent(void) +{ + // No lock needed because if this changes, we won't be running anymore. + struct _reent *ret; +#if !defined CONFIG_IDF_RTOS_RTTHREAD + TCB_t *pxCurTask = xTaskGetCurrentTaskHandle(); + if (pxCurTask == NULL) { + // No task running. Return global struct. + ret = _GLOBAL_REENT; + } else { + // We have a task; return its reentrant struct. + ret = &pxCurTask->xNewLib_reent; + } +#else + ret = _GLOBAL_REENT; +#endif + return ret; +} +#endif // configUSE_NEWLIB_REENTRANT == 1 + +/* -------------------------------------------------- Task Snapshot ---------------------------------------------------- + * + * ------------------------------------------------------------------------------------------------------------------ */ + +#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT + +#include "task_snapshot.h" + +/** + * @brief List of all task lists in FreeRTOS + * + * @note There are currently differing number of task list between SMP FreeRTOS and ESP-IDF FreeRTOS + */ +static List_t *non_ready_task_lists[] = { + #ifdef CONFIG_FREERTOS_SMP + &xPendingReadyList, + #else + &xPendingReadyList[0], + #ifndef CONFIG_FREERTOS_UNICORE + &xPendingReadyList[1], + #endif // CONFIG_FREERTOS_UNICORE + #endif //CONFIG_FREERTOS_SMP + &xDelayedTaskList1, + &xDelayedTaskList2, + #if( INCLUDE_vTaskDelete == 1 ) + &xTasksWaitingTermination, + #endif + #if( INCLUDE_vTaskSuspend == 1 ) + &xSuspendedTaskList, + #endif +}; + +/** + * @brief Get the next task list to traverse + * + * - Given a particular task list, this function returns the next task to traverse. + * - The task lists are returned in the following precedence + * - Ready lists (highest to lowers priority) + * - Pending ready list(s) + * - Delayed list 1 + * - Delayed list 2 + * - Waiting termination list + * - Suspended list + * + * @param pxCurTaskList Previously traversed task list (or NULL if obtaining the first task list) + * @return List_t* The next task list to traverse (or NULL of all task lists have been traversed) + */ +static List_t *pxGetNextTaskList(List_t *pxCurTaskList) +{ + List_t *pxNextTaskList = NULL; + + // No Current List. Start from the highest priority ready task list + if (pxCurTaskList == NULL) + { + pxNextTaskList = &pxReadyTasksLists[configMAX_PRIORITIES - 1]; + } + // Current list is one of the ready task lists. Find the current priority, and return the next lower priority ready task list + else if (pxCurTaskList >= &pxReadyTasksLists[0] && pxCurTaskList <= &pxReadyTasksLists[configMAX_PRIORITIES - 1] ) + { + // Find the current priority + int cur_priority; + for (cur_priority = configMAX_PRIORITIES - 1; cur_priority >= 0; cur_priority--) { + if (pxCurTaskList == &pxReadyTasksLists[cur_priority]) { + break; + } + } + // Return the ready task list at (cur_priority - 1), or the pending ready task list + if (cur_priority > 0) + { + pxNextTaskList = &pxReadyTasksLists[cur_priority - 1]; + } + // We've reached the end of the Ready Task Lists. We get the next list from the non-ready task lists + else if (cur_priority == 0) + { + pxNextTaskList = non_ready_task_lists[0]; + } + else + { + abort(); // This should never occur + } + } + + // Current list is one of the non-ready task lists. Fetch the next non-ready task list + if (pxNextTaskList == NULL) { + int cur_list_idx; + const int num_non_ready_task_lists = (sizeof(non_ready_task_lists) / sizeof(List_t *)); + // Note: - 1 so that if the current list is the last on non_ready_task_lists[], the next list will return NULL + for (cur_list_idx = 0; cur_list_idx < num_non_ready_task_lists - 1; cur_list_idx++) { + if (pxCurTaskList == non_ready_task_lists[cur_list_idx]) { + pxNextTaskList = non_ready_task_lists[cur_list_idx + 1]; + break; + } + } + } + + return pxNextTaskList; +} + +TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ) +{ + TCB_t *pxTCB = (TCB_t *)pxTask; + // Check current task is valid + if (pxTCB != NULL && !portVALID_TCB_MEM(pxTCB)) { + return NULL; + } + + List_t *pxCurTaskList; + const ListItem_t *pxCurListItem; + if (pxTCB == NULL) { + // Starting traversal for the first time + pxCurTaskList = pxGetNextTaskList(NULL); + pxCurListItem = listGET_END_MARKER(pxCurTaskList); + } else { + // Continuing traversal + pxCurTaskList = listLIST_ITEM_CONTAINER(&pxTCB->xStateListItem); + pxCurListItem = &pxTCB->xStateListItem; + } + + ListItem_t *pxNextListItem = NULL; + if (pxCurListItem->pxNext == listGET_END_MARKER(pxCurTaskList)) { + List_t *pxNextTaskList = pxGetNextTaskList(pxCurTaskList); + while (pxNextTaskList != NULL) { + if (!listLIST_IS_EMPTY(pxNextTaskList)) { + // Get the first item in the next task list + pxNextListItem = listGET_HEAD_ENTRY(pxNextTaskList); + break; + } + // Task list is empty. Get the next task list + pxNextTaskList = pxGetNextTaskList(pxNextTaskList); + } + } else { + //There are still more items in the current task list. Get the next item + pxNextListItem = listGET_NEXT(pxCurListItem); + } + + TCB_t *pxNextTCB; + if (pxNextListItem == NULL) { + pxNextTCB = NULL; + } else { + pxNextTCB = (TCB_t *)listGET_LIST_ITEM_OWNER(pxNextListItem); + } + + return pxNextTCB; +} + +BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ) +{ + if (portVALID_TCB_MEM(pxTask) == false || pxTaskSnapshot == NULL) { + return pdFALSE; + } + + TCB_t *pxTCB = (TCB_t *)pxTask; + pxTaskSnapshot->pxTCB = pxTCB; + pxTaskSnapshot->pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack; + pxTaskSnapshot->pxEndOfStack = (StackType_t *)pxTCB->pxEndOfStack; + return pdTRUE; +} + +UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize ) +{ + UBaseType_t uxArrayNumFilled = 0; + + //Traverse all of the tasks lists + List_t *pxCurTaskList = pxGetNextTaskList(NULL); //Get the first task list + while (pxCurTaskList != NULL && uxArrayNumFilled < uxArrayLength) { + if (!listLIST_IS_EMPTY(pxCurTaskList)) { + const ListItem_t *pxCurListItem; + //Walk each task on the current task list + pxCurListItem = listGET_HEAD_ENTRY(pxCurTaskList); + while (pxCurListItem != listGET_END_MARKER(pxCurTaskList)) { + TCB_t *pxTCB = (TCB_t *)listGET_LIST_ITEM_OWNER(pxCurListItem); + vTaskGetSnapshot((TaskHandle_t)pxTCB, &pxTaskSnapshotArray[uxArrayNumFilled]); + uxArrayNumFilled++; + if (!(uxArrayNumFilled < uxArrayLength)) { + break; + } + pxCurListItem = listGET_NEXT(pxCurListItem); + } + } + //Get the next task list + pxCurTaskList = pxGetNextTaskList(pxCurTaskList); + } + + *pxTCBSize = sizeof(TCB_t); + return uxArrayNumFilled; +} +#endif // CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT + +/* ----------------------------------------------------- OpenOCD ------------------------------------------------------- + * + * ------------------------------------------------------------------------------------------------------------------ */ + +#if ( configENABLE_FREERTOS_DEBUG_OCDAWARE == 1 ) + +/** + * Debug param indexes. DO NOT change the order. OpenOCD uses the same indexes + * Entries in FreeRTOS_openocd_params must match the order of these indexes + */ +enum { + ESP_FREERTOS_DEBUG_TABLE_SIZE = 0, + ESP_FREERTOS_DEBUG_TABLE_VERSION, + ESP_FREERTOS_DEBUG_KERNEL_VER_MAJOR, + ESP_FREERTOS_DEBUG_KERNEL_VER_MINOR, + ESP_FREERTOS_DEBUG_KERNEL_VER_BUILD, + ESP_FREERTOS_DEBUG_UX_TOP_USED_PIORITY, + ESP_FREERTOS_DEBUG_PX_TOP_OF_STACK, + ESP_FREERTOS_DEBUG_PC_TASK_NAME, + /* New entries must be inserted here */ + ESP_FREERTOS_DEBUG_TABLE_END, +}; + +const DRAM_ATTR uint8_t FreeRTOS_openocd_params[ESP_FREERTOS_DEBUG_TABLE_END] = { + ESP_FREERTOS_DEBUG_TABLE_END, /* table size */ + 1, /* table version */ + tskKERNEL_VERSION_MAJOR, + tskKERNEL_VERSION_MINOR, + tskKERNEL_VERSION_BUILD, + configMAX_PRIORITIES - 1, /* uxTopUsedPriority */ + offsetof(TCB_t, pxTopOfStack), /* thread_stack_offset; */ + offsetof(TCB_t, pcTaskName), /* thread_name_offset; */ +}; + +#endif // configENABLE_FREERTOS_DEBUG_OCDAWARE == 1 + +/* -------------------------------------------- FreeRTOS IDF API Additions --------------------------------------------- + * FreeRTOS related API that were added by IDF + * ------------------------------------------------------------------------------------------------------------------ */ + +#if CONFIG_FREERTOS_SMP +_Static_assert(tskNO_AFFINITY == CONFIG_FREERTOS_NO_AFFINITY, "CONFIG_FREERTOS_NO_AFFINITY must be the same as tskNO_AFFINITY"); + +BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pxTaskCode, + const char * const pcName, + const uint32_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask, + const BaseType_t xCoreID) +{ + BaseType_t ret; + #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) + { + // Convert xCoreID into an affinity mask + UBaseType_t uxCoreAffinityMask; + if (xCoreID == tskNO_AFFINITY) { + uxCoreAffinityMask = tskNO_AFFINITY; + } else { + uxCoreAffinityMask = (1 << xCoreID); + } + ret = xTaskCreateAffinitySet(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, uxCoreAffinityMask, pxCreatedTask); + } + #else /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ + { + ret = xTaskCreate(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask); + } + #endif /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ + return ret; +} + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) +TaskHandle_t xTaskCreateStaticPinnedToCore( TaskFunction_t pxTaskCode, + const char * const pcName, + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const puxStackBuffer, + StaticTask_t * const pxTaskBuffer, + const BaseType_t xCoreID) +{ + TaskHandle_t ret; + #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) + { + // Convert xCoreID into an affinity mask + UBaseType_t uxCoreAffinityMask; + if (xCoreID == tskNO_AFFINITY) { + uxCoreAffinityMask = tskNO_AFFINITY; + } else { + uxCoreAffinityMask = (1 << xCoreID); + } + ret = xTaskCreateStaticAffinitySet(pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer, uxCoreAffinityMask); + } + #else /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ + { + ret = xTaskCreateStatic(pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer); + } + #endif /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ + return ret; +} +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +TaskHandle_t xTaskGetCurrentTaskHandleForCPU( BaseType_t xCoreID ) +{ + TaskHandle_t xTaskHandleTemp; + assert(xCoreID >= 0 && xCoreID < configNUM_CORES); + taskENTER_CRITICAL(); + xTaskHandleTemp = (TaskHandle_t) pxCurrentTCBs[xCoreID]; + taskEXIT_CRITICAL(); + return xTaskHandleTemp; +} + +TaskHandle_t xTaskGetIdleTaskHandleForCPU( BaseType_t xCoreID ) +{ + assert(xCoreID >= 0 && xCoreID < configNUM_CORES); + return (TaskHandle_t) xIdleTaskHandle[xCoreID]; +} + +BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) +{ + taskENTER_CRITICAL(); + UBaseType_t uxCoreAffinityMask; +#if ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) + TCB_t *pxTCB = prvGetTCBFromHandle( xTask ); + uxCoreAffinityMask = pxTCB->uxCoreAffinityMask; +#else + uxCoreAffinityMask = tskNO_AFFINITY; +#endif + taskEXIT_CRITICAL(); + BaseType_t ret; + // If the task is not pinned to a particular core, treat it as tskNO_AFFINITY + if (uxCoreAffinityMask & (uxCoreAffinityMask - 1)) { // If more than one bit set + ret = tskNO_AFFINITY; + } else { + int index_plus_one = __builtin_ffs(uxCoreAffinityMask); + assert(index_plus_one >= 1); + ret = index_plus_one - 1; + } + return ret; +} + +#if ( CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS ) +void vTaskSetThreadLocalStoragePointerAndDelCallback( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue, TlsDeleteCallbackFunction_t pvDelCallback) + { + // Verify that the offsets of pvThreadLocalStoragePointers and pvDummy15 match. + // pvDummy15 is part of the StaticTask_t struct and is used to access the TLSPs + // while deletion. + _Static_assert(offsetof( StaticTask_t, pvDummy15 ) == offsetof( TCB_t, pvThreadLocalStoragePointers ), "Offset of pvDummy15 must match the offset of pvThreadLocalStoragePointers"); + + //Set the local storage pointer first + vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue ); + + //Set the deletion callback at an offset of configNUM_THREAD_LOCAL_STORAGE_POINTERS/2 + vTaskSetThreadLocalStoragePointer( xTaskToSet, ( xIndex + ( configNUM_THREAD_LOCAL_STORAGE_POINTERS / 2 ) ), pvDelCallback ); + } +#endif // CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS + +#endif // CONFIG_FREERTOS_SMP diff --git a/FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h b/FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h new file mode 100644 index 0000000..07849a8 --- /dev/null +++ b/FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h @@ -0,0 +1,80 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT || defined __DOXYGEN__ +/** + * @brief Task Snapshot structure + * + * - Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system. + * - We need this structure because TCB_t is defined (hidden) in tasks.c. + */ +typedef struct xTASK_SNAPSHOT +{ + void *pxTCB; /*!< Address of the task control block. */ + StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ + StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo + pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ +} TaskSnapshot_t; + +/** + * @brief Iterate over all tasks in the system + * + * - This function can be used to iterate over every task in the system + * - The first call to this function must set pxTask to NULL + * - When all functions have been iterated, this function will return NULL. + * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. + * + * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function + * does not acquire any locks. + * @param pxTask Handle of the previous task (or NULL on the first call of this function) + * @return TaskHandle_t Handle of the next task (or NULL when all tasks have been iterated over) + */ +TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); + +/** + * @brief Fill a TaskSnapshot_t structure for specified task. + * + * - This function is used by the panic handler to get the snapshot of a particular task. + * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. + * + * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function + * does not acquire any locks. + * @param[in] pxTask Task's handle + * @param[out] pxTaskSnapshot Snapshot of the task + * @return pdTRUE if operation was successful else pdFALSE + */ +BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); + +/** + * @brief Fill an array of TaskSnapshot_t structures for every task in the system + * + * - This function is used by the panic handler to get a snapshot of all tasks in the system + * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. + * + * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function + * does not acquire any locks. + * @param[out] pxTaskSnapshotArray Array of TaskSnapshot_t structures filled by this function + * @param[in] uxArrayLength Length of the provided array + * @param[out] pxTCBSize Size of the a task's TCB structure + * @return UBaseType_t + */ +UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize ); + +#endif // CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT || defined __DOXYGEN__ + +#ifdef __cplusplus +} +#endif diff --git a/SConscript b/SConscript index cce859b..3d15055 100644 --- a/SConscript +++ b/SConscript @@ -5,9 +5,6 @@ cwd = GetCurrentDir() objs = [] list = os.listdir(cwd) -if (GetDepend(['PKG_USING_ESP_IDF']) or GetDepend(['BSP_USING_LOCAL_ESP_IDF'])): - Return('objs') - for d in list: path = os.path.join(cwd, d) if os.path.isfile(os.path.join(path, 'SConscript')): From 695675b169a7776f523258e67294281fa50e4fd4 Mon Sep 17 00:00:00 2001 From: WCX1024979076 Date: Tue, 18 Jul 2023 05:40:51 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=92=8Cesp-idf=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9B=B8=E5=85=B3=E7=9A=84.h=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../riscv/include/freertos/FreeRTOSConfig.h | 270 ------------ .../freertos/freertos_tasks_c_additions.h | 399 ------------------ .../riscv/include/freertos/task_snapshot.h | 80 ---- 3 files changed, 749 deletions(-) delete mode 100644 FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h delete mode 100644 FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h delete mode 100644 FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h diff --git a/FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h b/FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h deleted file mode 100644 index 5065a78..0000000 --- a/FreeRTOS/portable/esp-idf/riscv/include/freertos/FreeRTOSConfig.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -#include "sdkconfig.h" - -/* -This file get's pulled into assembly sources. Therefore, some includes need to be wrapped in #ifndef __ASSEMBLER__ -*/ - -#ifndef __ASSEMBLER__ -#include //For configASSERT() -#endif /* def __ASSEMBLER__ */ - -#ifdef CONFIG_FREERTOS_SMP - -// Pull in the SMP configuration -#include "freertos/FreeRTOSConfig_smp.h" - -#else // CONFIG_FREERTOS_SMP - -// The arch-specific FreeRTOSConfig_arch.h in port//include. -#include "freertos/FreeRTOSConfig_arch.h" - -#if !(defined(FREERTOS_CONFIG_XTENSA_H) \ - || defined(FREERTOS_CONFIG_RISCV_H) \ - || defined(FREERTOS_CONFIG_LINUX_H)) -#error "Needs architecture-speific FreeRTOSConfig.h!" -#endif - -/* ----------------------------------------------------- Helpers ------------------------------------------------------- - * - Macros that the FreeRTOS configuration macros depend on - * ------------------------------------------------------------------------------------------------------------------ */ - -/* Higher stack checker modes cause overhead on each function call */ -#if CONFIG_STACK_CHECK_ALL || CONFIG_STACK_CHECK_STRONG -#define STACK_OVERHEAD_CHECKER 256 -#else -#define STACK_OVERHEAD_CHECKER 0 -#endif - -/* with optimizations disabled, scheduler uses additional stack */ -#if CONFIG_COMPILER_OPTIMIZATION_NONE -#define STACK_OVERHEAD_OPTIMIZATION 320 -#else -#define STACK_OVERHEAD_OPTIMIZATION 0 -#endif - -/* apptrace mdule increases minimum stack usage */ -#if CONFIG_APPTRACE_ENABLE -#define STACK_OVERHEAD_APPTRACE 1280 -#else -#define STACK_OVERHEAD_APPTRACE 0 -#endif - -/* Stack watchpoint decreases minimum usable stack size by up to 60 bytes. - See FreeRTOS FREERTOS_WATCHPOINT_END_OF_STACK option in Kconfig. */ -#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK -#define STACK_OVERHEAD_WATCHPOINT 60 -#else -#define STACK_OVERHEAD_WATCHPOINT 0 -#endif - -#define configSTACK_OVERHEAD_TOTAL ( \ - STACK_OVERHEAD_CHECKER + \ - STACK_OVERHEAD_OPTIMIZATION + \ - STACK_OVERHEAD_APPTRACE + \ - STACK_OVERHEAD_WATCHPOINT \ - ) - -/* ------------------------------------------------- FreeRTOS Config --------------------------------------------------- - * - All Vanilla FreeRTOS configuration goes into this section - * - Keep this section in-sync with the corresponding version of single-core upstream version of FreeRTOS - * - Don't put any SMP or ESP-IDF exclusive FreeRTOS configurations here. Those go into the next section - * - Not all FreeRTOS configuration are listed. Some configurations have default values set in FreeRTOS.h thus don't - * need to be explicitly defined. - * ------------------------------------------------------------------------------------------------------------------ */ - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html - *----------------------------------------------------------*/ - -// ------------------ Scheduler Related -------------------- - -#define configUSE_PREEMPTION 1 -#define configUSE_TICKLESS_IDLE CONFIG_FREERTOS_USE_TICKLESS_IDLE -#if configUSE_TICKLESS_IDLE -#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP -#endif //configUSE_TICKLESS_IDLE -#define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000) -#define configTICK_RATE_HZ CONFIG_FREERTOS_HZ -#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority -#define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL ) -#define configUSE_TIME_SLICING 1 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 0 -#define configKERNEL_INTERRUPT_PRIORITY 1 //Todo: This currently isn't used anywhere - -// ------------- Synchronization Primitives ---------------- - -#define configUSE_MUTEXES 1 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_QUEUE_SETS 1 -#define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE -#define configUSE_TASK_NOTIFICATIONS 1 -#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 - -// ----------------------- System -------------------------- - -#define configMAX_TASK_NAME_LEN CONFIG_FREERTOS_MAX_TASK_NAME_LEN -#define configNUM_THREAD_LOCAL_STORAGE_POINTERS CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS -#ifndef CONFIG_IDF_TARGET_LINUX -#define configSTACK_DEPTH_TYPE uint32_t -#define configUSE_NEWLIB_REENTRANT 1 -#endif -#if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY -#define configENABLE_BACKWARD_COMPATIBILITY 1 -#else -#define configENABLE_BACKWARD_COMPATIBILITY 0 -#endif -#define configASSERT(a) assert(a) -#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 - -// ----------------------- Memory ------------------------- - -#define configSUPPORT_STATIC_ALLOCATION 1 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 -//We define the heap to span all of the non-statically-allocated shared RAM. ToDo: Make sure there -//is some space left for the app and main cpu when running outside of a thread. -#define configTOTAL_HEAP_SIZE (&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) ) -#define configAPPLICATION_ALLOCATED_HEAP 1 -#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 - -// ------------------------ Hooks -------------------------- - -#define configUSE_IDLE_HOOK CONFIG_FREERTOS_USE_IDLE_HOOK -#define configUSE_TICK_HOOK CONFIG_FREERTOS_USE_TICK_HOOK -#if CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE -#define configCHECK_FOR_STACK_OVERFLOW 0 -#elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL -#define configCHECK_FOR_STACK_OVERFLOW 1 -#elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY -#define configCHECK_FOR_STACK_OVERFLOW 2 -#endif -#define configRECORD_STACK_HIGH_ADDRESS 1 - -// ------------------- Run-time Stats ---------------------- - -#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS -#define configGENERATE_RUN_TIME_STATS 1 /* Used by vTaskGetRunTimeStats() */ -#endif -#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY -#define configUSE_TRACE_FACILITY 1 /* Used by uxTaskGetSystemState(), and other trace facility functions */ -#endif -#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */ -#endif - -// -------------------- Co-routines ----------------------- - -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES 2 - -// ------------------- Software Timer ---------------------- - -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY CONFIG_FREERTOS_TIMER_TASK_PRIORITY -#define configTIMER_QUEUE_LENGTH CONFIG_FREERTOS_TIMER_QUEUE_LENGTH -#define configTIMER_TASK_STACK_DEPTH CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH - -// -------------------- API Includes ----------------------- - -#if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY -#define configENABLE_BACKWARD_COMPATIBILITY 1 -#else -#define configENABLE_BACKWARD_COMPATIBILITY 0 -#endif - -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_xTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTaskGetIdleTaskHandle 1 -#define INCLUDE_xTaskAbortDelay 1 -#define INCLUDE_xSemaphoreGetMutexHolder 1 -#define INCLUDE_xTaskGetHandle 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 1 -#define INCLUDE_uxTaskGetStackHighWaterMark2 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTaskResumeFromISR 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_xTaskGetSchedulerState 1 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -//Unlisted -#define INCLUDE_pxTaskGetStackStart 1 - -// -------------------- Trace Macros ----------------------- - -/* -For trace macros. -Note: Include trace macros here and not above as trace macros are dependent on some of the FreeRTOS configs -*/ -#ifndef __ASSEMBLER__ -#if CONFIG_SYSVIEW_ENABLE -#include "SEGGER_SYSVIEW_FreeRTOS.h" -#undef INLINE // to avoid redefinition -#endif //CONFIG_SYSVIEW_ENABLE -#endif /* def __ASSEMBLER__ */ - -/* ------------------------------------------------ ESP-IDF Additions -------------------------------------------------- - * - All FreeRTOS related configurations no part of Vanilla FreeRTOS goes into this section - * - FreeRTOS configurations related to SMP and ESP-IDF additions go into this section - * ------------------------------------------------------------------------------------------------------------------ */ - -// ------------------------- SMP --------------------------- - -#ifndef CONFIG_FREERTOS_UNICORE -#define portNUM_PROCESSORS 2 -#else -#define portNUM_PROCESSORS 1 -#endif -#define configNUM_CORES portNUM_PROCESSORS -#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID -#define configTASKLIST_INCLUDE_COREID 1 -#endif - -// ---------------------- Features ------------------------- - -#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1 -#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 - -#ifndef __ASSEMBLER__ -#if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP -extern void vPortCleanUpTCB ( void *pxTCB ); -#define portCLEAN_UP_TCB( pxTCB ) vPortCleanUpTCB( pxTCB ) -#endif -#endif - -// -------------------- Compatibility ---------------------- - -// backward compatibility for 4.4 -#define xTaskRemoveFromUnorderedEventList vTaskRemoveFromUnorderedEventList - -#endif // CONFIG_FREERTOS_SMP - -#endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h b/FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h deleted file mode 100644 index 96fc4f7..0000000 --- a/FreeRTOS/portable/esp-idf/riscv/include/freertos/freertos_tasks_c_additions.h +++ /dev/null @@ -1,399 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "sdkconfig.h" - -/** - * This file will be included in `tasks.c` file, thus, it must NOT be included - * by any (other) file. - * The functions below only consist in getters for the static variables in - * `tasks.c` file. - * The only source files that should call these functions are the ones in - * `/additions` directory. - */ - -/* ----------------------------------------------------- Newlib -------------------------------------------------------- - * - * ------------------------------------------------------------------------------------------------------------------ */ - -#if ( configUSE_NEWLIB_REENTRANT == 1 ) -/** - * @brief Get reentrancy structure of the current task - * - * - This funciton is required by newlib (when __DYNAMIC_REENT__ is enabled) - * - It will return a pointer to the current task's reent struct - * - If FreeRTOS is not running, it will return the global reent struct - * - * @return Pointer to a the (current taks's)/(globa) reent struct - */ -struct _reent *__getreent(void) -{ - // No lock needed because if this changes, we won't be running anymore. - struct _reent *ret; -#if !defined CONFIG_IDF_RTOS_RTTHREAD - TCB_t *pxCurTask = xTaskGetCurrentTaskHandle(); - if (pxCurTask == NULL) { - // No task running. Return global struct. - ret = _GLOBAL_REENT; - } else { - // We have a task; return its reentrant struct. - ret = &pxCurTask->xNewLib_reent; - } -#else - ret = _GLOBAL_REENT; -#endif - return ret; -} -#endif // configUSE_NEWLIB_REENTRANT == 1 - -/* -------------------------------------------------- Task Snapshot ---------------------------------------------------- - * - * ------------------------------------------------------------------------------------------------------------------ */ - -#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT - -#include "task_snapshot.h" - -/** - * @brief List of all task lists in FreeRTOS - * - * @note There are currently differing number of task list between SMP FreeRTOS and ESP-IDF FreeRTOS - */ -static List_t *non_ready_task_lists[] = { - #ifdef CONFIG_FREERTOS_SMP - &xPendingReadyList, - #else - &xPendingReadyList[0], - #ifndef CONFIG_FREERTOS_UNICORE - &xPendingReadyList[1], - #endif // CONFIG_FREERTOS_UNICORE - #endif //CONFIG_FREERTOS_SMP - &xDelayedTaskList1, - &xDelayedTaskList2, - #if( INCLUDE_vTaskDelete == 1 ) - &xTasksWaitingTermination, - #endif - #if( INCLUDE_vTaskSuspend == 1 ) - &xSuspendedTaskList, - #endif -}; - -/** - * @brief Get the next task list to traverse - * - * - Given a particular task list, this function returns the next task to traverse. - * - The task lists are returned in the following precedence - * - Ready lists (highest to lowers priority) - * - Pending ready list(s) - * - Delayed list 1 - * - Delayed list 2 - * - Waiting termination list - * - Suspended list - * - * @param pxCurTaskList Previously traversed task list (or NULL if obtaining the first task list) - * @return List_t* The next task list to traverse (or NULL of all task lists have been traversed) - */ -static List_t *pxGetNextTaskList(List_t *pxCurTaskList) -{ - List_t *pxNextTaskList = NULL; - - // No Current List. Start from the highest priority ready task list - if (pxCurTaskList == NULL) - { - pxNextTaskList = &pxReadyTasksLists[configMAX_PRIORITIES - 1]; - } - // Current list is one of the ready task lists. Find the current priority, and return the next lower priority ready task list - else if (pxCurTaskList >= &pxReadyTasksLists[0] && pxCurTaskList <= &pxReadyTasksLists[configMAX_PRIORITIES - 1] ) - { - // Find the current priority - int cur_priority; - for (cur_priority = configMAX_PRIORITIES - 1; cur_priority >= 0; cur_priority--) { - if (pxCurTaskList == &pxReadyTasksLists[cur_priority]) { - break; - } - } - // Return the ready task list at (cur_priority - 1), or the pending ready task list - if (cur_priority > 0) - { - pxNextTaskList = &pxReadyTasksLists[cur_priority - 1]; - } - // We've reached the end of the Ready Task Lists. We get the next list from the non-ready task lists - else if (cur_priority == 0) - { - pxNextTaskList = non_ready_task_lists[0]; - } - else - { - abort(); // This should never occur - } - } - - // Current list is one of the non-ready task lists. Fetch the next non-ready task list - if (pxNextTaskList == NULL) { - int cur_list_idx; - const int num_non_ready_task_lists = (sizeof(non_ready_task_lists) / sizeof(List_t *)); - // Note: - 1 so that if the current list is the last on non_ready_task_lists[], the next list will return NULL - for (cur_list_idx = 0; cur_list_idx < num_non_ready_task_lists - 1; cur_list_idx++) { - if (pxCurTaskList == non_ready_task_lists[cur_list_idx]) { - pxNextTaskList = non_ready_task_lists[cur_list_idx + 1]; - break; - } - } - } - - return pxNextTaskList; -} - -TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ) -{ - TCB_t *pxTCB = (TCB_t *)pxTask; - // Check current task is valid - if (pxTCB != NULL && !portVALID_TCB_MEM(pxTCB)) { - return NULL; - } - - List_t *pxCurTaskList; - const ListItem_t *pxCurListItem; - if (pxTCB == NULL) { - // Starting traversal for the first time - pxCurTaskList = pxGetNextTaskList(NULL); - pxCurListItem = listGET_END_MARKER(pxCurTaskList); - } else { - // Continuing traversal - pxCurTaskList = listLIST_ITEM_CONTAINER(&pxTCB->xStateListItem); - pxCurListItem = &pxTCB->xStateListItem; - } - - ListItem_t *pxNextListItem = NULL; - if (pxCurListItem->pxNext == listGET_END_MARKER(pxCurTaskList)) { - List_t *pxNextTaskList = pxGetNextTaskList(pxCurTaskList); - while (pxNextTaskList != NULL) { - if (!listLIST_IS_EMPTY(pxNextTaskList)) { - // Get the first item in the next task list - pxNextListItem = listGET_HEAD_ENTRY(pxNextTaskList); - break; - } - // Task list is empty. Get the next task list - pxNextTaskList = pxGetNextTaskList(pxNextTaskList); - } - } else { - //There are still more items in the current task list. Get the next item - pxNextListItem = listGET_NEXT(pxCurListItem); - } - - TCB_t *pxNextTCB; - if (pxNextListItem == NULL) { - pxNextTCB = NULL; - } else { - pxNextTCB = (TCB_t *)listGET_LIST_ITEM_OWNER(pxNextListItem); - } - - return pxNextTCB; -} - -BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ) -{ - if (portVALID_TCB_MEM(pxTask) == false || pxTaskSnapshot == NULL) { - return pdFALSE; - } - - TCB_t *pxTCB = (TCB_t *)pxTask; - pxTaskSnapshot->pxTCB = pxTCB; - pxTaskSnapshot->pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack; - pxTaskSnapshot->pxEndOfStack = (StackType_t *)pxTCB->pxEndOfStack; - return pdTRUE; -} - -UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize ) -{ - UBaseType_t uxArrayNumFilled = 0; - - //Traverse all of the tasks lists - List_t *pxCurTaskList = pxGetNextTaskList(NULL); //Get the first task list - while (pxCurTaskList != NULL && uxArrayNumFilled < uxArrayLength) { - if (!listLIST_IS_EMPTY(pxCurTaskList)) { - const ListItem_t *pxCurListItem; - //Walk each task on the current task list - pxCurListItem = listGET_HEAD_ENTRY(pxCurTaskList); - while (pxCurListItem != listGET_END_MARKER(pxCurTaskList)) { - TCB_t *pxTCB = (TCB_t *)listGET_LIST_ITEM_OWNER(pxCurListItem); - vTaskGetSnapshot((TaskHandle_t)pxTCB, &pxTaskSnapshotArray[uxArrayNumFilled]); - uxArrayNumFilled++; - if (!(uxArrayNumFilled < uxArrayLength)) { - break; - } - pxCurListItem = listGET_NEXT(pxCurListItem); - } - } - //Get the next task list - pxCurTaskList = pxGetNextTaskList(pxCurTaskList); - } - - *pxTCBSize = sizeof(TCB_t); - return uxArrayNumFilled; -} -#endif // CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT - -/* ----------------------------------------------------- OpenOCD ------------------------------------------------------- - * - * ------------------------------------------------------------------------------------------------------------------ */ - -#if ( configENABLE_FREERTOS_DEBUG_OCDAWARE == 1 ) - -/** - * Debug param indexes. DO NOT change the order. OpenOCD uses the same indexes - * Entries in FreeRTOS_openocd_params must match the order of these indexes - */ -enum { - ESP_FREERTOS_DEBUG_TABLE_SIZE = 0, - ESP_FREERTOS_DEBUG_TABLE_VERSION, - ESP_FREERTOS_DEBUG_KERNEL_VER_MAJOR, - ESP_FREERTOS_DEBUG_KERNEL_VER_MINOR, - ESP_FREERTOS_DEBUG_KERNEL_VER_BUILD, - ESP_FREERTOS_DEBUG_UX_TOP_USED_PIORITY, - ESP_FREERTOS_DEBUG_PX_TOP_OF_STACK, - ESP_FREERTOS_DEBUG_PC_TASK_NAME, - /* New entries must be inserted here */ - ESP_FREERTOS_DEBUG_TABLE_END, -}; - -const DRAM_ATTR uint8_t FreeRTOS_openocd_params[ESP_FREERTOS_DEBUG_TABLE_END] = { - ESP_FREERTOS_DEBUG_TABLE_END, /* table size */ - 1, /* table version */ - tskKERNEL_VERSION_MAJOR, - tskKERNEL_VERSION_MINOR, - tskKERNEL_VERSION_BUILD, - configMAX_PRIORITIES - 1, /* uxTopUsedPriority */ - offsetof(TCB_t, pxTopOfStack), /* thread_stack_offset; */ - offsetof(TCB_t, pcTaskName), /* thread_name_offset; */ -}; - -#endif // configENABLE_FREERTOS_DEBUG_OCDAWARE == 1 - -/* -------------------------------------------- FreeRTOS IDF API Additions --------------------------------------------- - * FreeRTOS related API that were added by IDF - * ------------------------------------------------------------------------------------------------------------------ */ - -#if CONFIG_FREERTOS_SMP -_Static_assert(tskNO_AFFINITY == CONFIG_FREERTOS_NO_AFFINITY, "CONFIG_FREERTOS_NO_AFFINITY must be the same as tskNO_AFFINITY"); - -BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pxTaskCode, - const char * const pcName, - const uint32_t usStackDepth, - void * const pvParameters, - UBaseType_t uxPriority, - TaskHandle_t * const pxCreatedTask, - const BaseType_t xCoreID) -{ - BaseType_t ret; - #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) - { - // Convert xCoreID into an affinity mask - UBaseType_t uxCoreAffinityMask; - if (xCoreID == tskNO_AFFINITY) { - uxCoreAffinityMask = tskNO_AFFINITY; - } else { - uxCoreAffinityMask = (1 << xCoreID); - } - ret = xTaskCreateAffinitySet(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, uxCoreAffinityMask, pxCreatedTask); - } - #else /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ - { - ret = xTaskCreate(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask); - } - #endif /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ - return ret; -} - -#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) -TaskHandle_t xTaskCreateStaticPinnedToCore( TaskFunction_t pxTaskCode, - const char * const pcName, - const uint32_t ulStackDepth, - void * const pvParameters, - UBaseType_t uxPriority, - StackType_t * const puxStackBuffer, - StaticTask_t * const pxTaskBuffer, - const BaseType_t xCoreID) -{ - TaskHandle_t ret; - #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) - { - // Convert xCoreID into an affinity mask - UBaseType_t uxCoreAffinityMask; - if (xCoreID == tskNO_AFFINITY) { - uxCoreAffinityMask = tskNO_AFFINITY; - } else { - uxCoreAffinityMask = (1 << xCoreID); - } - ret = xTaskCreateStaticAffinitySet(pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer, uxCoreAffinityMask); - } - #else /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ - { - ret = xTaskCreateStatic(pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer); - } - #endif /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) */ - return ret; -} -#endif /* configSUPPORT_STATIC_ALLOCATION */ - -TaskHandle_t xTaskGetCurrentTaskHandleForCPU( BaseType_t xCoreID ) -{ - TaskHandle_t xTaskHandleTemp; - assert(xCoreID >= 0 && xCoreID < configNUM_CORES); - taskENTER_CRITICAL(); - xTaskHandleTemp = (TaskHandle_t) pxCurrentTCBs[xCoreID]; - taskEXIT_CRITICAL(); - return xTaskHandleTemp; -} - -TaskHandle_t xTaskGetIdleTaskHandleForCPU( BaseType_t xCoreID ) -{ - assert(xCoreID >= 0 && xCoreID < configNUM_CORES); - return (TaskHandle_t) xIdleTaskHandle[xCoreID]; -} - -BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) -{ - taskENTER_CRITICAL(); - UBaseType_t uxCoreAffinityMask; -#if ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) - TCB_t *pxTCB = prvGetTCBFromHandle( xTask ); - uxCoreAffinityMask = pxTCB->uxCoreAffinityMask; -#else - uxCoreAffinityMask = tskNO_AFFINITY; -#endif - taskEXIT_CRITICAL(); - BaseType_t ret; - // If the task is not pinned to a particular core, treat it as tskNO_AFFINITY - if (uxCoreAffinityMask & (uxCoreAffinityMask - 1)) { // If more than one bit set - ret = tskNO_AFFINITY; - } else { - int index_plus_one = __builtin_ffs(uxCoreAffinityMask); - assert(index_plus_one >= 1); - ret = index_plus_one - 1; - } - return ret; -} - -#if ( CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS ) -void vTaskSetThreadLocalStoragePointerAndDelCallback( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue, TlsDeleteCallbackFunction_t pvDelCallback) - { - // Verify that the offsets of pvThreadLocalStoragePointers and pvDummy15 match. - // pvDummy15 is part of the StaticTask_t struct and is used to access the TLSPs - // while deletion. - _Static_assert(offsetof( StaticTask_t, pvDummy15 ) == offsetof( TCB_t, pvThreadLocalStoragePointers ), "Offset of pvDummy15 must match the offset of pvThreadLocalStoragePointers"); - - //Set the local storage pointer first - vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue ); - - //Set the deletion callback at an offset of configNUM_THREAD_LOCAL_STORAGE_POINTERS/2 - vTaskSetThreadLocalStoragePointer( xTaskToSet, ( xIndex + ( configNUM_THREAD_LOCAL_STORAGE_POINTERS / 2 ) ), pvDelCallback ); - } -#endif // CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS - -#endif // CONFIG_FREERTOS_SMP diff --git a/FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h b/FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h deleted file mode 100644 index 07849a8..0000000 --- a/FreeRTOS/portable/esp-idf/riscv/include/freertos/task_snapshot.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "sdkconfig.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT || defined __DOXYGEN__ -/** - * @brief Task Snapshot structure - * - * - Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system. - * - We need this structure because TCB_t is defined (hidden) in tasks.c. - */ -typedef struct xTASK_SNAPSHOT -{ - void *pxTCB; /*!< Address of the task control block. */ - StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ - StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo - pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ -} TaskSnapshot_t; - -/** - * @brief Iterate over all tasks in the system - * - * - This function can be used to iterate over every task in the system - * - The first call to this function must set pxTask to NULL - * - When all functions have been iterated, this function will return NULL. - * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. - * - * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function - * does not acquire any locks. - * @param pxTask Handle of the previous task (or NULL on the first call of this function) - * @return TaskHandle_t Handle of the next task (or NULL when all tasks have been iterated over) - */ -TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); - -/** - * @brief Fill a TaskSnapshot_t structure for specified task. - * - * - This function is used by the panic handler to get the snapshot of a particular task. - * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. - * - * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function - * does not acquire any locks. - * @param[in] pxTask Task's handle - * @param[out] pxTaskSnapshot Snapshot of the task - * @return pdTRUE if operation was successful else pdFALSE - */ -BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); - -/** - * @brief Fill an array of TaskSnapshot_t structures for every task in the system - * - * - This function is used by the panic handler to get a snapshot of all tasks in the system - * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. - * - * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function - * does not acquire any locks. - * @param[out] pxTaskSnapshotArray Array of TaskSnapshot_t structures filled by this function - * @param[in] uxArrayLength Length of the provided array - * @param[out] pxTCBSize Size of the a task's TCB structure - * @return UBaseType_t - */ -UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize ); - -#endif // CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT || defined __DOXYGEN__ - -#ifdef __cplusplus -} -#endif From 1b57d77c351832f1fd7b687de17b469ba312f5e6 Mon Sep 17 00:00:00 2001 From: WCX1024979076 Date: Tue, 18 Jul 2023 06:18:15 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20Sconscript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeRTOS/SConscript | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/FreeRTOS/SConscript b/FreeRTOS/SConscript index 6fff18e..0627782 100644 --- a/FreeRTOS/SConscript +++ b/FreeRTOS/SConscript @@ -3,6 +3,7 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') +CPPPATH = [os.path.join(cwd, "include", "freertos"), os.path.join(cwd, "include")] if (GetDepend(['PKG_USING_ESP_IDF']) or GetDepend(['BSP_USING_LOCAL_ESP_IDF'])): src += Split(""" @@ -10,16 +11,17 @@ if (GetDepend(['PKG_USING_ESP_IDF']) or GetDepend(['BSP_USING_LOCAL_ESP_IDF'])): portable/esp-idf/riscv/port.c portable/esp-idf/port_common.c """) - CPPPATH = Split(""" - include - include/freertos + CPPPATH += Split(""" portable/esp-idf/riscv/include portable/esp-idf/riscv/include/freertos """) -else : + +if GetDepend('PKG_FREERTOS_WRAPPER_USING_RTTHREAD') : src += Glob(os.path.join("portable", "rt-thread", "*.c")) + CPPPATH += [ os.path.join(cwd, "portable", "rt-thread")] + +if GetDepend('PKG_FREERTOS_WRAPPER_USING_MEMANG') : src += Glob(os.path.join("portable", "MemMang", "heap_3.c")) - CPPPATH = [os.path.join(cwd, "include", "freertos"), os.path.join(cwd, "portable", "rt-thread")] group = DefineGroup('FreeRTOS', src, depend = [''], CPPPATH = CPPPATH) From bf27c39947c0c436057db625b74e2aa99cf8e0a7 Mon Sep 17 00:00:00 2001 From: WCX1024979076 Date: Tue, 18 Jul 2023 06:32:51 +0000 Subject: [PATCH 4/5] change sconscript --- FreeRTOS/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeRTOS/SConscript b/FreeRTOS/SConscript index 0627782..a538205 100644 --- a/FreeRTOS/SConscript +++ b/FreeRTOS/SConscript @@ -5,7 +5,7 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [os.path.join(cwd, "include", "freertos"), os.path.join(cwd, "include")] -if (GetDepend(['PKG_USING_ESP_IDF']) or GetDepend(['BSP_USING_LOCAL_ESP_IDF'])): +if (GetDepend(['PKG_USING_ESP_IDF']): src += Split(""" portable/esp-idf/port_rt.c portable/esp-idf/riscv/port.c From a5d9aaee70fe2ea4557b26d8431b44acd99de385 Mon Sep 17 00:00:00 2001 From: WCX1024979076 Date: Tue, 18 Jul 2023 06:34:49 +0000 Subject: [PATCH 5/5] change sconscript --- FreeRTOS/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeRTOS/SConscript b/FreeRTOS/SConscript index a538205..e38c6af 100644 --- a/FreeRTOS/SConscript +++ b/FreeRTOS/SConscript @@ -5,7 +5,7 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [os.path.join(cwd, "include", "freertos"), os.path.join(cwd, "include")] -if (GetDepend(['PKG_USING_ESP_IDF']): +if GetDepend(['PKG_USING_ESP_IDF']): src += Split(""" portable/esp-idf/port_rt.c portable/esp-idf/riscv/port.c