cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in fx_stm32_sd_driver.c

MHoll.2
Senior III

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.

1 REPLY 1
Khaled_DHIF
ST Employee

Hello @MHoll.2 , 

Thank you for bringing this issue to our attention.

I have escalated it to the relevant internal team for further investigation.

Internal ticket number: 223007 (This is an internal tracking number and is not accessible or usable by customers).

Kind regards, 

DHIF Khaled

Please mark my answer as best by clicking on the “Accept as solution" button if it fully answered your question. This will help other users find this solution faster.​