Mapping external SRAM to instruction space on the ESP32?

hjalfi
Posts: 9
Joined: Sat Oct 02, 2021 9:38 am

Mapping external SRAM to instruction space on the ESP32?

Postby hjalfi » Sat Oct 30, 2021 6:36 pm

I've been looking at doing a Fuzix port (a very small, light-weight Unix clone) for the ESP32. I've got a ESP32-WROVER device, which means it's got 8MB of external QSPI SRAM.

What I'd really like to do is to split this into 4MB for process data and 4MB for process code; the programs would actually be stored on external flash, and copied to this space as they're loaded. I can then subdivide them per process using the Cache MMU so that each process sees its code and data at the same address.

However, the Technical Reference appears to say that external SRAM can only be mapped to data space. Is this correct, or is it a documentation error? If it is correct, is there any other way to store code in external SRAM?

(My backup plan is to use SRAM 0 and 1 for program storage, but SRAM1 doesn't have an MMU. I could just use SRAM 0 and swap process code in and out of external SRAM as needed but that's terrible, and I'm hoping to avoid it.)

ESP_Sprite
Posts: 9592
Joined: Thu Nov 26, 2015 4:08 am

Re: Mapping external SRAM to instruction space on the ESP32?

Postby ESP_Sprite » Sun Oct 31, 2021 3:25 am

That is correct, the ESP32 cannot store instructions in external RAM. The later chips (ESP32S2, ESP32S3) are able to; perhaps you can use one of those.

hjalfi
Posts: 9
Joined: Sat Oct 02, 2021 9:38 am

Re: Mapping external SRAM to instruction space on the ESP32?

Postby hjalfi » Sun Oct 31, 2021 10:31 am

ESP_Sprite wrote:
Sun Oct 31, 2021 3:25 am
That is correct, the ESP32 cannot store instructions in external RAM. The later chips (ESP32S2, ESP32S3) are able to; perhaps you can use one of those.
Curses! Unfortunately I'm targeting a ESP32-WROVER and ESP32-WROOM, so I have to use the classic ESP32.

I think swap's probably my best option. I do have 256kB of combined memory-mappable memory, which is a decent amount of Fuzix. The kernel (code and data) can live in SRAM1. Not needing to use external memory or flash frees up more of that and makes the design easier too. On the WROVER the PSRAM can be exposed as a cheap swap device. It's just a shame that SRAM0 can't be DMAd into.

Who is online

Users browsing this forum: Google [Bot] and 169 guests