#async #sdmmc #bus

no-std async-embedded-sdmmc

Embedded sdmmc driver with async support

3 releases

0.1.3 Feb 12, 2023
0.1.2 Jan 25, 2023
0.1.1 Jan 20, 2023
0.1.0 Dec 15, 2021

#489 in Embedded development


947 lines


A sdmmc implementation mainly focusing on embedded system with no_std and async support

Using this crate

Assuming you already have SPI struct which implements sdmmc::spi::Transfer

let mut bus = sdmmc::bus::linux::spi(&args.spi, args.cs).map_err(|e| format!("{:?}", e))?;
let card = bus.init(Delay).await.map_err(|e| format!("{:?}", e))?;
debug!("Card: {:?}", card);
let mut sd = SD::init(bus, card).await.map_err(|e| format!("{:?}", e))?;
let size = Size::from_bytes(sd.num_blocks() as u64 * sd.block_size() as u64);
debug!("Size {}", size);

let options = SpidevOptions { max_speed_hz: Some(2_000_000), ..Default::default() };
sd.bus(|bus| bus.spi(|spi| spi.0.configure(&options))).unwrap();

let mut buffer = [0u8; 512];
sd.read(0, slice::from_mut(&mut buffer).iter_mut()).await.map_err(|e| format!("{:?}", e))?;
let mbr = MasterBootRecord::from_bytes(&buffer).map_err(|e| format!("{:?}", e))?;
for partition in mbr.partition_table_entries().iter() {
    println!("{:?}", partition);


  • async

    Enable async support

  • async-trait

    Use async-trait, otherwise nightly unstable async_fn_in_trait feature is enabled

  • embedded-hal-async

    Enable embedded-hal-async support

  • std

    Use std library

  • linux-spi

    Enable linux SPI support

  • log-max-level-off

    Disable logging at compile time


~28K SLoC