cancel
Showing results for 
Search instead for 
Did you mean: 

Please fix one-year old bug!!!

sincoon
Associate II
Posted on April 19, 2016 at 20:03

Dear ST, please fix already one-year old bug!

It is described here yet: https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FSDIO%20BUG%20Large%20SDHC%20file%20system%20corruption%20%28sd_diskio.c%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC..., but I'll repeat again, because it leads to very strange behaviour during writing on SD card. Result: you cannot write more then 4 gb during one session using FatFS. lines

SD_state = BSP_SD_ReadBlocks_DMA((uint32_t*)scratch, (uint64_t) ((sector + count) * BLOCK_SIZE), BLOCK_SIZE, 1);
SD_state = BSP_SD_ReadBlocks_DMA((uint32_t*)buff, (uint64_t) (sector * BLOCK_SIZE), BLOCK_SIZE, count);
SD_state = BSP_SD_WriteBlocks_DMA((uint32_t*)scratch, (uint64_t)((sector + count) * BLOCK_SIZE), BLOCK_SIZE, 1);
SD_state = BSP_SD_WriteBlocks_DMA((uint32_t*)buff, (uint64_t)(sector * BLOCK_SIZE), BLOCK_SIZE, count);

sd_diskio.c should be:

SD_state = BSP_SD_ReadBlocks_DMA((uint32_t*)scratch, ((uint64_t)sector + count) * BLOCK_SIZE, BLOCK_SIZE, 1);
SD_state = BSP_SD_ReadBlocks_DMA((uint32_t*)buff, (uint64_t)sector * BLOCK_SIZE, BLOCK_SIZE, count);
SD_state = BSP_SD_WriteBlocks_DMA((uint32_t*)scratch, ((uint64_t)sector + count) * BLOCK_SIZE, BLOCK_SIZE, 1);
SD_state = BSP_SD_WriteBlocks_DMA((uint32_t*)buff, (uint64_t)sector * BLOCK_SIZE, BLOCK_SIZE, count);

#sdio #!bug #cubemx #fatfs
6 REPLIES 6
Walid FTITI_O
Senior II
Posted on April 19, 2016 at 20:29

Hi sinitsin.artyom,

Which Library/ driver versions you are using ?

-Hannibal-
markb
Associate II
Posted on April 20, 2016 at 13:52

The bug is still in

STM32Cube/Repository/STM32Cube_FW_F4_V1.5.0/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c

Walid FTITI_O
Senior II
Posted on April 20, 2016 at 18:51

Hi sinitsin.artyom,

Please try to use the last version of Hal library in

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897/PF259243

-Hannibal-

markb
Associate II
Posted on April 20, 2016 at 22:17

Sorry, my mistake, I meant to say that the bug is still in

STM32Cube/Repository/STM32Cube_FW_F4_V1.11.0/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c

sincoon
Associate II
Posted on April 21, 2016 at 11:37

The problem still exists, but in another functions. Look here(this is last CubeMX and HAL):

/*sd_diskio.c*/
DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
{
DRESULT res = RES_OK;
if(BSP_SD_ReadBlocks((uint32_t*)buff, 
(uint64_t) (sector * BLOCK_SIZE), 
BLOCK_SIZE, 
count) != MSD_OK)
{
res = RES_ERROR;
}
return res;
}
DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
{
DRESULT res = RES_OK;
if(BSP_SD_WriteBlocks((uint32_t*)buff, 
(uint64_t)(sector * BLOCK_SIZE), 
BLOCK_SIZE, count) != MSD_OK)
{
res = RES_ERROR;
}
return res;
}

Walid FTITI_O
Senior II
Posted on April 21, 2016 at 16:04

Hi sinitsin.artyom,

Thanks for the feedback. I will report this internally.

-Hannibal-