esp-rs / esp-hal

no_std Hardware Abstraction Layers for ESP32 microcontrollers
https://docs.esp-rs.org/esp-hal/
Apache License 2.0
630 stars 173 forks source link

Cache/Memory mapping #955

Open MabezDev opened 8 months ago

MabezDev commented 8 months ago

Copied from https://github.com/esp-rs/esp-hal/issues/954#issuecomment-1816696280

Huh, last time I went looking into how the cache works it was all ROM code and zero docs. Now there is a esp_mm component: https://github.com/espressif/esp-idf/tree/c8243465e45489835d645bf217a6929fd0c01b7f/components/esp_mm with some docs as to how it works. Maybe we should try and port some of this into esp-hal.

We could replace this piece of code (which is currently hardcoded) with a proper cache driver.

One limitation we have is that I don't think any of the cache registers are in the SVDs - but it looks like there is only one register with just a few bits: https://github.com/espressif/esp-idf/blob/c8243465e45489835d645bf217a6929fd0c01b7f/components/esp_mm/include/esp_cache.h#L21-L47

bjoernQ commented 8 months ago

Ah we actually configure something for S3, didn't knew that 🤔 Oh - that was me

ProfFan commented 8 months ago

Ah we actually configure something for S3, didn't knew that 🤔 Oh - that was me

Is the DCACHE only enabled when using the PSRAM driver?

bjoernQ commented 7 months ago

I think for most targets the second stage bootloader will enable it and use whatever was configured when building it For S3 (something I re-learned) we always configure it in esp-hal. It's a bit inconsistent IMHO