cancel
Showing results for 
Search instead for 
Did you mean: 

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

Alireza Safdari
Associate III

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.

8 REPLIES 8
u_2man
Associate II

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

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
Up vote any posts that you find helpful, it shows what's working..

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.

The F2 is a rather old and orphaned product line, you might find a better audience for L4, F7 and H7 lines.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi

I have not found a solution yet. But I started accepting it :)

I think the files generated by CubeMX and CubeIDE are not the same and I cannot figure out why. for example CMSIS libraries do not get added to CubeIDE but CubeMX does generate them.

Test build for 4-bit (known working)

https://community.st.com/s/question/0D50X0000BOtWr8SQF/fatfs-sdio-4-bit-mode-stm32f746zg-nucleo

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

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

Thanks for the update but is not that weird?