espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.11k stars 7.31k forks source link

Unusual crash on the ESP wifi adapter when reading an analog value from IO 6 #8356

Open aeonSolutions opened 1 year ago

aeonSolutions commented 1 year ago

Board

Custom ESP32 S3 based

Device Description

This is a custom PCB using ESP32 S3 MCU for data acquisition

Hardware Configuration

I2C bus includes a AHT20 sensor, a LSM6DS3 sensor and a ATSHA204 IC. It has 16MB of flash storage from WInBond and 8MB of PSRAM.

Version

latest master (checkout manually)

IDE Name

Arduino IDE 1.8

Operating System

Windows 11

Flash frequency

240Mhz

PSRAM enabled

yes

Upload speed

115200

Description

The crash happened when requesting analogRead from GPIO 6 The crash

Sketch

anyone can find the code on my Repository here:
https://github.com/aeonSolutions/openScience-Smart-DAQ-to-Upload-Live-Experimental-Data-to-a-Data-Repository/tree/main/Firmware%20Code

in particular in the file `measurements.cpp` class function `void MEASUREMENTS::runExternalMeasurements();`

Debug Message

Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4038647c  PS      : 0x00060933  A0      : 0x80386c68  A1      : 0x3fcabdc0  
A2      : 0x3d800014  A3      : 0x3d803e44  A4      : 0x00000003  A5      : 0x00000018  
A6      : 0x00060720  A7      : 0x00000001  A8      : 0x00000017  A9      : 0x0000001f  
A10     : 0x3d803e5c  A11     : 0x3d800c78  A12     : 0x3d800038  A13     : 0x3d80007c  
A14     : 0x3d803e4c  A15     : 0x00000005  SAR     : 0x00000018  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x0000000f  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0xffffffff  

Backtrace: 0x40386479:0x3fcabdc0 0x40386c65:0x3fcabde0 0x40386e98:0x3fcabe00 0x4037840d:0x3fcabe20 0x403784de:0x3fcabe50 0x40378169:0x3fcabea0 0x420f9147:0x3fcabec0 0x42101523:0x3fcabee0 0x420fed15:0x3fcabf00 0x42062032:0x3fcabf20

ELF file SHA256: dc7ae69a6b0d0826

using the Exception decoder the error above error is pointing at

PC: 0x4038647c: tlsf_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_tlsf.c line 237
EXCVADDR: 0x0000000f

Decoding stack results
0x40386479: tlsf_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_tlsf.c line 235
0x40386c65: multi_heap_malloc_impl at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap.c line 200
0x40386e98: multi_heap_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap_poisoning.c line 230
0x4037840d: heap_caps_malloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c line 154
0x403784de: heap_caps_malloc_prefer at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c line 269
0x40378169: wifi_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_wifi/esp32s3/esp_adapter.c line 71
0x42062032: timer_task at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_timer/src/esp_timer.c line 360


### Other Steps to Reproduce

anyone can find the code on my Repository here:
https://github.com/aeonSolutions/openScience-Smart-DAQ-to-Upload-Live-Experimental-Data-to-a-Data-Repository/tree/main/Firmware%20Code

in particular in the file `measurements.cpp` class function `void MEASUREMENTS::runExternalMeasurements();`

### I have checked existing issues, online documentation and the Troubleshooting Guide

- [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.
mrengineer7777 commented 1 year ago

Your code is too complicated to troubleshoot. Create a separate project that demonstrates the issue.

I will note that ADC2 and WiFi cannot be used at the same time on the ESP32, but that may not be an issue on S3.

TD-er commented 1 year ago

I will note that ADC2 and WiFi cannot be used at the same time on the ESP32, but that may not be an issue on S3.

Yep, it still is an issue on ESP32-S3.

ADC2 – no restrictions, unless there is an on-going Wi-Fi connection. ADC2_CH… analog functions (see Table 2-4 RTC and Analog Pin Functions) cannot be used with Wi-Fi simultaneously.

ESP32-S3 datasheet page 20

However the pin mentioned here in the title of this issue should be connected to ADC1, so that should not be related to WiFi activities.