Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDIO driver does not support 16Gb+ card capacities #77

Closed
andysworkshop opened this issue Dec 26, 2014 · 0 comments
Closed

SDIO driver does not support 16Gb+ card capacities #77

andysworkshop opened this issue Dec 26, 2014 · 0 comments
Assignees
Labels

Comments

@andysworkshop
Copy link
Owner

This is due to a bug in ST's driver code that's still there today in the latest "cube" release. They managed to demonstrate an awareness of the issue by correctly declaring the CardCapacity member of the HAL_SD_CardInfoTypedef structure as a uint64_t. Unfortunately they don't understand that the width of the type being assigned to is not taken into account until after the calculation on the right-hand side is done, and that calculation is done at 32-bit width. Result: overflow on this line:

pCardInfo->CardCapacity  = ((pCardInfo->SD_csd.DeviceSize + 1)) * 512 * 1024;

The fix can be done in a few ways, here's the one I chose:

pCardInfo->CardCapacity = (_cardInfo.SD_csd.DeviceSize + 1) * 512ULL * 1024ULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant