8000 SDIO driver does not support 16Gb+ card capacities · Issue #77 · andysworkshop/stm32plus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
SDIO driver does not support 16Gb+ card capacities #77
Closed
@andysworkshop

Description

@andysworkshop

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;

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0