Skip to main content
Alireza Safdari
Associate
August 18, 2019
Question

Nucleo F767 SDIO's Works in 1 bit but not 4 bit? (Cube IDE is Used)

  • August 18, 2019
  • 8 replies
  • 2837 views

I am using CubeIDE 1.0.2 on Nucleo-F767ZI.

=> all settings are the default setting, but ETH and USB_OTG_FS are disabled,.

=> The SDIO is enabled (SD 1 bit /SD 4 bits Wide Bus) and has all the default settings, except for SDMMCCLK Clock Divider Factor = 4.

=> The FatFs is enabled for SD Card and has all the default settings, except for MAX_SS (Maximum Sector Size) = 4096 and Detect_SDIO = PC0 (First set it as GPIO input)

=> The clock for SDMMC1 (48MHz) is taken from PLL48CLK

Everything works fine in 1-bit SD mode but, in 4-bit wide the "f_mount" function from FatFs returns: "FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */".

I narrowed down the problem and it is happening in the "HAL_SD_ReadBlocks" function once it is called from

"find_volume"

"fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */"

"if (move_window(fs, sect) != FR_OK) return 4;"

"if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) {"

"res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);"

" if(BSP_SD_ReadBlocks((uint32_t*)buff, (uint32_t) (sector), count, SD_TIMEOUT) == MSD_OK)"

"if (HAL_SD_ReadBlocks(&hsd1, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK)"

(I learned this by comparing the path taken by 1-bit version vs 4-bit version)

The SD card reader is:

https://www.robotshop.com/en/micro-sd-storage-module.html

And my friend has gotten the same SD card and card reader working with Nucleo-H743ZI in 4-bit mode. So I highly doubt if it is a hardware problem.

I have attached both project.

This topic has been closed for replies.

8 replies

u_2man
Associate II
October 3, 2019

Hi..

I have the same problem, using STM32F207 and STM32CubeIDE. 1 bit mode works properly, but in 4 bit mode, f_mount always return error. I debug my program, error when call HAL_SD_Readblock.

Then I generate with STM32CubeMX for TrueStudio, 4 bit mode works with no problem.

Is there any possibility error in code generated by STM32CubeIDE?

I already try to replace source that generated by cubeIDE with source file from TrueStudio (generated by cubeMX): bsd_driver_sd.c, fatfs.c, sdio.c.

But still can not work for 4 bit mode.

Thanks

Tesla DeLorean
Guru
October 3, 2019

There should be worked examples under the HAL F2 trees for the CubeF2. Look at the EVAL boards, and applications directories, either SDIO examples, or FatFs ones. The F4 examples might be richer, and 99% compatible.

Use these with one of the IAR/Keil tool chains, personally wouldn't trust CubeIDE or CubeMX to generate production grade code.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
u_2man
Associate II
October 3, 2019

Agree with you...

I used CubeIDE for educational purpose (I am wrting a book of STM32F207).

For project/production I used TrueStudio with CubeMX off course. So far no problem found.

Tesla DeLorean
Guru
October 3, 2019
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
u_2man
Associate II
October 4, 2019

Hi

Finally it works 4 bit mode in STM32CubeIDE.

Just re-compile the source in Release mode, not Debug Mode.

Open, write, read operation works fine.

Thanks

Alireza Safdari
Associate
October 5, 2019

Thanks for the update but is not that weird?