Skip to content

Conversation

@ginkgm
Copy link

@ginkgm ginkgm commented Dec 20, 2019

The SDIO protocol is a subset of complete SD, which uses the same lower level protocol but different commands, responds and different flow.

The main differences are:

  • New command CMD5 and different card initialization flow
  • New command CMD52 (w/o data) and CMD53 (with data) for data transmission
  • Data blocks (by CMD53) are no longer determined by a special command and fixed to some length, it's determined by CMD53, and can be variable among 1-512 bytes.
  • Data block numbers is no longer determined by Stop Transmission commands, but determined by the number in CMD53.

This MR proposed a new decoder sdio modified from the sdcard_sd decoder, provides features:

  • Detect Command or Respond automatically (now you don't have to set the start time of decoding).
  • Support to select sample edge of clock
  • Calculating of CRC on CMD and DATA lines
  • Upgrade display of commands: CMD7 and R6 (response of CMD3).
  • SDIO support
    • CMD5, CMD52, R4, R5, CMD53 supported
    • interrupt line not supported yet.
  • Decoding of data lines (1-line and 4-line mode), support to decode the host to card busy token

Though the original decoder (sdcard_sd) is possible to support both SD memory, SDIO and even eMMC, since this introduces some refactoring from the v2 decoder, I'm not sure whether you can accept the refactoring.

If you like this decoder, I'd like to know which apprroach do you prefer, putting it into the original decoder, or having a new decoder? So that I can cleanup the code a bit more.

Usage of the decoder:

  1. Specify required pins for the mode you are using (CMD, CLK, D0 for 1-bit mode, while CMD, CLK, D0-3 for 4-bit mode)
  2. Specify the 1-bit or 4-bit mode, sample edges, and block size (512 by default)
  3. Having fun with this decoder!

@ginkgm
Copy link
Author

ginkgm commented Dec 20, 2019

And here are the dump files for 1-bit and 4-bit SDIO communication.

sdio.zip

The `wait()` interface needs to write to a tuple with variables with
exact the same number as it returns, instead of a single variable.  If
the return type is not valid, error occurs.
@uwehermann
Copy link
Member

Hi, thanks for the sample files! Could you add those to the sigrok-dumps repo and send a PR there, please? Ideally also add a small README with some info about the files and what they contain, what hardware setup was used etc. etc.

Example:
https://github.com/sigrokproject/sigrok-dumps/blob/master/sdcard/sd_mode/imx6_quad/README

Thanks!

@uwehermann
Copy link
Member

As for the decoder, it's probably best to merge SDIO support into the existing sdcard_sd decoder, yes.

This has received quite a bunch of improvements in the last few days (and more will follow), which make it a lot more readable and also usable with a recent PulseView nightly build (you can now enable/disable any annotation class, which can be very handy).

Please add your changes as multiple individual commits (one per feature if possible), in order to make reviews and git history browsing easier. Thanks!

For example, the CRC feature should be one independent commit; also, please add crc7() and crc16() to the pd.py file directly, there's no need for an extra file or test-code (I'm assuming you've tested/debugged this already).

You can probably close this PR and open new ones for the individual changes against the current sdcard_sd decoder.

Thanks again for your work!

@uwehermann uwehermann self-assigned this Jul 20, 2020
@PetteriAimonen
Copy link
Contributor

@ginkgm Thanks for this decoder, it works much better than the limited sdcard_sd decoder and in my opinion could replace it entirely.

I had to do this change to fix error "annotation class/row IDs contain duplicates" with newer libsigrokdecode (annotation rows and annotations cannot share names anymore):


    annotation_rows = (
        ('row_data', 'Data Line', tuple(range(137,141))),
        ('row_raw-bits', 'Raw bits', (128,)),
        ('row_decoded-bits', 'Decoded bits', (135,)),
        ('row_decoded-fields', 'Decoded fields', (136,)),
        ('row_fields', 'Fields', tuple(range(129, 135))),
        ('row_cmd', 'Commands', tuple(range(128))),
        ('row_msg', 'Messages', (141,)),
    )

antonok-edm added a commit to antonok-edm/libsigrokdecode that referenced this pull request Apr 23, 2025
note that I put this together before seeing
sigrokproject#24 and
sigrokproject#93; I'm not sure
how this compares to either of them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants