esp-idf-svc 0.49.1 spi sdcard example failing to mount
Posted: Mon Nov 04, 2024 4:08 pm
Hello!
I'm quite new to Rust generally, so apologies if I'm missing something obvious.
I'm trying to use the example code to mount an SD Card on an M5 Cardputer. I've changed the pins to match the board as follows:
[Codebox]
let spi_driver = SpiDriver::new(
peripherals.spi3,
pins.gpio40,
pins.gpio14,
Some(pins.gpio39),
&DriverConfig::default().dma(Dma::Auto(1024)),
)?;
let spi_device = SpiDevice::new(
spi_driver,
pins.gpio12,
[/Codebox]
When I try to run the code on device I get the following when [Codebox]Fat::mount[/Codebox] is called:
[Codebox]
I (446) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (446) sdspi_transaction: cmd=52, R1 response: command not supported
I (496) sdspi_transaction: cmd=5, R1 response: command not supported
E (506) vfs_fat_sdmmc: mount_to_vfs failed (0x102).
I (506) gpio: GPIO[12]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (516) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (526) gpio: GPIO[39]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (536) gpio: GPIO[40]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
thread 'main' panicked at /home/benvh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-idf-hal-0.44.1/src/spi.rs:482:52:
called `Result::unwrap()` on an `Err` value: ESP_ERR_INVALID_STATE (error code 259)
[/Codebox]
I haven't been able to figure out anything that is obviously wrong, so I'm asking for help. It looks like the GPIOs might not be in the right state (OutputEn: 0) but I'm not sure if that's correct or not and the example code doesn't reconfigure the pins manually.
I don't have another ESP board with an SD card with me at the moment, so I'm trying to figure out why it's failing. I've tried setting [Codebox]format_if_mount_failed[/Codebox] when calling [Codebox]Fat::mount[/Codebox] but it didn't make any difference.
Thanks for any pointers or thoughts!
I'm quite new to Rust generally, so apologies if I'm missing something obvious.
I'm trying to use the example code to mount an SD Card on an M5 Cardputer. I've changed the pins to match the board as follows:
[Codebox]
let spi_driver = SpiDriver::new(
peripherals.spi3,
pins.gpio40,
pins.gpio14,
Some(pins.gpio39),
&DriverConfig::default().dma(Dma::Auto(1024)),
)?;
let spi_device = SpiDevice::new(
spi_driver,
pins.gpio12,
[/Codebox]
When I try to run the code on device I get the following when [Codebox]Fat::mount[/Codebox] is called:
[Codebox]
I (446) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (446) sdspi_transaction: cmd=52, R1 response: command not supported
I (496) sdspi_transaction: cmd=5, R1 response: command not supported
E (506) vfs_fat_sdmmc: mount_to_vfs failed (0x102).
I (506) gpio: GPIO[12]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (516) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (526) gpio: GPIO[39]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (536) gpio: GPIO[40]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
thread 'main' panicked at /home/benvh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-idf-hal-0.44.1/src/spi.rs:482:52:
called `Result::unwrap()` on an `Err` value: ESP_ERR_INVALID_STATE (error code 259)
[/Codebox]
I haven't been able to figure out anything that is obviously wrong, so I'm asking for help. It looks like the GPIOs might not be in the right state (OutputEn: 0) but I'm not sure if that's correct or not and the example code doesn't reconfigure the pins manually.
I don't have another ESP board with an SD card with me at the moment, so I'm trying to figure out why it's failing. I've tried setting [Codebox]format_if_mount_failed[/Codebox] when calling [Codebox]Fat::mount[/Codebox] but it didn't make any difference.
Thanks for any pointers or thoughts!