From ccb4b0665c322582a4e6d79bc2c67e93a1b9e5e1 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 7 Jan 2024 11:24:01 +0000 Subject: [PATCH 1/4] Fix ESP32 hw_timer2_read() Without setting update bit counter value won't change. Probably worked previously because some other code did this. --- Sming/Arch/Esp32/Components/driver/include/driver/hw_timer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Sming/Arch/Esp32/Components/driver/include/driver/hw_timer.h b/Sming/Arch/Esp32/Components/driver/include/driver/hw_timer.h index 8f2a7e2ccd..1979b45072 100644 --- a/Sming/Arch/Esp32/Components/driver/include/driver/hw_timer.h +++ b/Sming/Arch/Esp32/Components/driver/include/driver/hw_timer.h @@ -147,6 +147,7 @@ uint32_t hw_timer1_read(void); __forceinline static uint32_t hw_timer2_read(void) { #if CONFIG_ESP_TIMER_IMPL_TG0_LAC + REG_WRITE(TIMG_LACTUPDATE_REG(0), 1); return REG_READ(TIMG_LACTLO_REG(0)); #elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) systimer_ll_counter_snapshot(&SYSTIMER, 0); From 1d317edc0c760e88d730a22428aed0525ee547a6 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 7 Jan 2024 12:09:04 +0000 Subject: [PATCH 2/4] Fix WDT with callback timers --- Sming/Arch/Esp32/Components/driver/hw_timer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sming/Arch/Esp32/Components/driver/hw_timer.cpp b/Sming/Arch/Esp32/Components/driver/hw_timer.cpp index 9b5cc202dc..8ab470c5b0 100644 --- a/Sming/Arch/Esp32/Components/driver/hw_timer.cpp +++ b/Sming/Arch/Esp32/Components/driver/hw_timer.cpp @@ -62,7 +62,8 @@ class TimerConfig #else int source = timer_group_periph_signals.groups[group].timer_irq_id[index]; #endif - esp_intr_alloc_intrstatus(source, ESP_INTR_FLAG_IRAM, status_reg, mask, timerIsr, this, &isr_handle); + esp_intr_alloc_intrstatus(source, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_INTRDISABLED, status_reg, mask, timerIsr, + this, &isr_handle); clear_intr_status(); enable_intr(true); } From aa925a5bac66ed44066282b394305b5fecf42ff7 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 7 Jan 2024 23:08:31 +0000 Subject: [PATCH 3/4] HostTests needs more program space for ESP32 --- tests/HostTests/host-tests-esp32.hw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/HostTests/host-tests-esp32.hw b/tests/HostTests/host-tests-esp32.hw index d8b9c308fa..f56f5bd7c9 100644 --- a/tests/HostTests/host-tests-esp32.hw +++ b/tests/HostTests/host-tests-esp32.hw @@ -3,7 +3,7 @@ "base_config": "host-tests", "partitions": { "factory": { - "size": "1M" + "size": "1600K" } } } From 126739b258720562cfa9ae55738474102890f775 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 7 Jan 2024 16:05:11 +0000 Subject: [PATCH 4/4] Default timer copy constructor causing weird issues e.g. ``` String s; s += timer; ``` Doesn't behave as expected and instead constructs new instance then calls destructor on it. Manifests by hanging HostTests on esp32 (standard, s2 and c3 variants) but curiously not on esp8266 or host. --- Sming/Core/CallbackTimer.h | 7 ++++++- tests/HostTests/modules/Timers.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Sming/Core/CallbackTimer.h b/Sming/Core/CallbackTimer.h index 9844c6ed86..f56ef2dc58 100644 --- a/Sming/Core/CallbackTimer.h +++ b/Sming/Core/CallbackTimer.h @@ -33,6 +33,12 @@ template struct CallbackTimerApi { return ApiDef::typeName(); } + CallbackTimerApi() + { + } + + CallbackTimerApi(const CallbackTimerApi&) = delete; + String name() const { String s; @@ -50,7 +56,6 @@ template struct CallbackTimerApi { s += static_cast(this)->getInterval(); s += ", ticks = "; s += static_cast(this)->ticks(); - // s += ApiDef::Clock::ticks(); return s; } diff --git a/tests/HostTests/modules/Timers.cpp b/tests/HostTests/modules/Timers.cpp index 5e0eda4fba..2dc7bb638c 100644 --- a/tests/HostTests/modules/Timers.cpp +++ b/tests/HostTests/modules/Timers.cpp @@ -81,7 +81,7 @@ class CallbackTimerTest : public TestGroup String s; s += system_get_time(); s += " "; - s += statusTimer; + s += String(statusTimer); s += " fired, timercount = "; s += activeTimerCount; s += ", mem = ";