Page 1 of 1

Using segmentation fault to bridge different memory segments?

Posted: Wed Feb 17, 2021 2:49 am
by marcmerlin
I need an array of 224KB but you can only get around 160KB contiguous memory on ESP32. If I could split the array in 2 regions, then I can get the 224KB I need, but I have lots of code (including external libraries I don't control) that expect that memory block to be an array that must be contiguous.

I have a board I don't control ESP32, unfortunately without PSRAM (I'd be set with PSRAM).
http://www.openhardwareconf.org/wiki/Sw ... ingStarted

Unfortunately, even lolin can't manage to have a common pinout across their chips, so I can't replace that D32 lite with a D32 pro with PSRAM since none of the pins are compatible :(

So now I'm going to waste a fair amount of time in software to work around this, it's enough pain that I may just give up entirely as in not worth my time to spend so much effort to work around unfortunate hardware limitations.
But I was thinking: ESP32 knows how to page in PSRAM and make it look like a single block.
Can that PC EMS-like memory manager be used to allocate 224KB in different blocks, and make it look like a contiguous block to user code?

Re: Using segmentation fault to bridge different memory segments?

Posted: Wed Feb 17, 2021 3:35 am
by ESP_Angus
Hi Marc,

I'm afraid this isn't possible. The "MMU" in ESP32 is limited to cache access (PSRAM and flash only), it's not possible to remap internal memory access.

Do you have 224KB of free contiguous space immediately on boot (after other memory is reclaimed by the bootloader?) If yes, then you could malloc() this buffer and pass around a pointer in place of the static variable.

Angus

Re: Using segmentation fault to bridge different memory segments?

Posted: Wed Feb 17, 2021 3:44 am
by marcmerlin
ESP_Angus wrote:
Wed Feb 17, 2021 3:35 am
Hi Marc,

I'm afraid this isn't possible. The "MMU" in ESP32 is limited to cache access (PSRAM and flash only), it's not possible to remap internal memory access.

Do you have 224KB of free contiguous space immediately on boot (after other memory is reclaimed by the bootloader?) If yes, then you could malloc() this buffer and pass around a pointer in place of the static variable.

Angus
Thanks for the reply and confirming that I can't play hardware tricks to achieve what I needed.

Getting the memory earlier, not sure if it's possible. I had to refer to my own talk on the segment sizes and it seems that 180KB is the biggest one:
http://marc.merlins.org/linux/talks/ESP ... /img7.html
which came from
https://docs.espressif.com/projects/esp ... alloc.html

I'm not sure if I can modify esp32-arduino or switch to esp32-idf to get a larger block, but my understanding was that those non contiguous blocks were a hardware limitation.

Anyway, it sounds like I'm probably out of luck, on this one, and will have to find another approach, or just give up on that chip.
Thanks for the quick reply.