Closed niuhuan closed 4 months ago
this code has been panic at let _fat = Fat::mount(fat_configuration, host, "/")?;
let pins = peripherals.pins;
let spi3 = peripherals.spi3;
let device = esp_idf_svc::hal::spi::SpiDriver::new(
spi3,
pins.gpio12,
pins.gpio14,
Some(pins.gpio16),
&esp_idf_svc::hal::spi::config::DriverConfig::default(),
)?;
let sd_device = esp_idf_svc::sd::spi::SpiDevice::new(
device,
pins.gpio18,
Option::<esp_idf_svc::hal::gpio::AnyInputPin>::None,
Option::<esp_idf_svc::hal::gpio::AnyInputPin>::None,
Option::<esp_idf_svc::hal::gpio::AnyInputPin>::None,
);
let host_config = SdConfiguration::new();
let host = SdHost::new_with_spi(&host_config, sd_device);
let fat_configuration = FatConfiguration::new();
let _fat = Fat::mount(fat_configuration, host, "/")?;
let mut file = File::create("/test.txt")?;
file.write_all(b"Hello, world!")?;
I (548) main_task: Started on CPU0
I (558) main_task: Calling app_main()
I (568) myesp: MCU STARTED!
I (588) myesp::mmc_controller: INIT MMC
I (588) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
E (618) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
I (618) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (618) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (628) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (638) gpio: GPIO[12]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
thread 'main' panicked at D:\Developments\Runtimes\.cargo\registry\src\index.crates.io-6f17d22bba15001f\esp-idf-hal-0.44.0\src\spi.rs:482:52:
called `Result::unwrap()` on an `Err` value: ESP_ERR_INVALID_STATE (error code 259)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
abort() was called at PC 0x4202f1da on core 0
0x4202f1da - panic_abort::__rust_start_panic::abort
at D:\Developments\Runtimes\.rustup\toolchains\esp\lib\rustlib\src\rust\library\panic_abort\src\lib.rs:48
panic on this unwrap
impl<'d> Drop for SpiDriver<'d> {
fn drop(&mut self) {
esp!(unsafe { spi_bus_free(self.host()) }).unwrap();
}
}
Hello, Sorry for the delay, I am currently traveling. I just made a fix for the SD SPI part, I invite you to try with my branch that fixes the encountered bugs. Here is the hardware configuration I used. If this is okay with you, I will continue with the SD MMC part.
I was having the same issue. Your branch fixed it.
Using:
closing since esp-rs/esp-idf-hal#457 landed. If you still got problems please report back.
I am truly certain that my hardware is not faulty, and I can use the tf card normally with other firmware.
I have checked the correctness of the PINs, but still cannot read the tfcard
My code is copy lot of https://github.com/esp-rs/esp-idf-svc/blob/master/examples/sd_mmc.rs