psram_allocator macro resulting in panic on ESP32-S3

BattieBoHattie
Posts: 1
Joined: Thu Dec 18, 2025 1:53 pm

psram_allocator macro resulting in panic on ESP32-S3

Postby BattieBoHattie » Fri Dec 19, 2025 9:21 pm

I have enabled psram in Cargo.toml:

Code: Select all

esp-hal = { version = "1.0.0", features = ["defmt", "esp32s3", "unstable", "psram"] 
Dutifully following the instructions at https://docs.espressif.com/projects/rus ... index.html, I have put:

Code: Select all

esp_alloc::psram_allocator!(&peripherals.PSRAM, esp_hal::psram);
in my code. This results in a panic. I tracked down the source of the panic to this line within the aforementioned macro:

Code: Select all

let (start, size) = _psram::psram_raw_parts(&$peripheral);
I have also tried to configure:

Code: Select all

CONFIG_SPIRAM_MODE_OCT=y
to no avail.

Curiously, I see the following output after I run:

Code: Select all

cargo run --release

Code: Select all

[INFO ] chip id = ffffff (esp_hal src/psram/esp32s3.rs:218)
[INFO ] size is 0 (esp_hal src/psram/esp32s3.rs:241)
[INFO ] PSRAM core_clock SpiTimingConfigCoreClock80m, flash_div = 1, psram_div = 2 (esp_hal src/psram/esp32s3.rs:385)
Could this be related to my problem? I have replicated this on 3 different ESP32-S3 boards from 3 different manufacturers.

Thank you for your time.

BattieBoHattie
Posts: 1
Joined: Thu Dec 18, 2025 1:53 pm

Re: psram_allocator macro resulting in panic on ESP32-S3

Postby BattieBoHattie » Sat Dec 20, 2025 9:42 am

Edit: It works on boards using espressif modules but I cannot seem to get this to work for a board directly using an S3R8
A solution!
If I configure the psram as suggested in: https://github.com/esp-rs/esp-hal/issues/3956 and https://docs.espressif.com/projects/esp ... onfig.html (of particular note are the hardware tables listing the compatible flash and psram speeds)

Code: Select all

let psram_config = psram::PsramConfig { ram_frequency:  psram::SpiRamFreq::Freq80m, core_clock: core::prelude::v1::Some(SpiTimingConfigCoreClock::SpiTimingConfigCoreClock160m), ..Default::default() };
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max()).with_psram(psram_config);
The code no longer panics when attempting to initialize the allocator and can subsequently allocate to the psram.
Last edited by BattieBoHattie on Sat Dec 20, 2025 12:10 pm, edited 1 time in total.

lichurbagan
Posts: 62
Joined: Thu Nov 13, 2025 3:20 pm

Re: psram_allocator macro resulting in panic on ESP32-S3

Postby lichurbagan » Sat Dec 20, 2025 12:26 pm

You can manually initialize PSRAM before using the allocator.
You must explicitly initialize PSRAM before

Code: Select all

esp_alloc::psram_allocator!(...)
At the moment, esp-hal does not expose a stable, public API for full PSRAM init on S3 without a bootloader.
In practice, this option is not recommended unless you are willing to patch esp-hal.

Who is online

Users browsing this forum: No registered users and 1 guest