2022-09-12 06:36 AM
Hi
In the various filex with SDMMC examples the icache and dcache are enabled so when porting I did the same.
I noticed when attempting to use DMA SPI it was not working until I disabled these.
For the SD I then have to disable cache and cache management and as far as I can tell it works, if not then then the attempts to invalidate and clean the cache result in hardfault.
Is this a reasonable solution? Or should the cache be enabled and managed by invalidating the cache for the DMA SPI reads?
Thanks in advance
2022-09-12 06:41 AM
Disabling caches degrades performance of everything.
Best to manage specific buffers, with suitable alignment, limited scope and avoid collateral damage to surrounding data/structures.
2022-09-13 01:36 AM
Thanks.
So, declare buffers with ALIGN_32BYTES
Before each DMA SPI operation, the address TX buffer should be cleaned and RX invalidated.
I have no idea what the performance hit of this invalidation is, perhaps for small ~4 byte operations it's simpler to poll.
2022-10-05 03:34 AM
Hi,
Another solution is to allocate the buffers in an uncached area by configuring the MPU, without the need to disavble the cache.
regards
Haithem.
2022-10-05 12:37 PM
> for small ~4 byte operations
Put the buffers in a memory configured as non-cacheable by MPU.
2022-10-06 05:55 AM
thanks, I will have to look at the MPU examples to understand how this is done.
Invalidating the cache before seemed to be sufficient, although from the above example it appears as though it needs to be done after as well..
In my specific case, depending on the size of the message being read in it could be more or less than 32 bytes, although as mentioned the spi commands are usually around 4 bytes.