Skip to content

Documented CSD parsing expectations for SDIO lower-half#18543

Merged
acassis merged 5 commits intoapache:masterfrom
arjav1528:dev-issue-17248
Mar 17, 2026
Merged

Documented CSD parsing expectations for SDIO lower-half#18543
acassis merged 5 commits intoapache:masterfrom
arjav1528:dev-issue-17248

Conversation

@arjav1528
Copy link
Contributor

@arjav1528 arjav1528 commented Mar 16, 2026

Fixes: #17248

Summary

Addressed the issue by documenting how SDIO lower-half drivers must provide R2 (CID/CSD) responses and by adding a small sanity check in the MMCSD upper-half. include/nuttx/sdio.h now explains the R2 format, states that the upper-half expects a 128‑bit CID/CSD payload in the standard layout, and notes that controllers which strip the CRC must shift the four 32‑bit words left by one byte (with bcm2711_sdio.c and imx9_usdhc.c as examples). mmcsd_decode_csd in drivers/mmcsd/mmcsd_sdio.c gains a DEBUGASSERT(csd[0] != 0); under CONFIG_DEBUG_FEATURES to catch obviously invalid or misaligned CSDs, and the SDIO/MMCSD docs now describe the SDIO lower-half call-flow and R2/CSD expectations and point implementers to this guidance.

Impact

  • Runtime behavior: Only a debug‑only DEBUGASSERT in mmcsd_decode_csd is added; there is no behavior or performance change in non‑debug builds.
  • API/ABI: No changes to SDIO or MMCSD public interfaces; existing correct SDIO lower‑halves continue to work unchanged.
  • Documentation: SDIO docs now explicitly describe recv_r2/R2 handling (including CRC‑stripping controllers), and MMCSD docs direct SDIO lower‑half implementers there.
  • Build / compatibility / security: No new Kconfig options or dependencies beyond existing Sphinx for docs; no security impact; compatibility for /dev/mmcsd* users is unchanged.

Testing

  • make html in Documentation/ to verify the updated RST documentation builds successfully.
  • No runtime or hardware tests were performed because no SDIO/MMC-capable target hardware is available in this environment; the new DEBUGASSERT behavior is validated by static inspection only.

@arjav1528 arjav1528 changed the title Document CSD parsing expectations for SDIO lower-half Documented CSD parsing expectations for SDIO lower-half Mar 16, 2026
@github-actions github-actions bot added Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Mar 16, 2026
@arjav1528 arjav1528 force-pushed the dev-issue-17248 branch 2 times, most recently from a20aa66 to 7616424 Compare March 16, 2026 10:40
@github-actions github-actions bot added Area: Documentation Improvements or additions to documentation and removed Area: Drivers Drivers issues labels Mar 17, 2026
acassis
acassis previously approved these changes Mar 17, 2026
This update adds comprehensive documentation regarding the 136-bit response format for SDIO, including the structure of the response, CRC handling, and necessary byte-shifting for alignment. This information is crucial for developers implementing or maintaining SDIO drivers.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
This update expands the documentation for implementing an SDIO lower-half driver, detailing the required interface, call-flow, and handling of the R2 response format. It emphasizes the importance of byte-shifting when the CRC is stripped by the hardware, providing reference implementations for clarity.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
…ation

This update adds a reference to the SDIO Driver Documentation for implementers of SDIO lower-half drivers, emphasizing the importance of understanding R2/CSD response handling and the correct implementation of the lower-half interface.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
This update clarifies the call-flow for the SDIO lower-half driver implementation by providing a simplified example of the interaction between the MMCSD upper-half and the lower-half. It details the command sequence for handling R2 responses, improving the understanding of the expected behavior during card identification and initialization.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
This update enhances the SDIO documentation by including a reference to the card initialization flowchart in the MMC/SD physical layer specification. This addition aims to provide implementers with a clearer understanding of the complete card initialization and command sequence.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
@acassis acassis merged commit 3d14873 into apache:master Mar 17, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Document CSD parsing for MMCSD upper-half

4 participants