power: release PMU devices before deleting the i2c bus on M5CoreS3
What changed, and why it matters
This commit fixes a boot failure on the M5CoreS3 hardware. A recent update to the underlying Espressif SDK (ESP-IDF v5.5) changed the rules for deleting an I2C bus: it now refuses to delete a bus that still has devices attached. The power initialization code was attaching two power-management chips to the bus and then trying to delete the bus without detaching them first, causing the device to abort boot. The fix simply detaches those two devices before deleting the bus. There is no security vulnerability here—it's a compatibility/bug fix for a crash-on-boot scenario.
No security action required. Treat as a normal hardware-compatibility bug fix. Verify on M5CoreS3 hardware when available, and consider auditing other I2C bus teardown paths for similar missing device-removal calls under ESP-IDF v5.5+.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In main/power/m5stackcores3.inc, power_init() initializes axp2101 and aw9523 PMU devices on the I2C master bus. Previously it called _i2c_deinit() (which calls i2c_del_master_bus()) without first removing those attached devices. Starting with ESP-IDF v5.5, i2c_del_master_bus() returns ESP_ERR_INVALID_STATE when devices are still attached. The error propagated back to power_init(), which returned ESP_ERR_INVALID_STATE, triggering a JADE_ASSERT in main.c and aborting boot. The patch adds i2c_master_bus_rm_device() calls for axp2101 and aw9523 before _i2c_deinit(), mirroring a similar touchscreen fix in the preceding commit. This is a device-driver lifecycle fix, not a memory-safety or logic bug exploitable by an attacker.
Changed components
main/power/m5stackcores3.incM5CoreS3 power initializationaxp2101/aw9523 I2C device lifecycleInspect captured patch +3 / −0
diff --git a/main/power/m5stackcores3.inc b/main/power/m5stackcores3.inc
index 45c900a..390fd13 100644
--- a/main/power/m5stackcores3.inc
+++ b/main/power/m5stackcores3.inc
@@ -48,6 +48,9 @@ esp_err_t power_init(void)
axp2101_init();
vTaskDelay(100 / portTICK_PERIOD_MS);
+ // Since IDF 5.5 the i2c bus cannot be deleted while devices are still attached
+ I2C_CHECK_RET(i2c_master_bus_rm_device(axp2101));
+ I2C_CHECK_RET(i2c_master_bus_rm_device(aw9523));
I2C_CHECK_RET(_i2c_deinit(NULL));
return ESP_OK;
Why this scored 26/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.