psram: support for esp32-pico-v3-02
1. Support for 16Mbit PSRAM 2. Support for esp32-pico-v3-02 3. Use package identifier to look up SPI flash/PSRAM WP Pin, unless overridden Closes https://github.com/espressif/esp-idf/issues/7189
This commit is contained in:
@@ -112,6 +112,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"
|
||||
|
||||
@@ -123,6 +126,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
|
||||
@@ -340,23 +344,37 @@ menu "ESP32-specific"
|
||||
|
||||
endmenu
|
||||
|
||||
config SPIRAM_SPIWP_SD3_PIN
|
||||
int "SPI PSRAM WP(SD3) Pin when customising pins via eFuse (read help)"
|
||||
config SPIRAM_CUSTOM_SPIWP_SD3_PIN
|
||||
bool "Use custom SPI PSRAM WP(SD3) Pin when flash pins set in eFuse (read help)"
|
||||
depends on FLASHMODE_DIO || FLASHMODE_DOUT
|
||||
default y if SPIRAM_SPIWP_SD3_PIN != 7 # backwards compatibility, can remove in IDF 5
|
||||
default n
|
||||
help
|
||||
This setting is only used if the SPI flash pins have been overridden by setting the eFuses
|
||||
SPI_PAD_CONFIG_xxx, and the SPI flash mode is DIO or DOUT.
|
||||
|
||||
When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka
|
||||
ESP32 pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. The psram only has QPI
|
||||
mode, so a WP pin setting is necessary.
|
||||
|
||||
If this config item is set to N (default), the correct WP pin will be automatically used for any
|
||||
Espressif chip or module with integrated flash. If a custom setting is needed, set this config item
|
||||
to Y and specify the GPIO number connected to the WP pin.
|
||||
|
||||
When flash mode is set to QIO or QOUT, the PSRAM WP pin will be set the same as the SPI Flash WP pin
|
||||
configured in the bootloader.
|
||||
|
||||
config SPIRAM_SPIWP_SD3_PIN
|
||||
int "Custom SPI PSRAM WP(SD3) Pin"
|
||||
depends on FLASHMODE_DIO || FLASHMODE_DOUT
|
||||
#depends on SPIRAM_CUSTOM_SPIWP_SD3_PIN # backwards compatibility, can uncomment in IDF 5
|
||||
range 0 33
|
||||
default 7
|
||||
help
|
||||
This value is ignored unless flash mode is set to DIO or DOUT and the SPI flash pins have been
|
||||
overriden by setting the eFuses SPI_PAD_CONFIG_xxx.
|
||||
The option "Use custom SPI PSRAM WP(SD3) pin" must be set or this value is ignored
|
||||
|
||||
When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka
|
||||
ESP32 pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. And the psram only has QPI
|
||||
mode, the WP pin is necessary, so we need to configure this value here.
|
||||
|
||||
When flash mode is set to QIO or QOUT, the PSRAM WP pin will be set as the value configured in
|
||||
bootloader.
|
||||
|
||||
For ESP32-PICO chip, the default value of this config should be 7.
|
||||
If burning a customized set of SPI flash pins in eFuse and using DIO or DOUT mode for flash, set this
|
||||
value to the GPIO number of the SPIRAM WP pin.
|
||||
|
||||
config SPIRAM_2T_MODE
|
||||
bool "Enable SPI PSRAM 2T mode"
|
||||
|
||||
@@ -159,7 +159,6 @@ void IRAM_ATTR call_start_cpu0()
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_BOOT_INIT
|
||||
esp_spiram_init_cache();
|
||||
if (esp_spiram_init() != ESP_OK) {
|
||||
#if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init external RAM, needed for external .bss segment");
|
||||
@@ -174,6 +173,7 @@ void IRAM_ATTR call_start_cpu0()
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
esp_spiram_init_cache();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ
|
||||
|
||||
@@ -114,12 +114,14 @@ bool esp_spiram_test()
|
||||
|
||||
void IRAM_ATTR esp_spiram_init_cache()
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
@@ -127,7 +129,7 @@ esp_spiram_size_t esp_spiram_get_chip_size()
|
||||
{
|
||||
if (!spiram_inited) {
|
||||
ESP_EARLY_LOGE(TAG, "SPI RAM not initialized");
|
||||
return ESP_SPIRAM_SIZE_INVALID;
|
||||
abort();
|
||||
}
|
||||
psram_size_t psram_size = psram_get_size();
|
||||
switch (psram_size) {
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "driver/spi_common.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
|
||||
#if CONFIG_SPIRAM_SUPPORT
|
||||
#include "soc/rtc.h"
|
||||
@@ -121,6 +122,9 @@ typedef enum {
|
||||
#define PICO_PSRAM_CLK_IO 6
|
||||
#define PICO_PSRAM_CS_IO CONFIG_PICO_PSRAM_CS_IO // Default value is 10
|
||||
|
||||
#define PICO_V3_02_PSRAM_CLK_IO 10
|
||||
#define PICO_V3_02_PSRAM_CS_IO 9
|
||||
|
||||
typedef struct {
|
||||
uint8_t flash_clk_io;
|
||||
uint8_t flash_cs_io;
|
||||
@@ -822,6 +826,16 @@ esp_err_t IRAM_ATTR psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vad
|
||||
s_clk_mode = PSRAM_CLK_MODE_NORM;
|
||||
psram_io.psram_clk_io = PICO_PSRAM_CLK_IO;
|
||||
psram_io.psram_cs_io = PICO_PSRAM_CS_IO;
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302) {
|
||||
ESP_EARLY_LOGI(TAG, "This chip is ESP32-PICO-V3-02");
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.tieh != RTC_VDDSDIO_TIEH_3_3V) {
|
||||
ESP_EARLY_LOGE(TAG, "VDDSDIO is not 3.3V");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
s_clk_mode = PSRAM_CLK_MODE_NORM;
|
||||
psram_io.psram_clk_io = PICO_V3_02_PSRAM_CLK_IO;
|
||||
psram_io.psram_cs_io = PICO_V3_02_PSRAM_CS_IO;
|
||||
} else if ((pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ6) || (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ5)){
|
||||
ESP_EARLY_LOGI(TAG, "This chip is ESP32-D0WD");
|
||||
psram_io.psram_clk_io = D0WD_PSRAM_CLK_IO;
|
||||
@@ -852,14 +866,7 @@ esp_err_t IRAM_ATTR psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vad
|
||||
psram_io.psram_spiq_sd0_io = EFUSE_SPICONFIG_RET_SPIQ(spiconfig);
|
||||
psram_io.psram_spid_sd1_io = EFUSE_SPICONFIG_RET_SPID(spiconfig);
|
||||
psram_io.psram_spihd_sd2_io = EFUSE_SPICONFIG_RET_SPIHD(spiconfig);
|
||||
|
||||
// If flash mode is set to QIO or QOUT, the WP pin is equal the value configured in bootloader.
|
||||
// If flash mode is set to DIO or DOUT, the WP pin should config it via menuconfig.
|
||||
#if CONFIG_FLASHMODE_QIO || CONFIG_FLASHMODE_QOUT
|
||||
psram_io.psram_spiwp_sd3_io = CONFIG_BOOTLOADER_SPI_WP_PIN;
|
||||
#else
|
||||
psram_io.psram_spiwp_sd3_io = CONFIG_SPIRAM_SPIWP_SD3_PIN;
|
||||
#endif
|
||||
psram_io.psram_spiwp_sd3_io = bootloader_flash_get_wp_pin();
|
||||
}
|
||||
|
||||
assert(mode < PSRAM_CACHE_MAX && "we don't support any other mode for now.");
|
||||
|
||||
@@ -380,7 +380,8 @@ void esp_chip_info(esp_chip_info_t* out_info)
|
||||
int package = (efuse_rd3 & EFUSE_RD_CHIP_VER_PKG_M) >> EFUSE_RD_CHIP_VER_PKG_S;
|
||||
if (package == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
|
||||
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
|
||||
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
|
||||
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 ||
|
||||
package == EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302) {
|
||||
out_info->features |= CHIP_FEATURE_EMB_FLASH;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user