imxrt-rs / imxrt-hal

Rust for NXP i.MX RT
Apache License 2.0
122 stars 29 forks source link

uSDHC support #119

Open AstraLuma opened 1 year ago

AstraLuma commented 1 year ago

I'm not seeing code for the uSDHC/SDIO peripheral found in the RT1062.

Add this please?

AstraLuma commented 1 year ago

I might end up doing this myself, but I'm pretty new to both rust and rust embedded, and I've got other stuff going on right now.

mciantyre commented 1 year ago

Happy to help answer any questions here.

Related:

mciantyre commented 1 year ago

Cherry-picking ideas from a downstream issue.

If you're interested in FAT file systems, take a look into embedded-sdmmc. Maybe there's a way to implement the BlockDevice trait for the uSDHC peripheral.

Also note that embedded-sdmmc already has some kind of SPI support. Here's the BlockSpi adapter, which provides a default BlocKDevice implementation. That might already play well with imxrt-hal's SPI drivers, so the "SD over SPI" problem might already be solved.

ameliamariecollins commented 1 year ago

I'm not sure if this is common knowledge, but I stumbled across a recipe to "misuse" the pins of the onboard SD card to allow use of simple 3-wire SPI:

Pin 44 (CLK) → SCK Pin 45 (CMD) → PICO (SDO from the controller's point of view) Pin 43 (DAT0) → POCI (SDI from the controller's point of view) Pin 46 (DAT3) → CS

This worked somehow. In fact it worked at 25MHz over jumpers in a breadboard. Or perhaps not — it might have been honoring the choice of pin functions, but bit-banging the SPI signals. After all, it doesn't even line up with LPSPI1's ALTs. (I was running CircuitPython on the Teensy4.1 at the time.)

We shall do better, of course. But there was no QSPI support at the time and I really, really wanted to get at that card.