Using segmentation fault to bridge different memory segments?

marcmerlin
Posts: 30
Joined: Mon Apr 17, 2017 12:50 am

Using segmentation fault to bridge different memory segments?

Postby marcmerlin » Wed Feb 17, 2021 2:49 am

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?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Using segmentation fault to bridge different memory segments?

Postby ESP_Angus » 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

marcmerlin
Posts: 30
Joined: Mon Apr 17, 2017 12:50 am

Re: Using segmentation fault to bridge different memory segments?

Postby marcmerlin » Wed Feb 17, 2021 3:44 am

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.

Who is online

Users browsing this forum: No registered users and 47 guests