diff --git a/components/esp_hw_support/component.mk b/components/esp_hw_support/component.mk index f0f472034f..2f762ab2b4 100644 --- a/components/esp_hw_support/component.mk +++ b/components/esp_hw_support/component.mk @@ -4,6 +4,7 @@ COMPONENT_ADD_LDFRAGMENTS := linker.lf ifdef IS_BOOTLOADER_BUILD COMPONENT_OBJEXCLUDE += clk_ctrl_os.o \ + esp_clk.o \ intr_alloc.o \ sleep_modes.o \ sleep_gpio.o \ diff --git a/components/esp_hw_support/esp_clk.c b/components/esp_hw_support/esp_clk.c index 591a33370b..3a10dfead9 100644 --- a/components/esp_hw_support/esp_clk.c +++ b/components/esp_hw_support/esp_clk.c @@ -8,6 +8,7 @@ #include #include +#include "freertos/FreeRTOS.h" #include "esp_attr.h" #include "soc/rtc.h" @@ -44,7 +45,7 @@ extern uint32_t g_ticks_per_us_app; #endif #endif -static _lock_t s_esp_rtc_time_lock; +static portMUX_TYPE s_esp_rtc_time_lock = portMUX_INITIALIZER_UNLOCKED; static RTC_DATA_ATTR uint64_t s_esp_rtc_time_us = 0, s_rtc_last_ticks = 0; inline static int IRAM_ATTR s_get_cpu_freq_mhz(void) @@ -86,7 +87,7 @@ void IRAM_ATTR ets_update_cpu_frequency(uint32_t ticks_per_us) uint64_t esp_rtc_get_time_us(void) { - _lock_acquire(&s_esp_rtc_time_lock); + portENTER_CRITICAL_SAFE(&s_esp_rtc_time_lock); const uint32_t cal = esp_clk_slowclk_cal_get(); const uint64_t rtc_this_ticks = rtc_time_get(); const uint64_t ticks = rtc_this_ticks - s_rtc_last_ticks; @@ -107,7 +108,7 @@ uint64_t esp_rtc_get_time_us(void) ((ticks_high * cal) << (32 - RTC_CLK_CAL_FRACT)); s_esp_rtc_time_us += delta_time_us; s_rtc_last_ticks = rtc_this_ticks; - _lock_release(&s_esp_rtc_time_lock); + portEXIT_CRITICAL_SAFE(&s_esp_rtc_time_lock); return s_esp_rtc_time_us; }