mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
esp32/esp32s2beta: Extract common SPIRAM options into esp_commmon component
This commit is contained in:

committed by
suda-morris

parent
06e31e243c
commit
ddbd09eb15
@@ -24,9 +24,12 @@ menu "ESP32-specific"
|
||||
default 160 if ESP32_DEFAULT_CPU_FREQ_160
|
||||
default 240 if ESP32_DEFAULT_CPU_FREQ_240
|
||||
|
||||
# Note: to support SPIRAM across multiple chips, check CONFIG_SPIRAM
|
||||
# instead
|
||||
config ESP32_SPIRAM_SUPPORT
|
||||
bool "Support for external, SPI-connected RAM"
|
||||
default "n"
|
||||
select SPIRAM
|
||||
help
|
||||
This enables support for an external SPI RAM chip, connected in parallel with the
|
||||
main SPI flash chip.
|
||||
@@ -34,41 +37,6 @@ menu "ESP32-specific"
|
||||
menu "SPI RAM config"
|
||||
depends on ESP32_SPIRAM_SUPPORT
|
||||
|
||||
config SPIRAM_BOOT_INIT
|
||||
bool "Initialize SPI RAM when booting the ESP32"
|
||||
default "y"
|
||||
help
|
||||
If this is enabled, the SPI RAM will be enabled during initial boot. Unless you
|
||||
have specific requirements, you'll want to leave this enabled so memory allocated
|
||||
during boot-up can also be placed in SPI RAM.
|
||||
|
||||
config SPIRAM_IGNORE_NOTFOUND
|
||||
bool "Ignore PSRAM when not found"
|
||||
default "n"
|
||||
depends on SPIRAM_BOOT_INIT && !SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
|
||||
help
|
||||
Normally, if psram initialization is enabled during compile time but not found at runtime, it
|
||||
is seen as an error making the ESP32 panic. If this is enabled, the ESP32 will keep on
|
||||
running but will not add the (non-existing) RAM to any allocator.
|
||||
|
||||
choice SPIRAM_USE
|
||||
prompt "SPI RAM access method"
|
||||
default SPIRAM_USE_MALLOC
|
||||
help
|
||||
The SPI RAM can be accessed in multiple methods: by just having it available as an unmanaged
|
||||
memory region in the ESP32 memory map, by integrating it in the ESP32s heap as 'special' memory
|
||||
needing heap_caps_malloc to allocate, or by fully integrating it making malloc() also able to
|
||||
return SPI RAM pointers.
|
||||
|
||||
config SPIRAM_USE_MEMMAP
|
||||
bool "Integrate RAM into ESP32 memory map"
|
||||
config SPIRAM_USE_CAPS_ALLOC
|
||||
bool "Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)"
|
||||
config SPIRAM_USE_MALLOC
|
||||
bool "Make RAM allocatable using malloc() as well"
|
||||
select FREERTOS_SUPPORT_STATIC_ALLOCATION
|
||||
endchoice
|
||||
|
||||
choice SPIRAM_TYPE
|
||||
prompt "Type of SPI RAM chip in use"
|
||||
default SPIRAM_TYPE_AUTO
|
||||
@@ -115,14 +83,6 @@ menu "ESP32-specific"
|
||||
bool "80MHz clock speed"
|
||||
endchoice
|
||||
|
||||
config SPIRAM_MEMTEST
|
||||
bool "Run memory test on SPI RAM initialization"
|
||||
default "y"
|
||||
depends on SPIRAM_BOOT_INIT
|
||||
help
|
||||
Runs a rudimentary memory test on initialization. Aborts when memory test fails. Disable this for
|
||||
slightly faster startop.
|
||||
|
||||
config SPIRAM_CACHE_WORKAROUND
|
||||
bool "Enable workaround for bug in SPI RAM cache for Rev1 ESP32s"
|
||||
depends on SPIRAM_USE_MEMMAP || SPIRAM_USE_CAPS_ALLOC || SPIRAM_USE_MALLOC
|
||||
@@ -136,6 +96,9 @@ menu "ESP32-specific"
|
||||
This will also not use any bits of newlib that are located in ROM, opting for a version that is
|
||||
compiled with the workaround and located in flash instead.
|
||||
|
||||
# insert non-chip-specific items here
|
||||
source "$IDF_PATH/components/esp_common/Kconfig.spiram.common"
|
||||
|
||||
config SPIRAM_BANKSWITCH_ENABLE
|
||||
bool "Enable bank switching for >4MiB external RAM"
|
||||
default y
|
||||
@@ -173,35 +136,6 @@ menu "ESP32-specific"
|
||||
from the non-preferred region instead, so malloc() will not suddenly fail when either internal or
|
||||
external memory is full.
|
||||
|
||||
config SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
bool "Try to allocate memories of WiFi and LWIP in SPIRAM firstly. If failed, allocate internal memory"
|
||||
depends on SPIRAM_USE_CAPS_ALLOC || SPIRAM_USE_MALLOC
|
||||
default "n"
|
||||
help
|
||||
Try to allocate memories of WiFi and LWIP in SPIRAM firstly. If failed, try to allocate internal
|
||||
memory then.
|
||||
|
||||
config SPIRAM_MALLOC_RESERVE_INTERNAL
|
||||
int "Reserve this amount of bytes for data that specifically needs to be in DMA or internal memory"
|
||||
depends on SPIRAM_USE_MALLOC
|
||||
default 32768
|
||||
range 0 262144
|
||||
help
|
||||
Because the external/internal RAM allocation strategy is not always perfect, it sometimes may happen
|
||||
that the internal memory is entirely filled up. This causes allocations that are specifically done in
|
||||
internal memory, for example the stack for new tasks or memory to service DMA or have memory that's
|
||||
also available when SPI cache is down, to fail. This option reserves a pool specifically for requests
|
||||
like that; the memory in this pool is not given out when a normal malloc() is called.
|
||||
|
||||
Set this to 0 to disable this feature.
|
||||
|
||||
Note that because FreeRTOS stacks are forced to internal memory, they will also use this memory pool;
|
||||
be sure to keep this in mind when adjusting this value.
|
||||
|
||||
Note also that the DMA reserved pool may not be one single contiguous memory region, depending on the
|
||||
configured size and the static memory usage of the app.
|
||||
|
||||
|
||||
config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
bool "Allow external memory as an argument to xTaskCreateStatic"
|
||||
default n
|
||||
@@ -214,15 +148,6 @@ menu "ESP32-specific"
|
||||
and does not call on ROM code in any way (no direct calls, but also no Bluetooth/WiFi), you can try to
|
||||
disable this and use xTaskCreateStatic to create the tasks stack in external memory.
|
||||
|
||||
config SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
|
||||
bool "Allow .bss segment placed in external memory"
|
||||
default n
|
||||
depends on ESP32_SPIRAM_SUPPORT
|
||||
help
|
||||
If enabled the option,and add EXT_RAM_ATTR defined your variable,then your variable will be placed in
|
||||
PSRAM instead of internal memory, and placed most of variables of lwip,net802.11,pp,bluedroid library
|
||||
to external memory defaultly.
|
||||
|
||||
choice SPIRAM_OCCUPY_SPI_HOST
|
||||
prompt "SPI host to use for 32MBit PSRAM"
|
||||
default SPIRAM_OCCUPY_VSPI_HOST
|
||||
|
@@ -302,7 +302,7 @@ esp_err_t esp_light_sleep_start()
|
||||
const uint32_t flash_enable_time_us = VDD_SDIO_POWERUP_TO_FLASH_READ_US
|
||||
+ CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY;
|
||||
|
||||
#ifndef CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#ifndef CONFIG_SPIRAM
|
||||
const uint32_t vddsdio_pd_sleep_duration = MAX(FLASH_PD_MIN_SLEEP_TIME_US,
|
||||
flash_enable_time_us + LIGHT_SLEEP_TIME_OVERHEAD_US + LIGHT_SLEEP_MIN_TIME_US);
|
||||
|
||||
@@ -310,7 +310,7 @@ esp_err_t esp_light_sleep_start()
|
||||
pd_flags |= RTC_SLEEP_PD_VDDSDIO;
|
||||
s_config.sleep_time_adjustment += flash_enable_time_us;
|
||||
}
|
||||
#endif //CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#endif //CONFIG_SPIRAM
|
||||
|
||||
rtc_vddsdio_config_t vddsdio_config = rtc_vddsdio_get_config();
|
||||
|
||||
|
@@ -46,7 +46,7 @@ we add more types of external RAM memory, this can be made into a more intellige
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#if CONFIG_SPIRAM
|
||||
|
||||
static const char* TAG = "spiram";
|
||||
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
#if CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#if CONFIG_SPIRAM
|
||||
#include "soc/rtc.h"
|
||||
|
||||
//Commands for PSRAM chip
|
||||
@@ -845,4 +845,4 @@ static void IRAM_ATTR psram_cache_init(psram_cache_mode_t psram_cache_mode, psra
|
||||
CLEAR_PERI_REG_MASK(SPI_PIN_REG(0), SPI_CS1_DIS_M); //ENABLE SPI0 CS1 TO PSRAM(CS0--FLASH; CS1--SRAM)
|
||||
}
|
||||
|
||||
#endif // CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#endif // CONFIG_SPIRAM
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
static const char TAG[] = "test_psram";
|
||||
|
||||
#ifdef CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#ifdef CONFIG_SPIRAM
|
||||
static void test_psram_content()
|
||||
{
|
||||
const int test_size = 2048;
|
||||
@@ -40,7 +40,7 @@ static void test_psram_content()
|
||||
TEST_CASE("can use spi when not being used by psram", "[psram_4m]")
|
||||
{
|
||||
spi_host_device_t host;
|
||||
#if !CONFIG_ESP32_SPIRAM_SUPPORT || !CONFIG_SPIRAM_SPEED_80M || CONFIG_SPIRAM_BANKSWITCH_ENABLE
|
||||
#if !CONFIG_SPIRAM || !CONFIG_SPIRAM_SPEED_80M || CONFIG_SPIRAM_BANKSWITCH_ENABLE
|
||||
//currently all 8M psram don't need more SPI peripherals
|
||||
host = -1;
|
||||
#elif CONFIG_SPIRAM_OCCUPY_HSPI_HOST
|
||||
@@ -66,7 +66,7 @@ TEST_CASE("can use spi when not being used by psram", "[psram_4m]")
|
||||
TEST_ASSERT(claim_vspi==true);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#ifdef CONFIG_SPIRAM
|
||||
test_psram_content();
|
||||
#endif
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ This code tests the interaction between PSRAM and SPI flash routines.
|
||||
#include "esp_partition.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
#if CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#if CONFIG_SPIRAM
|
||||
|
||||
#if CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC
|
||||
#define USE_CAPS_ALLOC 1
|
||||
@@ -179,4 +179,4 @@ IRAM_ATTR TEST_CASE("Spiram memcmp weirdness at 80MHz", "[spiram]") {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#endif // CONFIG_SPIRAM
|
||||
|
Reference in New Issue
Block a user