From d0aa950fa6818b620e0db363d1cd166f7c407609 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Thu, 26 Oct 2023 22:41:36 +0800 Subject: [PATCH 1/2] feat(freertos/idf): Add configRUN_TIME_COUNTER_TYPE option This commit adds a Kconfig option for configRUN_TIME_COUNTER_TYPE Closes https://github.com/espressif/esp-idf/issues/11973 --- components/freertos/Kconfig | 19 +++++++++++++++++++ .../config/include/freertos/FreeRTOSConfig.h | 8 ++++++++ .../freertos/sdkconfig.ci.freertos_options | 1 + 3 files changed, 28 insertions(+) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index eccb221ff2..d8ca79b487 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -244,6 +244,25 @@ menu "FreeRTOS" Note: The clock used for run time statistics can be configured in FREERTOS_RUN_TIME_STATS_CLK. + choice FREERTOS_RUN_TIME_COUNTER_TYPE + prompt "configRUN_TIME_COUNTER_TYPE" + depends on FREERTOS_GENERATE_RUN_TIME_STATS && !FREERTOS_SMP + default FREERTOS_RUN_TIME_COUNTER_TYPE_U32 + help + Sets the data type used for the FreeRTOS run time stats. A larger data type can be used to reduce the + frequency of the counter overflowing. + + config FREERTOS_RUN_TIME_COUNTER_TYPE_U32 + bool "uint32_t" + help + configRUN_TIME_COUNTER_TYPE is set to uint32_t + + config FREERTOS_RUN_TIME_COUNTER_TYPE_U64 + bool "uint64_t" + help + configRUN_TIME_COUNTER_TYPE is set to uint64_t + endchoice # FREERTOS_RUN_TIME_COUNTER_TYPE + config FREERTOS_USE_TICKLESS_IDLE # Todo: Currently not supported in SMP FreeRTOS yet (IDF-4986) # Todo: Consider whether this option should still be exposed (IDF-4986) diff --git a/components/freertos/config/include/freertos/FreeRTOSConfig.h b/components/freertos/config/include/freertos/FreeRTOSConfig.h index 623272fbc3..c8e7922615 100644 --- a/components/freertos/config/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/config/include/freertos/FreeRTOSConfig.h @@ -165,6 +165,14 @@ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */ #endif /* CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS */ +#if !CONFIG_FREERTOS_SMP + #if CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U32 + #define configRUN_TIME_COUNTER_TYPE uint32_t + #elif CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U64 + #define configRUN_TIME_COUNTER_TYPE uint64_t + #endif /* CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U64 */ +#endif /* !CONFIG_FREERTOS_SMP */ + /* -------------------- Co-routines ----------------------- */ #define configUSE_CO_ROUTINES 0 /* CO_ROUTINES are not supported in ESP-IDF */ diff --git a/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options b/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options index 541b767a2a..38ae8ab7df 100644 --- a/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options +++ b/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options @@ -13,6 +13,7 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y +CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U64=y CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_FREERTOS_FPU_IN_ISR=y CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2 From 2d07e3a6dce64de18b4a97492297c1c9ea05925b Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Tue, 31 Oct 2023 15:44:37 +0800 Subject: [PATCH 2/2] change(freertos): Update real_time_stats example to use configRUN_TIME_COUNTER_TYPE This commit updates the real_time_stats example to use the configurable configRUN_TIME_COUNTER_TYPE. The CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U64 is enabled by the example by default to demonstrate its usage. Note: Also cleaned up redundant configs in sdkconfig.ci --- .../real_time_stats/main/real_time_stats_example_main.c | 2 +- examples/system/freertos/real_time_stats/sdkconfig.ci | 2 -- examples/system/freertos/real_time_stats/sdkconfig.defaults | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/system/freertos/real_time_stats/main/real_time_stats_example_main.c b/examples/system/freertos/real_time_stats/main/real_time_stats_example_main.c index 03639c1b20..517177a64f 100644 --- a/examples/system/freertos/real_time_stats/main/real_time_stats_example_main.c +++ b/examples/system/freertos/real_time_stats/main/real_time_stats_example_main.c @@ -53,7 +53,7 @@ static esp_err_t print_real_time_stats(TickType_t xTicksToWait) { TaskStatus_t *start_array = NULL, *end_array = NULL; UBaseType_t start_array_size, end_array_size; - uint32_t start_run_time, end_run_time; + configRUN_TIME_COUNTER_TYPE start_run_time, end_run_time; esp_err_t ret; //Allocate array to store current task states diff --git a/examples/system/freertos/real_time_stats/sdkconfig.ci b/examples/system/freertos/real_time_stats/sdkconfig.ci index c87713d246..e69de29bb2 100644 --- a/examples/system/freertos/real_time_stats/sdkconfig.ci +++ b/examples/system/freertos/real_time_stats/sdkconfig.ci @@ -1,2 +0,0 @@ -CONFIG_FREERTOS_USE_TRACE_FACILITY=y -CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y diff --git a/examples/system/freertos/real_time_stats/sdkconfig.defaults b/examples/system/freertos/real_time_stats/sdkconfig.defaults index c87713d246..81c4a2635c 100644 --- a/examples/system/freertos/real_time_stats/sdkconfig.defaults +++ b/examples/system/freertos/real_time_stats/sdkconfig.defaults @@ -1,2 +1,3 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y +CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U64=y