I am trying to understand a way to invalidate the cache whenever i want to read some data from PSRAM.
for example.
byte *memory = (byte *)ps_malloc(1024*64);
loop:
memcpy(memory, memory, 1024);
goto loop:
The first access takes around ~600us and consequent memcpy takes only 80us. I think the value is loaded to the cache and the operation happens in the dcache rather than on the psram hardware. This is for a research purpose. so there is no practical need for this option.
but I want to know if i can disable the cache for such memcpy operation so the operation happens on the PSRAM directly and not through the cache. I dont care about the execution time. i want to have direct access to the psram without any cache.
xthal_dcache_line_invalidate() this has no effect
Invalidate cache
Re: Invalidate cache
Which IDF version and which chip are you using? We have added an API "esp_cache_msync" in IDF v5.1, but it only works on ESP32-S2 and later chips.
ESP32 doesn't have a hardware feature to write back all the cache contents. (It can invalidate the cache, but invalidating cache when the program is running is not safe since writes previously done into PSRAM by other parts of the code may get lost.)
On ESP32, the only way to do this is to read around 64kB of data from some location in PSRAM other than the one where your buffer is. This will cause the cache to be refilled with that new data, and old data will be written back.
ESP32 doesn't have a hardware feature to write back all the cache contents. (It can invalidate the cache, but invalidating cache when the program is running is not safe since writes previously done into PSRAM by other parts of the code may get lost.)
On ESP32, the only way to do this is to read around 64kB of data from some location in PSRAM other than the one where your buffer is. This will cause the cache to be refilled with that new data, and old data will be written back.
Who is online
Users browsing this forum: bfredo123, Bing [Bot], Google [Bot] and 101 guests