Code only works once, until reset
gigawatts opened this issue · 0 comments
This sketch only seems to work once. Let me explain.
I flash your code, unmodified, to an ESP32 (in this case, its a CAN32 board, using a ESP32-WROOM-32U module, using the SparkFun ESP32 Thing board profile in the Arduino IDE), it starts fine. I connect to it from a phone, and I can send/receive messages without any issues. I can disconnect from the ESP AP, reconnect, and it still works. So far so good.
However, If I restart the ESP32 (reset button or power cycle), as soon as my phone tries to reconnect to it, I get the following error over and over in the serial term:
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10044
load:0x40080400,len:5900
entry 0x400806ac
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00000000 PS : 0x00060e30 A0 : 0x80107389 A1 : 0x3ffcc720
A2 : 0x3ffd6ff8 A3 : 0x3ffd77e8 A4 : 0x3ffd6df8 A5 : 0x3ffd6cf8
A6 : 0x0201a8c0 A7 : 0x0c01a8c0 A8 : 0x8010722c A9 : 0x3ffcc6e0
A10 : 0x3ffd7008 A11 : 0x3ffd77e8 A12 : 0x3ffcc72c A13 : 0x00000044
A14 : 0x00000001 A15 : 0x00000006 SAR : 0x00000010 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000
Backtrace: 0x00000000:0x3ffcc720 0x40107386:0x3ffcc760 0x40115261:0x3ffcc780 0x4011a1e9:0x3ffcc7c0 0x4011f4a2:0x3ffcc7e0 0x40107d8f:0x3ffcc800 0x4008e0b9:0x3ffcc830
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10044
load:0x40080400,len:5900
entry 0x400806ac
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00000000 PS : 0x00060e30 A0 : 0x80107389 A1 : 0x3ffcc720
A2 : 0x3ffd79e0 A3 : 0x3ffd83d0 A4 : 0x3ffd7cb4 A5 : 0x3ffd7c94
A6 : 0x0201a8c0 A7 : 0x0c01a8c0 A8 : 0x8010722c A9 : 0x3ffcc6e0
A10 : 0x3ffd79f0 A11 : 0x3ffd83d0 A12 : 0x3ffcc72c A13 : 0x00000044
A14 : 0x00000001 A15 : 0x00000006 SAR : 0x00000010 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000
Backtrace: 0x00000000:0x3ffcc720 0x40107386:0x3ffcc760 0x40115261:0x3ffcc780 0x4011a1e9:0x3ffcc7c0 0x4011f4a2:0x3ffcc7e0 0x40107d8f:0x3ffcc800 0x4008e0b9:0x3ffcc830
Rebooting...
If I turn off WiFi on my phone, so it does not attempt a connection, the sketch boots fine, but repeats the boot loop seen above as soon as a client tries to connect again.
The only way I have found to get the code to work again (once) is to erase the ESP32's flash with esptool.py --port COM3 erase_flash
, then flash the code to the ESP32 again. Again, that only works once, until the board is reset.
Update: After typing up all of the above, I found this, which seems extremely relevant: espressif/arduino-esp32#2025 (comment)
And it seems this suggestion fixes the problem: espressif/arduino-esp32#2025 (comment)