ESP32-S3 PSRAM issue

maskemaske
Posts: 9
Joined: Fri Oct 08, 2021 3:43 pm

ESP32-S3 PSRAM issue

Postby maskemaske » Wed Sep 07, 2022 2:02 pm

Hello, we planned to put a ~110KB buffer into SPIRAM (SPIRAM chip size is 2MiB).
Since it is the only thing we need in this memory area, we tried to use the simple method of integrating the SPI ram into the memory map, and access it with pointers. Note that the integrated SPI ram test is enabled and succeeds ("spiram: Found 16MBit SPI RAM device")

Using Menuconfig>Component Config>ESP32S3-Specific>SPI RAM config>SPI RAM access method>Integrate RAM into memory map

From https://docs.espressif.com/projects/esp ... l-ram.html
During the ESP-IDF startup, external RAM is mapped into the data address space, starting at address 0x3D000000 (byte-accessible)
So the most simple test; read 16 bytes starting from 0x3D000000, overwrite them, read them again: https://pastebin.com/mX1CKhhA
This is it's log-output (after the usual bootloader stuff):
I (0) cpu_start: Starting scheduler on APP CPU.
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0x28 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42001d95
0x42001d95: panic_handler at /home/user/esp/esp-idf/components/esp_system/port/panic_handler.c:148 (discriminator 3)
It doesnt even print the first byte.

Q1: Why does this fail? What needs to be done to make this work?

Q2: we have changed the setup, so we are instead using "Make RAM allocatable using heap_caps_malloc". When malloc'ing the required amount of memory, the first returned address is 0x3DE00974. Why does this not start at 0x3D000000? We have not done any special configuration to put espressif logic components into this memory (USB, BLE, WiFi disabled). And the module still panics when accessing 0x3D000000 with a raw pointer.

Q3: using the "integrated into memory map" method, it works fine using 0x3DE00000 as starting address. Maybe the documentation is wrong?

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

Re: ESP32-S3 PSRAM issue

Postby ESP_Sprite » Thu Sep 08, 2022 2:35 am

I think you're right in that the docs are wrong: I guess that address was valid for the ESP32 (and possibly -S2) but not for the ESP32S3. The ESP32 has an unified 32MiB address space to map both flash and psram to, and what I think is happening here is that part of your application in flash is mapped to the first part of that address space, and the psram to the first available address after that, hence the strange address. (Note that this also makes using a hardcoded address brittle: if the size of the rodata/text segments of your application ever change, the base address of PSRAM will change. Not ideal.)

Suggest you use 'Make RAM allocatable using heap_caps_malloc' for now; aside from a small amount of PSRAM usage, it doesn't really impact things. I'll file an internal ticket to see if we can fix the 'integrate into memory map' option.

EricVs
Posts: 2
Joined: Thu Oct 13, 2022 4:30 pm

Re: ESP32-S3 PSRAM issue

Postby EricVs » Thu Oct 13, 2022 5:26 pm

I have been trying a similar thing on the ESP32-S3-WROOM-1U P1N8R8, using IDF 4.4.2 and I confirm the issue.
My conclusion is:
- the documentation seems incorrect : the PSRAM is not mapped at 0x3D000000
- it is mapped at 0x3E000000 - size(PSRAM) = 0x3D800000 in my case, works fine like that :)
- the dynamic allocations may not work properly, I use the "Integrate RAM into the ESP32-S3 Memory Map" option.

Who is online

Users browsing this forum: No registered users and 325 guests