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

Consider replacing the variable name PMU in examples with anything else #23

Closed
hybrid-orbital opened this issue Jul 5, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@hybrid-orbital
Copy link

Espressif defines a PMU variable declared as extern for some of their SOCs (in my case it was the ESP32H2):
https://github.com/espressif/esp-idf/blob/1cb4f3468d64c9e8bde196b15df37cbcd4b31395/components/soc/esp32h2/include/soc/pmu_struct.h#L761
This code is precompiled into the esp32-arduino-lib library installed by Arduino. If you run the example programs on these SOCs, everything will get messed up due to the global PMU variable.

I encountered this problem when debugging the sleep function of ESP32-H2. It took me some time to troubleshoot this issue because the compiler doesn't directly prompt the error.
The sleep-related functions of ESP32-H2 will reference the PMU variable, which will cause the sleep function to not run properly and cause core panic.
https://github.com/espressif/esp-idf/blob/1cb4f3468d64c9e8bde196b15df37cbcd4b31395/components/esp_hw_support/sleep_wake_stub.c#L71-L74
https://github.com/espressif/esp-idf/blob/1cb4f3468d64c9e8bde196b15df37cbcd4b31395/components/esp_hw_support/sleep_modes.c#L2060

This problem can be reproduced by running AXP2101_Sleep_Example.ino on ESP32-H2. Switch 'Core Debug Level' to 'Verbose' and it should show something like

Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
MEPC    : 0x40803bd8  RA      : 0x408058c8  SP      : 0x40817c50  GP      : 0x4080e194  
TP      : 0x40806dd8  T0      : 0x40003128  T1      : 0x40000038  T2      : 0x00000000  
S0/FP   : 0x80000000  S1      : 0x00000010  A0      : 0x4080e61c  A1      : 0x80000010  
A2      : 0x00000000  A3      : 0x40000000  A4      : 0x4080f090  A5      : 0x00000000  
A6      : 0x00000003  A7      : 0x00000037  S2      : 0x00000001  S3      : 0x00000000  
S4      : 0x004c494c  S5      : 0x00000001  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000001  S10     : 0x4080f74c  S11     : 0x00000000  
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000018  MTVAL   : 0x00008082  
MHARTID : 0x00000000  

and reboot

@lewisxhe
Copy link
Owner

lewisxhe commented Jul 8, 2024

I am not using the AXP2101 chip on the ESP32H2, thanks for your report, I will make the change

@lewisxhe lewisxhe added the enhancement New feature or request label Jul 8, 2024
lewisxhe added a commit that referenced this issue Jul 8, 2024
@lewisxhe
Copy link
Owner

lewisxhe commented Jul 8, 2024

Thanks for reminding me, the changes have been completed.

@lewisxhe lewisxhe closed this as completed Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants