From 9de04b9f5f92af1a6623828833680b63f19c23cc Mon Sep 17 00:00:00 2001 From: chenjianqiang Date: Fri, 3 Jul 2020 22:13:00 +0800 Subject: [PATCH] feat(psram): support 16Mbit PSRAM for esp32 --- components/esp32/Kconfig | 4 ++++ components/esp32/spiram.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index dbe79dcdb4..24edd35eaa 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -78,6 +78,9 @@ menu "ESP32-specific" config SPIRAM_TYPE_AUTO bool "Auto-detect" + config SPIRAM_TYPE_ESPPSRAM16 + bool "ESP-PSRAM16 or APS1604" + config SPIRAM_TYPE_ESPPSRAM32 bool "ESP-PSRAM32 or IS25WP032" @@ -89,6 +92,7 @@ menu "ESP32-specific" config SPIRAM_SIZE int default -1 if SPIRAM_TYPE_AUTO + default 2097152 if SPIRAM_TYPE_ESPPSRAM16 default 4194304 if SPIRAM_TYPE_ESPPSRAM32 default 8388608 if SPIRAM_TYPE_ESPPSRAM64 default 0 diff --git a/components/esp32/spiram.c b/components/esp32/spiram.c index c1bd976a17..20f9921ad2 100644 --- a/components/esp32/spiram.c +++ b/components/esp32/spiram.c @@ -114,12 +114,14 @@ bool esp_spiram_test(void) void IRAM_ATTR esp_spiram_init_cache(void) { + int size = esp_spiram_get_size(); + if (size > 4 * 1024 * 1024) size = 4 * 1024 * 1024; // we can map at most 4MByte //Enable external RAM in MMU - cache_sram_mmu_set( 0, 0, SOC_EXTRAM_DATA_LOW, 0, 32, 128 ); + cache_sram_mmu_set(0, 0, SOC_EXTRAM_DATA_LOW, 0, 32, (size / 1024 / 32)); //Flush and enable icache for APP CPU #if !CONFIG_FREERTOS_UNICORE DPORT_CLEAR_PERI_REG_MASK(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MASK_DRAM1); - cache_sram_mmu_set( 1, 0, SOC_EXTRAM_DATA_LOW, 0, 32, 128 ); + cache_sram_mmu_set(1, 0, SOC_EXTRAM_DATA_LOW, 0, 32, (size / 1024 / 32)); #endif }