mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
fix(esp_timer): avoid signed integer overflow in ESP_SYSTEM_INIT_FN
CONFIG_ESP_TIMER_ISR_AFFINITY can be equal to -1, whereas ESP_SYSTEM_INIT_FN takes an uint16_t argument. To avoid overflow, move the choice of init mask into source code and set the value explicitly.
This commit is contained in:
@@ -54,7 +54,7 @@ CORE: 170: init_xt_wdt in components/esp_system/startup_funcs.c on BIT(0)
|
|||||||
########### SECONDARY startup stage ###########
|
########### SECONDARY startup stage ###########
|
||||||
|
|
||||||
# esp_timer has to be initialized early, since it is used by several other components
|
# esp_timer has to be initialized early, since it is used by several other components
|
||||||
SECONDARY: 100: esp_timer_startup_init in components/esp_timer/src/esp_timer.c on CONFIG_ESP_TIMER_ISR_AFFINITY
|
SECONDARY: 100: esp_timer_startup_init in components/esp_timer/src/esp_timer.c on ESP_TIMER_INIT_MASK
|
||||||
|
|
||||||
# HW stack guard via assist-debug module.
|
# HW stack guard via assist-debug module.
|
||||||
SECONDARY: 101: esp_hw_stack_guard_init in components/esp_system/hw_stack_guard.c on ESP_SYSTEM_INIT_ALL_CORES
|
SECONDARY: 101: esp_hw_stack_guard_init in components/esp_system/hw_stack_guard.c on ESP_SYSTEM_INIT_ALL_CORES
|
||||||
|
@@ -74,12 +74,6 @@ menu "High resolution timer (esp_timer)"
|
|||||||
depends on !FREERTOS_UNICORE && ESP_TIMER_SHOW_EXPERIMENTAL
|
depends on !FREERTOS_UNICORE && ESP_TIMER_SHOW_EXPERIMENTAL
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config ESP_TIMER_ISR_AFFINITY
|
|
||||||
hex
|
|
||||||
default 0x1 if ESP_TIMER_ISR_AFFINITY_CPU0
|
|
||||||
default 0x2 if ESP_TIMER_ISR_AFFINITY_CPU1
|
|
||||||
default FREERTOS_NO_AFFINITY if ESP_TIMER_ISR_AFFINITY_NO_AFFINITY
|
|
||||||
|
|
||||||
choice ESP_TIMER_ISR_AFFINITY
|
choice ESP_TIMER_ISR_AFFINITY
|
||||||
prompt "timer interrupt core affinity"
|
prompt "timer interrupt core affinity"
|
||||||
default ESP_TIMER_ISR_AFFINITY_CPU0
|
default ESP_TIMER_ISR_AFFINITY_CPU0
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -574,7 +574,16 @@ esp_err_t esp_timer_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_SYSTEM_INIT_FN(esp_timer_startup_init, SECONDARY, CONFIG_ESP_TIMER_ISR_AFFINITY, 100)
|
#if CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0
|
||||||
|
#define ESP_TIMER_INIT_MASK BIT(0)
|
||||||
|
#elif CONFIG_ESP_TIMER_ISR_AFFINITY_CPU1
|
||||||
|
#define ESP_TIMER_INIT_MASK BIT(1)
|
||||||
|
#elif CONFIG_ESP_TIMER_ISR_AFFINITY_NO_AFFINITY
|
||||||
|
#define ESP_TIMER_INIT_MASK ESP_SYSTEM_INIT_ALL_CORES
|
||||||
|
#endif // CONFIG_ESP_TIMER_ISR_AFFINITY_*
|
||||||
|
|
||||||
|
|
||||||
|
ESP_SYSTEM_INIT_FN(esp_timer_startup_init, SECONDARY, ESP_TIMER_INIT_MASK, 100)
|
||||||
{
|
{
|
||||||
return esp_timer_init();
|
return esp_timer_init();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user