Skip to main content
raaa
Visitor II
April 25, 2016
Question

HAL SDIO Sector computation error

  • April 25, 2016
  • 1 reply
  • 605 views
Posted on April 25, 2016 at 12:43

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
    This topic has been closed for replies.

    1 reply

    Nesrine M_O
    Associate
    April 25, 2016
    Posted on April 25, 2016 at 12:58

    Hi Ra,

    Thanks for highlighting this issue.It is a known issue,but the fix has not yet been released on the web. 

    -Syrine-