Repository navigation
Conversation
Replaces the dmsdio placeholder with a complete, hardware-independent SDSC/SDHC/SDXC driver: - dmsdio_port.h: a thin, protocol-free Module API - send a raw command and capture whichever response shape the caller says to expect, move already block-aligned data in/out, set bus width/speed mode. Every SD command sequence, response field, and byte<->block address translation lives in dmsdio.c, never in a port. - dmsdio.c: card identification (CMD0/CMD8/ACMD41/CMD2/CMD3/CMD9/CMD7), CID/CSD/SCR parsing, ACMD6 bus-width negotiation, CMD6 High Speed switch (with real Switch Function Status decoding, not just "did the command itself succeed"), single/multi-block read/write with CMD12 stop, ERASE, CMD13-based READY_FOR_DATA polling after a write/erase instead of guessing at a raw DAT0 busy bit, retry policy for transient CRC/timeout errors, and a dmdrvi device model: a persistent host node plus a hot-plugged card sub-node (/dev/dmsdioN/0) announced/unannounced via dmdrvi_device_available()/_unavailable(). Byte-offset reads/writes handle non-block-aligned ranges via read-modify-write on the boundary blocks, going straight to/from the card for interior full sectors. A dmsdio_generation_t on every open handle rejects stale access once a card is gone. - Card detect is an optional dmgpio friend (the same friend_group pattern dmspi uses for its chip-select) with edge-interrupt -> queue -> dmosi worker-thread debounce, so ISR context never touches the bus - see dmsdio.c's hotplug_worker(). No CD friend configured just means presence is only re-checked by attempting identification itself. - src/port/stm32f7: a real SDMMC1 register-level implementation (command/ response state machine, data phase via SDMMC's own internal IDMA - no dmdma involved, matching real hardware: F7's SDMMC has an internal DMA engine unlike F4's older SDIO peripheral) using dmclk_port's "sdio" clock domain for divider calculation. - src/port/x86_64: a mocked SD card (mock_control.h) simulating SDSC v1/v2, SDHC, and SDXC identification, configurable error injection (CRC/timeout/ removal), and a small backing store for real read/write round-trips - driving dmsdio.c through the exact CMD/ACMD sequence a real card would see. tests/dmsdio_test.c exercises it exactly the way a real consumer (dmdevfs) would: through the dmdrvi DIF, looked up by module name, not a direct/linked call. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes choco-technologies/dmod-ecosystem#11.
Summary
Replaces the dmsdio placeholder with a complete, hardware-independent SDSC/SDHC/SDXC driver.
dmsdio_port.h: a thin, protocol-free Module API - send a raw command and capture whichever response shape the caller expects, move already block-aligned data in/out, set bus width/speed mode. Every SD command sequence, response field, and byte<->block address translation lives indmsdio.c, never in a port.dmsdio.c: card identification (CMD0/CMD8/ACMD41/CMD2/CMD3/CMD9/CMD7), CID/CSD/SCR parsing, ACMD6 bus-width negotiation, a CMD6 High Speed switch that actually decodes the Switch Function Status response (not just "did the command itself succeed"), single/multi-block read/write with CMD12 stop, ERASE, CMD13-basedREADY_FOR_DATApolling after a write/erase, retry policy for transient CRC/timeout errors, and a dmdrvi device model: a persistent host node plus a hot-plugged card sub-node (/dev/dmsdioN/0) announced/unannounced viadmdrvi_device_available()/_unavailable(). Byte-offset reads/writes handle non-block-aligned ranges via read-modify-write on the boundary blocks. Admsdio_generation_ton every open handle rejects stale access once a card is gone.friend_grouppattern dmspi uses for its chip-select) with edge-interrupt → queue → dmosi worker-thread debounce, so ISR context never touches the bus. No CD friend configured just means presence is re-checked by attempting identification itself.src/port/stm32f7: a real SDMMC1 register-level implementation (command/response state machine, data phase via SDMMC's own internal IDMA - no dmdma involved, since F7's SDMMC has an internal DMA engine unlike F4's older SDIO peripheral) usingdmclk_port'ssdioclock domain for divider calculation.src/port/x86_64: a mocked SD card (mock_control.h) simulating SDSC v1/v2, SDHC, and SDXC identification, configurable error injection (CRC/timeout/removal), and a small backing store for real read/write round-trips.tests/dmsdio_test.cdrives it exactly the way a real consumer (dmdevfs) would: through the dmdrvi DIF, looked up by module name at runtime, not a direct/linked call.Test plan
dmsdiocore +stm32f7porttests/dmsdio_test.c) covers: SDSC v1/v2/SDHC/SDXC identification, 64-bit capacity reported without truncation, full-sector round-trip, unaligned read-modify-write preserving surrounding bytes, transient-CRC-recovered-by-retry vs. retry-exhaustion, card-removed-during-transfer, and identification timeout (no card) - CI job "Build and Test dmsdio (core)"Note on scope
dmsdio_port for STM32F4 (SDIO, which needs a real dmdma stream rather than an internal IDMA engine) is not part of this PR - only STM32F7/SDMMC, matching the epic's board list for this stage. STM32F4 support can follow as its own port once this core/dmdrvi-model/STM32F7 combination is validated on real hardware.