2026-05-07 7:48 AM - last edited on 2026-05-07 8:04 AM by Andrew Neil
Hi everyone,
I am working on a Riverdi 12.1" display board based on STM32H7 with TouchGFX 4.25 generated project.
Environment:
TouchGFX 4.25
STM32CubeMX generated project
STM32CubeIDE
Riverdi 12.1" board
STM32H7
FreeRTOS enabled
Debugging with ST-LINK
Problem:
BSP_SD_Init() returns MSD_ERROR_SD_NOT_PRESENT.
In main.c:
uint8_t res;
res = BSP_SD_Init();
risultato = res;
if(res != 2)
{
Error_Handler();
}The value stored in risultato is:
MSD_ERROR_SD_NOT_PRESENT
Additional important behavior:
When I start a FreeRTOS task that accesses FATFS/SD, the display becomes completely black and TouchGFX no longer shows images.
This is my task:
void StartDefaultTask(void *argument)
{
FIL file;
UINT bw;
for(;;)
{
SCB_CleanDCache();
SCB_InvalidateDCache();
if(BSP_SD_Init() == MSD_OK)
{
if(f_mount(&SDFatFS, SDPath, 1) == FR_OK)
{
if(f_open(&file, "log.txt", FA_OPEN_ALWAYS | FA_WRITE) == FR_OK)
{
f_lseek(&file, f_size(&file));
char msg[] = "log entry\r\n";
f_write(&file, msg, strlen(msg), &bw);
f_close(&file);
}
}
}
osDelay(1000);
}
}If I completely comment out this task, TouchGFX works correctly and all images are displayed normally.
So:
With SD/FATFS task enabled → display becomes black
With SD/FATFS task disabled → GUI works correctly
Other details:
SDRAM initialized correctly
LTDC working before SD task starts
QSPI memory mapped mode enabled
FATFS enabled
MPU configured with SDRAM framebuffer as non-cacheable
MPU configuration:
MPU_InitStruct.BaseAddress = 0xD0000000; MPU_InitStruct.Size = MPU_REGION_SIZE_8MB; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
Questions:
Could this be a DCache/MPU coherency issue between TouchGFX and FATFS?
Is there a known issue with Riverdi BSP + SDMMC + TouchGFX?
Should SD buffers be placed in a dedicated MPU region?
Is calling SCB_CleanDCache() and SCB_InvalidateDCache() inside the task causing LTDC framebuffer corruption?
Is there a recommended STM32H7 cache configuration for TouchGFX + FATFS?
Any suggestion is appreciated.
Thanks.