2019-08-18 12:59 AM
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.
2019-10-03 08:03 AM
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
2019-10-03 08:10 AM
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.
2019-10-03 08:22 AM
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.
2019-10-03 08:37 AM
The F2 is a rather old and orphaned product line, you might find a better audience for L4, F7 and H7 lines.
2019-10-03 11:49 AM
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.
2019-10-03 12:00 PM
Test build for 4-bit (known working)
https://community.st.com/s/question/0D50X0000BOtWr8SQF/fatfs-sdio-4-bit-mode-stm32f746zg-nucleo
2019-10-04 04:41 PM
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
2019-10-04 10:40 PM
Thanks for the update but is not that weird?