2024-11-12 03:05 AM - last edited on 2024-11-12 03:21 AM by Andrew Neil
All my code works on RTOS.
When I enable D-Cache,fs_mount() from FATFS on SD card returns FR_NO_FILESYSTEM,SD card can not work.
When I disable D-Cache, fs_mount() returns FR_OK, SD card can write and read.
But at the same time , i need to use Ethernet on my device . When I close D-Cache, my Ethernet can not work.
How can I resolve these two conflicting issues?
Solved! Go to Solution.
2024-11-12 03:29 AM - edited 2024-11-12 03:33 AM
Hello @ClockZLZ and welcome to the community.
Most probably it's something related to cache coherency/maintenance.
See this thread:
2024-11-12 03:22 AM - edited 2024-11-12 03:24 AM
FatFS is open-source.
So step into fs_mount() and see exactly where it is failing, and what causes that failure.
Similarly, step the code in the working case and see where it differs.
PS:
@ClockZLZ wrote:at the same time , i need to use Ethernet on my device . When I close D-Cache, my Ethernet can not work.
Are you sure that the issue is actually to do with D-Cache, or is it some other conflict between your Ethernet & SD-Card stuff ...?
2024-11-12 03:29 AM - edited 2024-11-12 03:33 AM
Hello @ClockZLZ and welcome to the community.
Most probably it's something related to cache coherency/maintenance.
See this thread:
2024-11-12 03:35 AM - edited 2024-11-12 03:38 AM
> When I close D-Cache, my Ethernet can not work.
Does it crash / catch exception or fault when you disable D-cache? Ethernet should work even without D-cache, at least on older 'H7 such as H743.
Using the Cortex-M7 D-cache correctly is not trivial, this is why it is not enabled by default. When the cache is disabled, most libraries made for Cortex-M4 can be reused as is.
2024-11-12 05:04 PM
My SD card problem is the same as:
Solved: Re: fs_mount() from FATFS on SD card returns FR_NO... - STMicroelectronics Community
The Ethernet part is maintained by my colleague,i will make sure if there is any other conflict between your Ethernet & SD-Card.
thank you for your opinion!
2024-11-12 05:15 PM
Thank you very much for your opinion !
No crash or fault occure when I disable D-cache. In fact , in order to make Ethernet work will , I enable D-cache and MPU for it.
If you are sure Ethernet can work without D-cache. I will have a try.
2024-11-12 06:16 PM
it's usef to uncomment L63 in sd_diskio.c to activate Cache maintenance:
/* USER CODE BEGIN enableSDDmaCacheMaintenance */ #define ENABLE_SD_DMA_CACHE_MAINTENANCE 1 /* USER CODE END enableSDDmaCacheMaintenance */
After doing this my SD Card can mount successfully when D-cache is enabled.
2024-11-13 04:07 AM
> If you are sure Ethernet can work without D-cache. I will have a try.
I got it working on STM32H743/53 with some previous version of ST libraries and ETH driver, not sure that the current will work as is. Hardware itself does work with properly assigned memories and no D-cache.