How to allocate PSRAM for only one CPU core on ESP32 Xtensa

QlifeDeveloper
Posts: 7
Joined: Wed Nov 09, 2022 9:02 pm

How to allocate PSRAM for only one CPU core on ESP32 Xtensa

Postby QlifeDeveloper » Mon Nov 21, 2022 7:49 am

Hi
I need to reserve one CPU core for critical interrupt and WIFI handling.
When I use PSRAM the CPU core accessing the PSRAM will get stalled until PSRAM data transmission is concluded.
How can I configure ESP-IDF to only allocate PSRAM for one CPU core so the other CPU core won't get stalled due to PSRAM access?
Thanks in advance!
Best regards Søren

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

Re: How to allocate PSRAM for only one CPU core on ESP32 Xtensa

Postby ESP_Sprite » Mon Nov 21, 2022 9:01 am

PSRAM access by itself doesn't stall both cores, only the core that is affected. However, what you may be seeing is that PSRAM and flash use the same bus, and as such the processor not using psram will be stalled on a cache miss as it needs to wait for the PSRAM access to finish before it can do a flash access.

QlifeDeveloper
Posts: 7
Joined: Wed Nov 09, 2022 9:02 pm

Re: How to allocate PSRAM for only one CPU core on ESP32 Xtensa

Postby QlifeDeveloper » Mon Nov 21, 2022 10:34 am

ESP_Sprite wrote:
Mon Nov 21, 2022 9:01 am
PSRAM access by itself doesn't stall both cores, only the core that is affected. However, what you may be seeing is that PSRAM and flash use the same bus, and as such the processor not using psram will be stalled on a cache miss as it needs to wait for the PSRAM access to finish before it can do a flash access.
Thanks for your input.
My concern is that any cache miss in the PSRAM stalls the core. My timing constraints does not leave time for the core to stall for the time period it takes to access PSRAM. I need to assign one core for handling timing critical functionality which does not access PSRAM.
Best regards Søren

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

Re: How to allocate PSRAM for only one CPU core on ESP32 Xtensa

Postby ESP_Sprite » Tue Nov 22, 2022 6:47 am

The only solution to that would be to make sure that any time-critical code you have runs entirely (including any functions it calls) in IRAM.

(Also, what are you doing that requires timing that tight? Are you sure you can't handle it in hardware, with e.g. the RMT peripheral?)

QlifeDeveloper
Posts: 7
Joined: Wed Nov 09, 2022 9:02 pm

Re: How to allocate PSRAM for only one CPU core on ESP32 Xtensa

Postby QlifeDeveloper » Wed Nov 23, 2022 9:35 am

Hi
Thanks for your replies :)
Is it correct that a cache miss in the PSRAM area just triggers functionality implemented in the Espressif "spiram_psram.c" module?
And thereby only stalls the current thread accessing the PSRAM?
Thanks in advance!
Best regards Søren

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

Re: How to allocate PSRAM for only one CPU core on ESP32 Xtensa

Postby ESP_Sprite » Wed Nov 23, 2022 1:47 pm

No, it does not trigger any software routine; cache misses are handled in hardware. As such, they will stall the entire core that does the read; hardware is not aware of threading.

Who is online

Users browsing this forum: Lobelois, ltsm0265 and 95 guests