Skip to content

PSRAM init fault when PSRAM does not exist and ignore not-found is set (IDFGH-4204) #6063

@ryankurte

Description

@ryankurte

When CONFIG_SPIRAM_IGNORE_NOTFOUND=y is set initialising a device with SPIRAM enabled causes a fault (rather than continuing to boot without enabling the additional PSRAM)

Environment

  • Development Kit: [ESP32-Wrover-Kit|ESP32-DevKitC|ESP32-PICO-Kit|ESP32-LyraT|ESP32-LyraTD-MSC|none]
  • Kit version (for WroverKit/PicoKit/DevKitC): n/a
  • Module or chip used: [ESP32-WROOM-32D]
  • IDF version (run git describe --tags to find it): v4.2-dev-2182-gdddcc2ede
  • Build System: [Make|CMake|idf.py]
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): xtensa-esp32-elf-gcc (crosstool-NG esp-2020r2) 8.2.0
  • Operating System: [Windows|Linux|macOS]
  • Using an IDE?: [No|Yes (please give details)]
  • Power Supply: [USB|external 5V|external 3.3V|Battery]

Problem Description

Configuring SPIRAM with auto-detect and ignore-notfound should (i believe) attempt to check the PSRAM exists and continue booting if not, instead this panics at esp_spiram_get_chip_size.

SPIRAM KConfig fields:

+CONFIG_ESP32_SPIRAM_SUPPORT=y
+
+#
+# SPI RAM config
+#
+CONFIG_SPIRAM_TYPE_AUTO=y
+# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
+# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
+# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
+CONFIG_SPIRAM_SIZE=-1
+CONFIG_SPIRAM_SPEED_40M=y
+CONFIG_SPIRAM=y
+CONFIG_SPIRAM_BOOT_INIT=y
+CONFIG_SPIRAM_IGNORE_NOTFOUND=y
+# CONFIG_SPIRAM_USE_MEMMAP is not set
+# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
+CONFIG_SPIRAM_USE_MALLOC=y
+CONFIG_SPIRAM_MEMTEST=y
+CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
+CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
+CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
+# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
+CONFIG_SPIRAM_CACHE_WORKAROUND=y

Expected Behavior

The device starts, attempts to detect SPIRAM and fails, then continues booting with available onboard memory.

Actual Behavior

The device detects RAM was not available, continues, and appears to fault while trying to fetch the SPIRAM size. See the logs below.

Steps to reproduce

  • Enable SPIRAM on a non-supported platform (or platform without SPIRAM)

Debug Logs

I (886) psram: This chip is ESP32-D0WD
E (892) psram: PSRAM ID read error: 0xffffffff
E (896) spiram: SPI RAM enabled but initialization failed. Bailing out.
I (903) cpu_start: Failed to init external RAM; continuing without it.
E (910) spiram: SPI RAM not initialized
Re-enable cpu cache.

abort() was called at PC 0x400d4faa on core 0
0x400d4faa: esp_spiram_get_chip_size at /opt/esp/idf/components/esp32/spiram.c:132 (discriminator 1)


Backtrace:0x40095b22:0x3ffe3b30 0x40096201:0x3ffe3b50 0x4009a939:0x3ffe3b70 0x400d4faa:0x3ffe3be0 0x400d5043:0x3ffe3c00 0x40082856:0x3ffe3c20 0x40082176:0x3ffe3c40 0x400793a2:0x3ffe3c80 |<-CORRUPTED
0x40095b22: panic_abort at /opt/esp/idf/components/esp_system/panic.c:330

0x40096201: esp_system_abort at /opt/esp/idf/components/esp_system/system_api.c:106

0x4009a939: abort at /opt/esp/idf/components/newlib/abort.c:46

0x400d4faa: esp_spiram_get_chip_size at /opt/esp/idf/components/esp32/spiram.c:132 (discriminator 1)

0x400d5043: esp_spiram_get_size at /opt/esp/idf/components/esp32/spiram.c:220

0x40082856: esp_spiram_init_cache at /opt/esp/idf/components/esp32/spiram.c:117

0x40082176: call_start_cpu0 at /opt/esp/idf/components/esp32/cpu_start.c:189

Notes

  • It would be viable to work around this if it was plausible to init / mount the PSRAM at runtime via an API? Whether this was possible to me was not clear from the API documentation.
  • Enabling PSRAM on a platform with this supported always overflows IRAM and requires wifi optimisations disabled (per Upgrading v3.3 to v4.0 with PSRAM, app no longer fits in IRAM (IDFGH-3664) #5598), it may be nice to document this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions