Skip to content

[BUG] Document CSD parsing for MMCSD upper-half #17248

@linguini1

Description

@linguini1

Description / Steps to reproduce the issue

This is not really a bug, but when developing the RPi4B SDIO implementation in #17245, I wasted a little bit of time troubleshooting CSD parsing since the upper-half expects the CSD to include the trailing CRC, while some SDMMC controllers remove the trailing CRC before storing the response, since they check it in hardware.

You can see that some other architectures have taken the same approach as I did in #17245 to shift over the bits properly for the CSD parsing. It's not necessary to compute the checksum, since the CSD parsing logic doesn't actually check the value (that is a lower-half responsibility).

Suggested solution

  1. I think it should be documented in the function comment for SDIO_RECVR2 that it is necessary to check if your controller removes the CRC, and if it does, shift over the response by 1 byte.
  2. Document this similarly in the NuttX doc website (it would be good to have a page about implementing an SDIO lower-half to give devs an idea of the call-flow).
  3. Run-time DEBUGASSERT in the CSD parsing to make sure that the CSD which was pased is actually valid. I'm not too familiar with the CSD contents, and it's likely the only way to check for a valid CSD is by the CRC, but it would be good if we could warn a developer at runtime that their CSD is in the wrong form (i.e. missing CRC and has leading 0s) so they can catch it quicker.

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Arch Linux

NuttX Version

master

Issue Architecture

[Arch: all]

Issue Area

[Area: Drivers], [Area: Debugging]

Host information

N/A

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: allIssues that apply to all architecturesArea: DebuggingDebugging issuesArea: DriversDrivers issuesOS: LinuxIssues related to Linux (building system, etc)Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions