sd: Fix SDSC card support #41

Merged
matthias merged 1 commits from fix-sdsc-card-blocksize into main 2025-10-07 19:54:11 +00:00
Owner
  • Old SDSC cards could have a native blocksize != 512 bytes, but they
    should support the SET_BLOCKLEN command to set the blocksize to 512.
    Use that so we can just assume 512 everywhere else.

  • SDSC cards used byte addresses, not sector numbers, for the argument
    of READ_BLOCK and WRITE_BLOCK. Check the card type and multiply the
    sector number with 512 if necessary.

Tested with a noname chinese 128 MiB-ish card.

Signed-off-by: Matthias Blankertz matthias@blankertz.org

- Old SDSC cards could have a native blocksize != 512 bytes, but they should support the SET_BLOCKLEN command to set the blocksize to 512. Use that so we can just assume 512 everywhere else. - SDSC cards used byte addresses, not sector numbers, for the argument of READ_BLOCK and WRITE_BLOCK. Check the card type and multiply the sector number with 512 if necessary. Tested with a noname chinese 128 MiB-ish card. Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
matthias self-assigned this 2025-09-07 14:06:11 +00:00
matthias added 1 commit 2025-09-07 14:06:12 +00:00
sd: Fix SDSC card support
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m18s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 4s
Run unit tests on host / Run-Unit-Tests (push) Successful in 7s
Run pytests / Check-Pytest (push) Successful in 10s
d39157ba0a
- Old SDSC cards could have a native blocksize != 512 bytes, but they
  should support the SET_BLOCKLEN command to set the blocksize to 512.
  Use that so we can just assume 512 everywhere else.

- SDSC cards used byte addresses, not sector numbers, for the argument
  of READ_BLOCK and WRITE_BLOCK. Check the card type and multiply the
  sector number with 512 if necessary.

Tested with a noname chinese 128 MiB-ish card.

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
matthias requested review from stefank 2025-09-07 14:06:12 +00:00
stefank approved these changes 2025-10-07 19:39:06 +00:00
matthias merged commit bd17197fef into main 2025-10-07 19:54:11 +00:00
matthias deleted branch fix-sdsc-card-blocksize 2025-10-07 19:54:12 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TonBERRY/tonberry-pico#41