Skip to content

esp32s3: pr 91027 results in 'periph_rtc_dig_clk8m_get_freq()' returning zero #93668

@havoc-dlt

Description

@havoc-dlt

Describe the bug

Just confirmed with zephyr ref 2a88cb5 on my custom esp32s3 hardware:

Since PR 91027 was merged, the ledc pwm clock source selection uses RC_FAST automatically. Since I don't have the I2C drivers enabled and thus preventing periph_rtc_dig_clk8m_enable() from ever getting called, the line 162 channel->clock_src_hz = periph_rtc_dig_clk8m_get_freq(); sets clock_src_hz to zero in pwm_led_esp32_timer_config().
This makes the pwm code print errors to the log and prevents it from working.

My current workaround is to patch components/esp_hw_support/clk_ctrl_os.c like this:

diff --git a/components/esp_hw_support/clk_ctrl_os.c b/components/esp_hw_support/clk_ctrl_os.c
index 14ba0446d1..7a9989fb26 100644
--- a/components/esp_hw_support/clk_ctrl_os.c
+++ b/components/esp_hw_support/clk_ctrl_os.c
@@ -46,6 +46,11 @@ uint32_t periph_rtc_dig_clk8m_get_freq(void)
     /* Workaround: CLK8M calibration cannot be performed, we can only return its theoretic value */
     return SOC_CLK_RC_FAST_FREQ_APPROX;
 #else
+#if SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
+    if (s_rc_fast_freq == 0) {
+        s_rc_fast_freq = esp_clk_tree_rc_fast_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_EXACT);
+    }
+#endif
     return s_rc_fast_freq;
 #endif
 }

Regression

  • This is a regression.

Steps to reproduce

  1. compile the blinky pwm sample with logging on zephyr version >= v4.2.0 on any esp32s3 board
  2. start debugging with espressif monitor
  3. observe the error messages and the non-working pwm

Relevant log output

Impact

Functional Limitation

Environment

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugThe issue is a bug, or the PR is fixing a bugplatform: ESP32Espressif ESP32

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions