SerialBT.available() throws exception

proggi_DE
Posts: 4
Joined: Tue Oct 01, 2019 1:52 pm

SerialBT.available() throws exception

Postby proggi_DE » Tue Nov 29, 2022 11:36 pm

Hello,
I have a code, that regularly (every 5ms) calls a function from loop(), that decodes incoming serial protocols from SerialBT. Before reading the buffer it is checked by SerialBT.available() to go on with reading and decoding state machine.

The ESP32 WROOM-32E throws:
Guru Meditation Error: Core 1 panic'ed (LoadStoreAlignment). Exception was unhandled.
Core 1 register dump:
PC : 0x40092186 PS : 0x00060133 A0 : 0x80091084 A1 : 0x3ffc8780
A2 : 0x3ffbac59 A3 : 0x0000abab A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060120 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0x3ffc8770
A10 : 0x00000000 A11 : 0x3ffc88fc A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060520 A15 : 0x00000000 SAR : 0x00000018 EXCCAUSE: 0x00000009
EXCVADDR: 0x3ffbac59 LBEG : 0x4000c28c LEND : 0x4000c296 LCOUNT : 0x00000000

ELF file SHA256: 0000000000000000

Backtrace: 0x40092186:0x3ffc8780 0x40091081:0x3ffc87b0 0x400d3ffd:0x3ffc87d0 0x400d1775:0x3ffc87f0 0x400d2a8b:0x3ffc8810 0x400d6da0:0x3ffc8840 0x4009116a:0x3ffc8860

The exception decoder outputs the following:
Decoding stack results:
0x40092186: vTaskEnterCritical at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/include/freertos/portmacro.h line 353
0x40091081: uxQueueMessagesWaiting at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 1749
0x400d3ffd: BluetoothSerial::available() at C:\Users\user\.platformio\packages\framework-arduinoespressif32\libraries\BluetoothSerial\src\BluetoothSerial.cpp line 670
0x400d1775: ProcessProt(unsigned char) at src\prot.cpp line 210
0x400d2a8b: loop() at src\main.cpp line 1174
0x400d6da0: loopTask(void*) at C:\Users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32\main.cpp line 23
0x4009116a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

The exceptions are different, sometimes LoadStoreAlignment, sometimes LoadProhibited, sometimes abort() called.

Generally the firmware does what it should do but it crashes after unpredictable times. I cannot isolate the condition when it throws. Sometimes is runs for several minutes up to hours without exception. After another start it crashes after 2 minutes.
All exception decoding points to the SerialBT.available(). Occurs with and without active Bluetooth connection.

Code is made with VisualStudioCode, PlatformIO, Arduino framework.

Would be really glad if somebody could help.
Thanks

proggi_DE
Posts: 4
Joined: Tue Oct 01, 2019 1:52 pm

Re: SerialBT.available() throws exception

Postby proggi_DE » Fri Dec 02, 2022 12:39 am

Another exception decoding, this time "StoreProhibited"

Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40092176 PS : 0x00060333 A0 : 0x80091074 A1 : 0x3ffc87b0
A2 : 0x06000092 A3 : 0x0000abab A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060320 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0x7860c000
A10 : 0x00000bf7 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x0000000e
A14 : 0x00000000 A15 : 0x3ffc87cc SAR : 0x0000001d EXCCAUSE: 0x0000001d
EXCVADDR: 0x06000092 LBEG : 0x400029ac LEND : 0x400029cb LCOUNT : 0x00000000

ELF file SHA256: 0000000000000000

Backtrace: 0x40092176:0x3ffc87b0 0x40091071:0x3ffc87e0 0x400d3fc1:0x3ffc8800 0x400d177c:0x3ffc8820 0x400d2a12:0x3ffc8840 0x400d6d90:0x3ffc8870 0x4009115a:0x3ffc8890
#0 0x40092176:0x3ffc87b0 in uxPortCompareSet at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
(inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.inc.h:86
(inlined by) vPortCPUAcquireMutexIntsDisabled at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.h:98
(inlined by) vTaskEnterCritical at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:4201
#1 0x40091071:0x3ffc87e0 in uxQueueMessagesWaiting at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:2520
#2 0x400d3fc1:0x3ffc8800 in BluetoothSerial::available() at C:\Users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32/WString.h:48
#3 0x400d177c:0x3ffc8820 in ProcessProt(unsigned char) at src/prot.cpp:211
#4 0x400d2a12:0x3ffc8840 in loop() at src/main.cpp:1153
#5 0x400d6d90:0x3ffc8870 in loopTask(void*) at C:\Users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:23
#6 0x4009115a:0x3ffc8890 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

Same as above. It has to do with the uxQueueMessagesWaiting in BluetoothSerial.available().

Tried to remove this function call and used BluetoothSerial.read instead, with -1 as break condition, same result.
Help appeciated....

Who is online

Users browsing this forum: No registered users and 75 guests