2026-02-28 9:46 PM
Hi,
Have this working on STM32F302R8 but cannot seem to get my SD Card working on an STM32F446RE. Using hal 0.23.0 with stm32F446 and embedded-sdmm 0.9.0);
let sd_mosi = gpiob.pb15.into_alternate::<5>();
let sd_miso = gpiob.pb14.into_alternate::<5>();
let sd_sck = gpiob.pb13.into_alternate::<5>();
let mut sd_spi = Spi::new(
dp.SPI2,
(Some(sd_sck), Some(sd_miso), Some(sd_mosi)),
Mode {
polarity: Polarity::IdleLow,
phase: Phase::CaptureOnFirstTransition,
},
400.kHz(),
&mut rcc,
);
let sd_spi_dev = ExclusiveDevice::new_no_delay(sd_spi, sd_cs).unwrap();
rprintln!("Reading file...");
let num_bytes = sdcard.num_bytes().unwrap();
rprintln!("SD Card Size: {} bytes", num_bytes);Which gives
[2026-03-01T05:30:04.085Z, +020837ms] panicked at both_test/src/main.rs:184:40:
[2026-03-01T05:30:04.085Z, +020837ms] called `Result::unwrap()` on an `Err` value: CardNotFoundVery new to all this but certain of wiring. The SD Adaptor has an Ams117 chip but I have tried in 3.3V 5V, tried lower speeds, set CS high, etc with no joy. Added 4.7k pullup to CS.
I can move it back to F302R8 and it works straight away.
Thanks all
Solved! Go to Solution.
2026-03-02 7:35 PM
Completely all my fault, probably been at it too long. When you set high and the Logic Analyzer says no, check the wiring. In fairness I am dyslexic but also a massive wally. Upside pinout Arrrrghhh. Still refreshed on my Logic Analyzer skills hahaha.
2026-03-02 7:03 AM
Have you tried using any other SPI on the chip?
Have you looked at the SPI lines using an oscilloscope and/or logic analyser?
What programming language are you using - is that Rust ?
2026-03-02 2:06 PM
Tested with an ILI9341 on SPI1 and all good but no joy with SDMMC. Learning to use my scope and should get it out but figured working on my ESP32 and STM32F302R8 meant it probably was not the boards (I have 3 with ASM117, and built in one on the ILI module)
Currently working through STM32CubeMx through WSL as I no longer run Linux. Long time since I left C behind for Rust but nice seeing an old friend.
Thanks for replying and will feedback for others
2026-03-02 7:35 PM
Completely all my fault, probably been at it too long. When you set high and the Logic Analyzer says no, check the wiring. In fairness I am dyslexic but also a massive wally. Upside pinout Arrrrghhh. Still refreshed on my Logic Analyzer skills hahaha.