Bug in fx_stm32_sd_driver.c
I think I have found a bug in the mentioned file (in my case the file comes from x-cube_azrtos-h7, but the problem seems to be present in other versions to).
In the function fx_stm32_sd_driver() there is a check that the passed Databuffer (media_ptr→fx_media_driver_buffer) is 4 Byte alligned, if this is true then the function sd_read_data() uses directly the passed buffer otherwise it uses a local scratch buffer. But after the DMA the function needs to invalidate the cache (by calling invalidate_cache_by_addr), on the Cortex M7 a cache line is 32 Byte.
This may overwrite data in the cache out side of the buffer.
Correction:
Set use_scratch_buffer to false only when fx_media_driver_buffer is 32 Byte aligned and a multiple of 32 Byte.
