Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFS + CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256=y causes reading ADC hang (IDFGH-6499) #8152

Closed
AxelLin opened this issue Dec 28, 2021 · 9 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@AxelLin
Copy link
Contributor

AxelLin commented Dec 28, 2021

Environment

  • Module or chip used: ESP32-WROOM-32E
  • IDF version: v4.3.2-106-g8a7b2f326b
  • Build System: idf.py
  • Compiler version: xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2) 8.4.0
  • Operating System: Linux
  • Power Supply: USB

Problem Description

DFS + CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256=y causes reading ADC hang

Steps to reproduce

Use examples/wifi/power_save snip code to reproduce the issue:

  1. Set ESP32_RTC_CLK_SRC_INT_8MD256=y
  2. Add below code for reading adc1
diff --git a/examples/wifi/power_save/main/power_save.c b/examples/wifi/power_save/main/power_save.c
index 4ad924665c..2d4a985165 100644
--- a/examples/wifi/power_save/main/power_save.c
+++ b/examples/wifi/power_save/main/power_save.c
@@ -19,6 +19,7 @@
 #include "esp_event.h"
 #include "esp_pm.h"
 #include "nvs_flash.h"
+#include "driver/adc.h"
 
 /*set the ssid and password via "idf.py menuconfig"*/
 #define DEFAULT_SSID CONFIG_EXAMPLE_WIFI_SSID
@@ -81,6 +82,19 @@ static void wifi_power_save(void)
     esp_wifi_set_ps(DEFAULT_PS_MODE);
 }
 
+static void test_adc(void)
+{
+    int adc_val;
+    adc1_config_width(ADC_WIDTH_BIT_12);
+    adc_gpio_init(ADC_UNIT_1, ADC1_CHANNEL_0);
+    adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);
+
+    vTaskDelay(pdMS_TO_TICKS(50));
+
+    adc_val = adc1_get_raw(ADC1_CHANNEL_0);
+    ESP_LOGI(TAG, "ADC val: %d", adc_val);
+}
+
 void app_main(void)
 {
     // Initialize NVS
@@ -111,5 +125,7 @@ void app_main(void)
     ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
 #endif // CONFIG_PM_ENABLE
 
+// Test reading adc
+     test_adc();
     wifi_power_save();
 }
  1. build the power_save and run
    Then observe device hang at below:
    ...
    I (590) cpu_start: Starting scheduler on PRO CPU.
    I (0) cpu_start: Starting scheduler on APP CPU.
    I (877) pm: Frequency switching co

Also note comment out below code can make CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256=y work.
https://github.com/espressif/esp-idf/blob/release/v4.3/components/esp_hw_support/port/esp32/rtc_sleep.c#L196-L202
Looks like 73384ad is the bad commit.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 28, 2021
@github-actions github-actions bot changed the title DFS + CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256=y causes reading ADC hang DFS + CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256=y causes reading ADC hang (IDFGH-6499) Dec 28, 2021
@AxelLin
Copy link
Contributor Author

AxelLin commented Dec 28, 2021

BTW, when I test DFS + wifi, sometimes I got below error message:

E (19377) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz
E (28126) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz

Does that mean something wrong in my configuration?
Or I can just ignore it? (The device seems still working)

@negativekelvin
Copy link
Contributor

#8089

@AxelLin
Copy link
Contributor Author

AxelLin commented Dec 28, 2021

#8089

Above PR fixes the issue, thanks.

@AxelLin
Copy link
Contributor Author

AxelLin commented Dec 29, 2021

BTW, when I test DFS + wifi, sometimes I got below error message:

E (19377) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz E (28126) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz

Does that mean something wrong in my configuration? Or I can just ignore it? (The device seems still working)

I found the device shows below messages today:
E (36759743) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 80000000Hz
E (37138888) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 80000000Hz
E (37233375) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 80000000Hz
E (37354657) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz
E (37577531) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 80000000Hz

I'm confused, isn't 80MHz == 80000000Hz?

@AxelLin
Copy link
Contributor Author

AxelLin commented Dec 29, 2021

BTW, when I test DFS + wifi, sometimes I got below error message:

E (19377) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz E (28126) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz

Above message only happens on v4.3 branch, it does not happen on v4.4 or master tree.
#8162 (comment) fixes above error message on v4.3.

Edit: 496f2a5 fixed above error message on v4.3.

@esp-lis
Copy link
Collaborator

esp-lis commented Mar 24, 2022

BTW, when I test DFS + wifi, sometimes I got below error message:

E (19377) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz E (28126) wifi_apb80m_request: WiFi needs 80MHz APB frequency to work, but got 40000000Hz

Does that mean something wrong in my configuration? Or I can just ignore it? (The device seems still working)

I summarize the commits that fix this issue on 4.1, 4.2, 4.3, 4.4 as follows:
4.4 or master: 75a1942
4.3 ae84265
4.2 ebee6f3
4.1 2ed9685

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Mar 24, 2022
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, feel free to reopen.

@AxelLin
Copy link
Contributor Author

AxelLin commented Mar 25, 2022

The #8152 (comment) fixes the error mesage.
However it still hang unless applying #8089 .

@AxelLin
Copy link
Contributor Author

AxelLin commented Mar 25, 2022

@Alvin1Zhang @esp-lis
It's fine to close this one and trace #8007 instead.
However, nobody responses with #8007 .

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: In Progress Work is in progress labels Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

5 participants