diff --git a/components/esp_psram/device/esp_psram_impl_ap_quad.c b/components/esp_psram/device/esp_psram_impl_ap_quad.c index a269751388..742b2315c0 100644 --- a/components/esp_psram/device/esp_psram_impl_ap_quad.c +++ b/components/esp_psram/device/esp_psram_impl_ap_quad.c @@ -267,9 +267,14 @@ esp_err_t esp_psram_impl_enable(void) s_psram_size = PSRAM_SIZE_8MB; } else { uint8_t density = PSRAM_SIZE_ID(psram_id); + const int eid = PSRAM_EID_BIT_47_40(psram_id); s_psram_size = density == 0x0 ? PSRAM_SIZE_2MB : density == 0x1 ? PSRAM_SIZE_4MB : - density == 0x2 ? PSRAM_SIZE_8MB : 0; + density == 0x2 ? PSRAM_SIZE_8MB : + /* Do not use `density` for QEMU PSRAM since we don't want any future QSPI PSRAM + * that are 16MB or 32MB to be interpreted as QEMU PSRAM devices */ + eid == PSRAM_QEMU_16MB_ID ? PSRAM_SIZE_16MB : + eid == PSRAM_QEMU_32MB_ID ? PSRAM_SIZE_32MB : 0; } if ((s_psram_size == PSRAM_SIZE_8MB) && s_check_aps3204_2tmode()) { diff --git a/components/esp_psram/device/esp_quad_psram_defs.h b/components/esp_psram/device/esp_quad_psram_defs.h index 67b5044f3f..e78437768f 100644 --- a/components/esp_psram/device/esp_quad_psram_defs.h +++ b/components/esp_psram/device/esp_quad_psram_defs.h @@ -70,6 +70,10 @@ extern "C" { #define PSRAM_CS_HOLD_VAL 1 #define PSRAM_CS_SETUP_VAL 1 +// QEMU has a simulated 16MB and 32MB Quad SPI PSRAM. Use a fake ID for these. +#define PSRAM_QEMU_16MB_ID 0x6a +#define PSRAM_QEMU_32MB_ID 0x8e + #ifdef __cplusplus } #endif