EmotiBit / EmotiBit_FeatherWing

Firmware to run Emotibit with Adafruit feather M0 WiFi and Feather ESP32
MIT License
19 stars 8 forks source link

ESP32 crashing with DoubleBuffer implementation #297

Open nitin710 opened 4 months ago

nitin710 commented 4 months ago

Describe the bug ESP32 crashes randomly and consistently when running an implementation using double buffer. Generator ESP: I used this code to create precise GPIO toggle events.

Logger ESP: I used this code to log and measure the ISR events created by the first ESP32. The Logger prints ISR event times on the serial. It also toggles another GPIO on every "rising" transition of the input from the Generator ESP.

This does not happen when using a Feather M0. The logger code has been modified to accommodate flashing a Feather M0.

Note: The crashing stops if i comment out the doubleBuffer updates in the ISR. This is confirmed by the sq. wave generated by the logger ESP32.

Expected behavior The ESP32 used to log the GPIO should work without crashing.

Additional details

Core 1 register dump: PC : 0x400847aa PS : 0x00050d31 A0 : 0x800f2758 A1 : 0x3ffbef4c
A2 : 0x00000040 A3 : 0x00018040 A4 : 0x000637ff A5 : 0x3ffbef1c
A6 : 0x00000000 A7 : 0x3ffbdc38 A8 : 0x005015ab A9 : 0x40087fc0
A10 : 0x00000001 A11 : 0x80000001 A12 : 0x00000001 A13 : 0x3ffbeefc
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000e EXCCAUSE: 0x0000001c
EXCVADDR: 0x800f2764 LBEG : 0x400842e1 LEND : 0x400842e9 LCOUNT : 0x00000027

Backtrace:0x400847a7:0x3ffbef4c |<-CORRUPTED



**To Reproduce**
- Flash 2 ESP32's with the code linked above.
- Open Serial monitor and observe serial log.

**Compiled Binaries**
- You can use EmotiBit firmware installer to flash these binaries
[compiledBins.zip](https://github.com/EmotiBit/EmotiBit_FeatherWing/files/14338928/compiledBins.zip)
nitin710 commented 4 months ago

I don't think it is a "multi core" multi thread issue. Arduino programs ESP to run the code on Core-1 by deafult. The ISR is also running on core-1.

Unlike EmotiBit, we don't even create a "new task" that handles ISR. If it is an access violation, I'm not sure where it is coming from