Skip to content

sdcardio: fix card size for SDXC cards > 32 GB#11013

Open
mikeysklar wants to merge 1 commit into
adafruit:10.2.xfrom
mikeysklar:fix-sdxc-csd-v2-sector-count-10.2.x
Open

sdcardio: fix card size for SDXC cards > 32 GB#11013
mikeysklar wants to merge 1 commit into
adafruit:10.2.xfrom
mikeysklar:fix-sdxc-csd-v2-sector-count-10.2.x

Conversation

@mikeysklar
Copy link
Copy Markdown
Collaborator

Backport of #11012 to 10.2.x.

SDXC cards larger than 32 GB were reporting roughly half their actual block count
over USB MSC. The CSD v2.0 C_SIZE field is 22 bits but only the bottom 16 were
being read — the fix reads all 22.

Test results — Metro RP2350, 64 GB exFAT SDXC

Before After
macOS disk size 28.9 GB 63.3 GB ✓
Linux disk size 26.9 GiB 58.9 GiB ✓

Regression tested with a 16 GB FAT32 SDHC card — size correct on both platforms,
no impact on cards ≤ 32 GB.

Before:

$ lsblk -o NAME,SIZE,FSTYPE,LABEL
sdc     26.9G
└─sdc1  26.9G exfat    SDXC

After:

$ lsblk -o NAME,SIZE,FSTYPE,LABEL
sdc     58.9G
└─sdc1  58.9G exfat    SDXC

The CSD v2.0 C_SIZE field is 22 bits but only the bottom 16 were
being read. Cards > 32 GB reported roughly half their actual block
count over USB MSC. Fix reads all 22 bits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mikeysklar
Copy link
Copy Markdown
Collaborator Author

Backport of #11012 (main).

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.

1 participant