2016-04-19 11:03 AM
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. linesSD_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
2016-04-19 11:29 AM
Hi sinitsin.artyom,
Which Library/ driver versions you are using ? -Hannibal-2016-04-20 04:52 AM
2016-04-20 09:51 AM
Hi sinitsin.artyom,
Please try to use the last version of Hal library inhttp://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897/PF259243
-Hannibal-2016-04-20 01:17 PM
2016-04-21 02:37 AM
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;
}
2016-04-21 07:04 AM
Hi sinitsin.artyom,
Thanks for the feedback. I will report this internally. -Hannibal-