mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-13 17:48:26 +08:00
Merge branch 'feature/add_cpu_usage' into 'master'
Add function to get CPU usage See merge request sdk/ESP8266_RTOS_SDK!812
This commit is contained in:
@ -93,4 +93,55 @@ config FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
|
|||||||
FreeRTOS. This will allow the usage of stats formatting functions such
|
FreeRTOS. This will allow the usage of stats formatting functions such
|
||||||
as vTaskList().
|
as vTaskList().
|
||||||
|
|
||||||
|
config FREERTOS_GENERATE_RUN_TIME_STATS
|
||||||
|
bool "Enable FreeRTOS to collect run time stats"
|
||||||
|
default n
|
||||||
|
select FREERTOS_USE_TRACE_FACILITY
|
||||||
|
select FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
|
||||||
|
help
|
||||||
|
If enabled, configGENERATE_RUN_TIME_STATS will be defined as 1 in
|
||||||
|
FreeRTOS. This will allow FreeRTOS to collect information regarding the
|
||||||
|
usage of processor time amongst FreeRTOS tasks. Run time stats are
|
||||||
|
generated using either the ESP Timer or the CPU Clock as the clock
|
||||||
|
source (Note that run time stats are only valid until the clock source
|
||||||
|
overflows). The function vTaskGetRunTimeStats() will also be available
|
||||||
|
if FREERTOS_USE_STATS_FORMATTING_FUNCTIONS and
|
||||||
|
FREERTOS_USE_TRACE_FACILITY are enabled. vTaskGetRunTimeStats() will
|
||||||
|
display the run time of each task as a % of the total run time of all
|
||||||
|
CPUs (task run time / no of CPUs) / (total run time / 100 )
|
||||||
|
|
||||||
|
choice FREERTOS_RUN_TIME_STATS_CLK
|
||||||
|
prompt "Choose the clock source for run time stats"
|
||||||
|
depends on FREERTOS_GENERATE_RUN_TIME_STATS
|
||||||
|
default FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
help
|
||||||
|
Choose the clock source for FreeRTOS run time stats. Options are CPU0's
|
||||||
|
CPU Clock or the ESP Timer. Both clock sources are 32 bits. The CPU
|
||||||
|
Clock can run at a higher frequency hence provide a finer resolution
|
||||||
|
but will overflow much quicker. Note that run time stats are only valid
|
||||||
|
until the clock source overflows.
|
||||||
|
|
||||||
|
config FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
bool "Use ESP TIMER for run time stats"
|
||||||
|
help
|
||||||
|
ESP Timer will be used as the clock source for FreeRTOS run time stats.
|
||||||
|
The ESP Timer runs at a frequency of 1MHz regardless of Dynamic
|
||||||
|
Frequency Scaling. Therefore the ESP Timer will overflow in
|
||||||
|
approximately 4290 seconds.
|
||||||
|
|
||||||
|
config FREERTOS_RUN_TIME_STATS_USING_CPU_CLK
|
||||||
|
bool "Use CPU Clock for run time stats"
|
||||||
|
help
|
||||||
|
CPU Clock will be used as the clock source for the generation of run
|
||||||
|
time stats. The CPU Clock has a frequency dependent on
|
||||||
|
ESP32_DEFAULT_CPU_FREQ_MHZ and Dynamic Frequency Scaling (DFS).
|
||||||
|
Therefore the CPU Clock frequency can fluctuate between 80 to 240MHz.
|
||||||
|
Run time stats generated using the CPU Clock represents the number of
|
||||||
|
CPU cycles each task is allocated and DOES NOT reflect the amount of
|
||||||
|
time each task runs for (as CPU clock frequency can change). If the CPU
|
||||||
|
clock consistently runs at the maximum frequency of 240MHz, it will
|
||||||
|
overflow in approximately 17 seconds.
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
@ -144,5 +144,25 @@ NVIC value of 255. */
|
|||||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */
|
#define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
|
||||||
|
#define configGENERATE_RUN_TIME_STATS 1 /* Used by vTaskGetRunTimeStats() */
|
||||||
|
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
|
|
||||||
|
//ccount or esp_timer are initialized elsewhere
|
||||||
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||||
|
|
||||||
|
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_CPU_CLK
|
||||||
|
/* Fine resolution time */
|
||||||
|
#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount()
|
||||||
|
#elif defined(CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER)
|
||||||
|
/* Coarse resolution time (us) */
|
||||||
|
#ifndef __ASSEMBLER__
|
||||||
|
uint32_t esp_get_time(void);
|
||||||
|
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) x = (uint32_t)esp_get_time()
|
||||||
|
#endif /* __ASSEMBLER__ */
|
||||||
|
#endif /* CONFIG_FREERTOS_RUN_TIME_STATS_USING_CPU_CLK */
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS */
|
||||||
|
|
||||||
#endif /* FREERTOS_CONFIG_H */
|
#endif /* FREERTOS_CONFIG_H */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user