ESP32 StoreProhibited: writing to an address that is not there

A StoreProhibited panic is the write side of LoadProhibited: the CPU tried to store a value at an address that is not writable memory. The cause is a pointer or an index you can find from the backtrace.

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

Core  0 register dump:
PC      : 0x400d2f1a  PS      : 0x00060830  A0      : 0x800d3044  A1      : 0x3ffbb2c0
...
EXCVADDR: 0x00000000

Backtrace: 0x400d2f17:0x3ffbb2c0 0x400d3041:0x3ffbb2e0 0x4008a1b2:0x3ffbb300

On RISC-V chips (ESP32-C3, C6, H2 and others) it is Store access fault, with the address in MTVAL.

Read EXCVADDR first

The register dump has the address the CPU tried to write in EXCVADDR (in MTVAL on RISC-V chips). It tells you most of the story:

The usual causes

Find the line

The Backtrace: line is a list of PC:SP pairs, innermost call first. To turn the addresses into functions and lines you need the ELF of exactly the build that crashed:

When it happens in the field

On your desk the crash prints to the serial monitor. On a device in someone else's building it prints to a port nobody is reading, the chip restarts, and all you hear is that it "sometimes hangs". Pinscope keeps the panic reason and backtrace across the restart, sends them on the next connection and decodes them with the ELF of the build that crashed, so you get the function and line without anyone at the device. Free for three devices. How crash reporting from the field works.

Related errors: LoadProhibited · CORRUPT HEAP · Stack overflow · IllegalInstruction. All ESP32 errors: the list. Messages and causes from ESP-IDF's panic handler and Espressif's Fatal Errors guide.

More