cancel
Showing results for 
Search instead for 
Did you mean: 

Bug report STM32CubeMX 4.14.0 - SD_read, SD_write for DMA mode

petr239955
Associate III
Posted on May 11, 2016 at 23:34

I have project generated by STM32CubeMX 4.14.0 and STM32CubeF7 1.3.1. I use the FATFS and SDIO with DMA.

If I wrote a file with higher clock for sd card, then there is an error in the function FR_DISK_ERR f_write.

I found the problem in sd_diskio.c where

SD_read and SD_write

 functions call functions for polling mode and not for DMA mode.

For DMA mode is necessary to change:

DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)

{

  DRESULT res = RES_OK;

 

  if(BSP_SD_ReadBlocks

_DMA

((uint32_t*)buff,

                       (

(uint64_t)

sector * BLOCK_SIZE),

                       BLOCK_SIZE,

                       count) != MSD_OK) DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)

{

  DRESULT res = RES_OK;

 

  if(BSP_SD_WriteBlocks

_DMA

((uint32_t*)buff,

                        (

(uint64_t)

sector * BLOCK_SIZE),

                        BLOCK_SIZE, count) != MSD_OK)

6 REPLIES 6
Walid FTITI_O
Senior II
Posted on May 12, 2016 at 12:05

Hi petr.k,

Thank you for the feedback. It's reported internally.

-Hannibal-

petr239955
Associate III
Posted on January 23, 2017 at 12:11

STM32CubeMX 4.19.0 and STM32CubeF7 1.6.0

No change

, the 

STM32CubeMX still has this bug !

ST team,

try to

do

your

examples

using

STM32CubeMX

,

you may find

yourself

bugs

faster.

Posted on January 23, 2017 at 12:53

Dear petr.k

SD and MMC(perhaps other peripheral) driver is still unmatured.

I mentioned in this thread.

https://community.st.com/0D50X00009Xkg1RSAR

For now,we should customize source codes by ourself as we like.

Posted on January 23, 2017 at 14:57

Hi

Kolomaznik.Petr

‌,

The issue is already tracked internally.

It is not directly related to CubeMX generated code, but the fix has to be applied in the Third_Party FatFS driver.

Sorry for such inconvenience.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on January 23, 2017 at 14:59

Hi

Nemui.Trinomius

‌,

SD and MMC(perhaps other peripheral) driver is still unmatured.

Is you comment applicable for the new driver available in the package version 1.6.0 of the STM32CubeF7?

If yes, please share your feedback providing all required details to explain it in a separate discussion.

Thanks.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

petr239955
Associate III
Posted on January 24, 2017 at 12:17

Hi

st.mcu

,

thank you for answer.

I have a

problem with the

SD

c

ard

that use

DMA

.

E.g.

it hangs

in a loop

where

timeout

is

1048 sec

(

17

minute ??

)

.

I

do not understand

why

such a long time

.

Please verify

and check all modes of SD and FATFS that are contained in

HAL

. It is a pity that such a great microcontrollers have poor software support.

#define SDMMC_DATATIMEOUT ((uint32_t)0x00100000U)

static uint32_t SD_FindSCR(SD_HandleTypeDef *hsd, uint32_t *pSCR)

{

....

while(!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXOVERR | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_DBCKEND))

{

if(__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXDAVL))

{

*(tempscr + index) = SDMMC_ReadFIFO(hsd->Instance);

index++;

}

if((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)

{

return HAL_SD_ERROR_TIMEOUT;

}

}

Other minor

bug

:

uint8_t FATFS_LinkDriverEx(Diskio_drvTypeDef *drv, char *path, uint8_t lun)

{

uint8_t ret = 1;

uint8_t DiskNum = 0;

if(disk.nbr <= _VOLUMES) // correctly if(disk.nbr < _VOLUMES)

{

disk.is_initialized[disk.nbr] = 0;

disk.drv[disk.nbr] = drv;

disk.lun[disk.nbr] = lun;

DiskNum = disk.nbr++;

path[0] = DiskNum + '0';

path[1] = ':';

path[2] = '/';

path[3] = 0;

ret = 0;

}

return ret;

}

Petr