2023-09-25 11:41 PM
Hello,
I'm currently trying to set up an SD-card driver for the STM32H750. I've following code right at initialization.
The driver code is from:
https://controllerstech.com/interface-sd-card-with-sdio-in-stm32/
Unfortunately, it doesn't work reliably. With D-Cache enabled, only the first file "FILE1.TXT" is created when powering on, but without content.
If the board is in operation and the card is empty, and I just do a reset, both text files are created with content.
In following link it explains to change the "win element" in the struct FATFS and change something to aligned, but unfortunately there is no example code.
https://yairgadelov.me/setup-sdcard-on-stm32-mcu/
I lack a deep understanding of this cache issue, and the STM32 application notes does not really helped me (to complicated). What else needs to be adjusted to make it work reliably?
I can't find any example code for STM32H750 or 745.
Thank you
sd_diskio.c:
/* USER CODE BEGIN enableSDDmaCacheMaintenance */
#define ENABLE_SD_DMA_CACHE_MAINTENANCE 1
/* USER CODE END enableSDDmaCacheMaintenance */
/*
* Some DMA requires 4-Byte aligned address buffer to correctly read/write data,
* in FatFs some accesses aren't thus we need a 4-byte aligned scratch buffer to correctly
* transfer data
*/
/* USER CODE BEGIN enableScratchBuffer */
#define ENABLE_SCRATCH_BUFFER
/* USER CODE END enableScratchBuffer */
main.c:
MX_SDMMC1_SD_Init();
MX_FATFS_Init();
Mount_SD("/");
Format_SD();
Create_File("FILE1.TXT");
sprintf(buffer, "Hello ---> %d\n", indx);
Update_File("FILE1.TXT", buffer);
Create_File("FILE2.TXT");
sprintf(buffer, "world ---> %d\n", indx);
Update_File("FILE2.TXT", buffer);
Unmount_SD("/");
2024-03-05 04:08 AM
Did you ever get this sorted? I am running into similar issues on an STM32H7B3I-DK evaluation board where the CF card only works if the D-Cache is not enabled.