SD Card + RTOS on F7 processor won't work with D-Cache enabled! (My fix below)
*** EDIT ***
Seems this was a memory issue rather than a D-Cache issue, the D-Cache option fixed it as a side effect!
*** EDIT ***
I have a project setup as follows:
STM32F765IIKx
RTOS
SD Card on SDMMC1 configured as SD 4 bits Wide, DMA Enabled
I followed this example, however, after a day of head scratching and nothing working I found that the only way to get it to work was disable the D-Cache. Once I had found this issue I remembered seeing the option within the "sd_dsikio.c" file for cache maintenance.
/*
* when using cacheable memory region, it may be needed to maintain the cache
* validity. Enable the define below to activate a cache maintenance at each
* read and write operation.
* Notice: This is applicable only for cortex M7 based platform.
*/
/* 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 */At a punt I decided to set this option and re-enable the D-Cache, this now works.
So why is it that the F7 processor also requires this cache maintenance setting for SD to work properly? I've not used any cache maintenance with my UART DMA routines and they work fine on this F7 processor, however I did need UART DMA cache maintenance on anther project using an H7 processor?
*EDIT*
I also needed this config switch set! I had removed it thinking it was only the D-Cache issue but this is also required for correct operation.
/* USER CODE BEGIN enableScratchBuffer */
#define ENABLE_SCRATCH_BUFFER
/* USER CODE END enableScratchBuffer */#define ENABLE_SCRATCH_BUFFER
Matt.
