AnsweredAssumed Answered

HAL SDIO Sector computation error

Question asked by _Ra_ on Apr 25, 2016
Latest reply on Apr 25, 2016 by Nesrine M
Hallo,

I noticed a BUG in sd_diskio.c in version 1.3.0 included in STM32CubeF4 v. 1.11.0 resulting in reading/writing from wrong sectors on big capacity SD cards.

In functions SD_read and SD_write sector computation is casted to uint64_t too late resulting in clipping of most significant bits:
Is:
if(BSP_SD_ReadBlocks((uint32_t*)buff,
                     (uint64_t)(sector * BLOCK_SIZE),
                     BLOCK_SIZE, count) != MSD_OK)

Fix:
if(BSP_SD_ReadBlocks((uint32_t*)buff,
                     (uint64_t) (sector) * BLOCK_SIZE,
                     BLOCK_SIZE, count) != MSD_OK)


Regards,

Ra

Outcomes