I'm using an ESP32-based µC board (Olimex ESP32-SBC-FabGL) together with the Arduino 1.8.19 IDE. Now I'd like to access the GPIO and I²C pins on the CH32V003 on-board port expander. Using FabGL ad the driver developed by Olimex, however, always provokes a crash when calling its begin()
method. I call this method like this:
Terminal::Terminal()
: m_canvas(nullptr),
m_mutex(nullptr),
m_soundGenerator(nullptr),
m_sprites(nullptr),
m_spritesCount(0),
m_mux ()
{
if (s_activeTerminal == nullptr)
s_activeTerminal = this;
}
bool Terminal::begin(BaseDisplayController * displayController, int maxColumns, int maxRows, Keyboard * keyboard)
{
// irrelevant code omitted
bool success = m_mux -> begin (); // TROUBLE
return success;
}
I get such an error message and call trace:
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400e52b5 PS : 0x00060c30 A0 : 0x800de86c A1 : 0x3ffc66a0
A2 : 0x00000000 A3 : 0x00000023 A4 : 0x00000001 A5 : 0x0000000e
A6 : 0x0000000d A7 : 0x00000001 A8 : 0x0000000c A9 : 0x3ffc66d0
A10 : 0x00000001 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x3ffdffec A15 : 0x00000000 SAR : 0x00000018 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4008aad9 LEND : 0x4008aafb LCOUNT : 0xffffffff
Backtrace: 0x400e52b2:0x3ffc66a0 0x400de869:0x3ffc6730 0x400d2dc6:0x3ffc6760 0x400d43a4:0x3ffc6780 0x400f362e:0x3ffc67b0
The exception decoder translates this data into such an output:
PC: 0x400e52b5: CH32V003::begin(gpio_num_t, gpio_num_t, gpio_num_t, gpio_num_t, short, short) at /home/jacek/Arduino/libraries/OLIMEX-FABGL/src/devdrivers/CH32V003.cpp line 84
EXCVADDR: 0x00000000
Decoding stack results
0x400e52b2: CH32V003::begin(gpio_num_t, gpio_num_t, gpio_num_t, gpio_num_t, short, short) at /home/jacek/Arduino/libraries/OLIMEX-FABGL/src/devdrivers/CH32V003.cpp line 82
0x400de869: fabgl::Terminal::begin(fabgl::BaseDisplayController*, int, int, fabgl::Keyboard*) at /home/jacek/Arduino/libraries/OLIMEX-FABGL/src/terminal.cpp line 407
0x400d2dc6: ConfDialogApp::setupDisplay() at /home/jacek/Arduino/libraries/OLIMEX-FABGL/examples/VGA/AnsiTerminal/confdialog.h line 645
0x400d43a4: setup() at /home/jacek/Arduino/libraries/OLIMEX-FABGL/examples/VGA/AnsiTerminal/AnsiTerminal.ino line 108
0x400f362e: loopTask(void*) at /home/jacek/.arduino15/packages/esp32/hardware/esp32/2.0.11/cores/esp32/main.cpp line 42
Neither do I have any expertise in ESP32 error messages, nor am I the developer of the CH32V003 driver. So: What do these error messages mean? And: Do I have the chance to circumvent this error somehow?
StoreProhibited indicated that your program tried to write to invalid memory. The EXCVADDR indicates the address that was being written to. In your case, this is 0x00000000, meaning a null pointer. In all likelihood it means that your m_mux pointer is a null pointer - you haven’t initialized it. You’ll need to construct a valid driver object first - e.g. using m_mux = new CH32V003();
- before attempting to call begin() on it.
The exceptions and what they mean are all documented here: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/fatal-errors.html