From f6fdfd4ee1be0e089798a40ae400d53617df2e1c Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Wed, 12 Jun 2024 17:40:26 -0300 Subject: [PATCH] soc: esp32c3: add systimer clock disable option When both MCUBoot and application run, systimer is initialized twice. As a consequence, application freezes as systimer new initialization conflicts with previous. This PR adds the systimer clock disable function, that shall be called before mcuboot jump to application, making sure it will work as expected. Fixes #74189 Signed-off-by: Sylvio Alves --- drivers/timer/Kconfig.esp32 | 1 + drivers/timer/esp32_sys_timer.c | 7 +++++++ west.yml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/timer/Kconfig.esp32 b/drivers/timer/Kconfig.esp32 index 0d45987c726..0634c3f0cb2 100644 --- a/drivers/timer/Kconfig.esp32 +++ b/drivers/timer/Kconfig.esp32 @@ -9,6 +9,7 @@ config ESP32_SYS_TIMER default y select TICKLESS_CAPABLE select TIMER_HAS_64BIT_CYCLE_COUNTER + select SYSTEM_TIMER_HAS_DISABLE_SUPPORT help This option enables the system timer driver for the Espressif ESP32Cx and provides the standard "system clock driver" interface. diff --git a/drivers/timer/esp32_sys_timer.c b/drivers/timer/esp32_sys_timer.c index 0fa888f6745..770a89edbdf 100644 --- a/drivers/timer/esp32_sys_timer.c +++ b/drivers/timer/esp32_sys_timer.c @@ -136,6 +136,13 @@ uint64_t sys_clock_cycle_get_64(void) return get_systimer_alarm(); } +void sys_clock_disable(void) +{ + systimer_ll_enable_alarm(systimer_hal.dev, SYSTIMER_ALARM_OS_TICK_CORE0, false); + systimer_ll_enable_alarm_int(systimer_hal.dev, SYSTIMER_ALARM_OS_TICK_CORE0, false); + systimer_hal_deinit(&systimer_hal); +} + static int sys_clock_driver_init(void) { diff --git a/west.yml b/west.yml index 10e7ec2a648..a5e7a78ff0b 100644 --- a/west.yml +++ b/west.yml @@ -157,7 +157,7 @@ manifest: groups: - hal - name: hal_espressif - revision: 0690c03f1540e8a5082da4c2b997e64bde8f4765 + revision: 4e38d8d9fe16d4d41736c1ffae6566001a624fca path: modules/hal/espressif west-commands: west/west-commands.yml groups: