machine.SDCard() fails with OSError: 16 on ESP32-P4 (ESP32_GENERIC_P4 firmware) (Micropython) #188887
ESP32-P4
|
Replies: 5 comments 6 replies
|
OSError: 16 is EBUSY — the driver is trying to claim a peripheral that's already in use or not properly released. On the ESP32-P4 this almost certainly means SDMMC support in ESP32_GENERIC_P4 firmware is incomplete or misconfigured for the built-in slot. 1. Force SPI mode with explicit pins (most reliable workaround right now):
Adjust the pin numbers to match your board's pinout — check your ESP32-P4 board schematic for the SD SPI pins. 2. Add a soft reset before initialising:
Sometimes the SDMMC peripheral isn't released cleanly on boot. 4. Check firmware maturity — ESP32-P4 MicroPython support is still relatively new. Check the [MicroPython ESP32 port changelog] (https://github.com/micropython/micropython/blob/master/CHANGELOG.md) and consider building from the latest master branch, as P4 SDMMC fixes may not be in a stable release yet. 5. Report upstream — If SPI mode works but native SDMMC doesn't, this is worth filing as a bug at [micropython/micropython] with (https://github.com/micropython/micropython/issues) test results. The P4 port is actively being developed and your findings would be valuable. |
|
Since you’ve confirmed the hardware is strictly wired for SDMMC and the standard software resets aren't clearing the OSError: 16, it appears we’ve reached the limits of current firmware support. The 'Busy' error on the P4 usually points to a pending fix needed in the MicroPython C-source for this specific port’s IOMUX or power domain initialization. Since we’ve narrowed it down to a driver/firmware limitation rather than a configuration error, could you please mark this as 'Answered' so it can help others troubleshooting the P4 and It will also help the community track which peripherals still need active development. Best of luck with the rest of your project 👍 |
|
It looks like the issue may be related to the ESP32-P4 MicroPython port rather than the SD card itself. Since the same card and code work correctly on an ESP32 DevKit v2, the OSError: 16 suggests that the SD interface is either not initialized properly or not yet fully supported on the current ESP32_GENERIC_P4 firmware. I would recommend testing with the latest nightly build and checking whether the board's built-in SD card reader is currently supported by the ESP32-P4 MicroPython port. This seems more like a firmware or driver limitation than a hardware fault. |
|
ESP32-P4 has an internal voltage regulator (LDO) architecture that requires enabling the correct LDO channel before it's possible to access the SD card. In MicroPython nightly builds (and the next release v1.29) the correct LDO channel is enabled automatically, so SDCard should work normally. (Details). In MicroPython v1.28 we have support for the ESP32-P4 LDO but it's not automatically integrated with import machine, esp32, vfs
ldo = esp32.LDO(4, 3300)
# then use the SDCard normally, i.e.
vfs.mount(machine.SDCard(), "/sd")(The workaround may need to be removed after you update to MicroPython v1.29.) |
|
Problem is solved |
ESP32-P4 has an internal voltage regulator (LDO) architecture that requires enabling the correct LDO channel before it's possible to access the SD card.
In MicroPython nightly builds (and the next release v1.29) the correct LDO channel is enabled automatically, so SDCard should work normally. (Details).
In MicroPython v1.28 we have support for the ESP32-P4 LDO but it's not automatically integrated with
machine.SDCard()yet. You can work around it on MicroPython v1.28 like this:(The workaround may need to be removed after you update to MicroPython v1.29.)