Component
UART / drvUartPm25 (PM2.5 AQI driver)
Summary
drvUartPm25::begin() dereferences _pm25 without ever allocating it, causing a null-pointer dereference the first time a PM2.5 (PMS5003 / PM1006) sensor is added over UART. On ESP32-C5 this manifests as a Guru Meditation Error: Load access fault (MCAUSE=5, A0=0x0, MTVAL=0x8) roughly 3 s after the UART Add (immediately after the driver's boot delay), which then boot-loops the device.
Details
In src/components/uart/drivers/drvUartPm25.h, the member is declared but never constructed:
bool begin() override {
delay(3 * ONE_SECOND_IN_MS); // wait for the sensor to boot
return _pm25->begin_UART(_hw_serial); // _pm25 is still nullptr here
}
// ...
Adafruit_PM25AQI *_pm25 = nullptr; // never assigned via new
The sibling I2C driver src/components/i2c/drivers/drvPm25.h does the allocation correctly (_pm25 = new Adafruit_PM25AQI(); at the top of begin()); the UART driver was simply missing that line. The existing destructor already deletes _pm25, so it always expected a heap instance.
Steps to reproduce
- Flash a build that includes the UART component.
- Send a UART
Add with cfg_device.pm25aqi (e.g. a PMS5003, PID 3686).
- Device prints
[uart] Added PM2.5 AQI device!, then panics ~3 s later.
Reproduced on HIL with a LilyGO T-Dongle C5 (ESP32-C5) and a PMS5003 on the UART0 pads:
[uart] Added PM2.5 AQI device!
Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.
MCAUSE : 0x00000005 MTVAL : 0x00000008 A0 : 0x00000000
Fix
Allocate _pm25 in begin() before use, mirroring the I2C driver.
Component
UART /
drvUartPm25(PM2.5 AQI driver)Summary
drvUartPm25::begin()dereferences_pm25without ever allocating it, causing a null-pointer dereference the first time a PM2.5 (PMS5003 / PM1006) sensor is added over UART. On ESP32-C5 this manifests as aGuru Meditation Error: Load access fault(MCAUSE=5,A0=0x0,MTVAL=0x8) roughly 3 s after the UARTAdd(immediately after the driver's boot delay), which then boot-loops the device.Details
In
src/components/uart/drivers/drvUartPm25.h, the member is declared but never constructed:The sibling I2C driver
src/components/i2c/drivers/drvPm25.hdoes the allocation correctly (_pm25 = new Adafruit_PM25AQI();at the top ofbegin()); the UART driver was simply missing that line. The existing destructor alreadydeletes_pm25, so it always expected a heap instance.Steps to reproduce
Addwithcfg_device.pm25aqi(e.g. a PMS5003, PID 3686).[uart] Added PM2.5 AQI device!, then panics ~3 s later.Reproduced on HIL with a LilyGO T-Dongle C5 (ESP32-C5) and a PMS5003 on the UART0 pads:
Fix
Allocate
_pm25inbegin()before use, mirroring the I2C driver.api-v2-pins-as-strings)