Skip to main content
FDonh.1
Visitor II
May 19, 2020
Question

SD Card with FAT-FS on ST32F746 Discovery Kit gets stuck in DMA method

  • May 19, 2020
  • 0 replies
  • 519 views

I am trying to use the SD card slot on the ST32F746 Discovery board. I am using the default project that is generated by STM32CubeIDE which includes MX_FATFS_Init() to set up the SD card. I have made no changes and used the default settings for everything except the StartDefaultTask method.

In my StartDefaultTask method I am trying to use the SD card similar to STM32CubeF7 Firmware Package:

void StartDefaultTask(void const *argument) {
	/* init code for USB_HOST */
	MX_USB_HOST_Init();
	/* USER CODE BEGIN 5 */
	FIL MyFile; /* File object */
	uint8_t workBuffer[_MAX_SS];
 
	FRESULT res; /* FatFs function common result code */
	uint32_t byteswritten, bytesread; /* File write/read counts */
	uint8_t wtext[] = "This is STM32 working with FatFs"; /* File write buffer */
	uint8_t rtext[100]; /* File read buffer */
 
	/*##Register the file system object to the FatFs module ##############*/
	if (f_mount(&SDFatFS, (TCHAR const*) SDPath, 1) != FR_OK) {
...

f_mount gets stuck since sd_diskio.c/SD_read gets stuck in the last line of this codeblock:

DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
{
 DRESULT res = RES_ERROR;
 uint32_t timer;
#if (osCMSIS < 0x20000U)
 osEvent event;
#else
 uint16_t event;
 osStatus_t status;
#endif
#if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1)
 uint32_t alignedAddr;
#endif
 /*
 * ensure the SDCard is ready for a new operation
 */
 
 if (SD_CheckStatusWithTimeout(SD_TIMEOUT) < 0)
 {
 return res;
 }
 
#if defined(ENABLE_SCRATCH_BUFFER)
 if (!((uint32_t)buff & 0x3))
 {
#endif
 /* Fast path cause destination buffer is correctly aligned */
 uint8_t ret = BSP_SD_ReadBlocks_DMA((uint32_t*)buff, (uint32_t)(sector), count);

If I click suspend it always stops here and all options (resume/step into/step over/ ...) lead to nothing. I can wait as long as I want but pressing suspend always leads back to this part. Setting breakpoints inside of BSP_SD_ReadBlocks_DMA also does not work since they are never hit (the method seems to never be called).

Do you know what's going wrong?

This topic has been closed for replies.