espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.24k stars 7.19k forks source link

PSRAM manual memory management (IDFGH-12832) #13799

Open nvx opened 3 months ago

nvx commented 3 months ago

Is your feature request related to a problem?

As per https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-guides/external-ram.html#integrate-ram-into-the-esp32-s3-memory-map it is possible to set the PSRAM to get mapped into the address space without adding it to the allocator, but there is no way to find the offset and size of usable space to be able to make use of the PSRAM when this route is taken.

Describe the solution you'd like.

An API in esp_psram to read the base address that the PSRAM has been mapped into as well as the size of the mapping from user code would be perfect.

Describe alternatives you've considered.

It appears in previous versions of the ESP-IDF the PSRAM was mapped to a static offset so it was possible to access it that way, but current versions map it dynamically so this approach no longer works.

Additional context.

It'd be good if the offset and size returned were the same that would normally be passed to the allocator when using PSRAM with the allocator as then it would still enable the use of PSRAM caching of instructions and rodata too.

eriksl commented 2 months ago

Just out of curiosity, can't you just allocate all of it using malloc_heap_caps in one go and then manage it yourself? I am doing something similar with RTC FAST memory.