mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +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
@@ -129,9 +129,12 @@ menu "ESP32S2-specific"
|
||||
|
||||
endmenu # Cache config
|
||||
|
||||
# Note: to support SPIRAM across multiple chips, check CONFIG_SPIRAM
|
||||
# instead
|
||||
config ESP32S2_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.
|
||||
@@ -139,41 +142,6 @@ menu "ESP32S2-specific"
|
||||
menu "SPI RAM config"
|
||||
depends on ESP32S2_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
|
||||
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 SUPPORT_STATIC_ALLOCATION
|
||||
endchoice
|
||||
|
||||
choice SPIRAM_TYPE
|
||||
prompt "Type of SPI RAM chip in use"
|
||||
default SPIRAM_TYPE_AUTO
|
||||
@@ -195,6 +163,9 @@ menu "ESP32S2-specific"
|
||||
default 8388608 if SPIRAM_TYPE_ESPPSRAM64
|
||||
default 0
|
||||
|
||||
# insert non-chip-specific items here
|
||||
source "$IDF_PATH/components/esp_common/Kconfig.spiram.common"
|
||||
|
||||
config SPIRAM_FETCH_INSTRUCTIONS
|
||||
bool "Cache fetch instructions from SPI RAM"
|
||||
default n
|
||||
@@ -240,79 +211,6 @@ menu "ESP32S2-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
|
||||
default "y"
|
||||
help
|
||||
Revision 1 of the ESP32 has a bug that can cause a write to PSRAM not to take place in some situations
|
||||
when the cache line needs to be fetched from external RAM and an interrupt occurs. This enables a
|
||||
fix in the compiler (-mfix-esp32-psram-cache-issue) that makes sure the specific code that is
|
||||
vulnerable to this will not be emitted.
|
||||
|
||||
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.
|
||||
|
||||
config SPIRAM_MALLOC_ALWAYSINTERNAL
|
||||
int "Maximum malloc() size, in bytes, to always put in internal memory"
|
||||
depends on SPIRAM_USE_MALLOC
|
||||
default 16384
|
||||
range 0 131072
|
||||
help
|
||||
If malloc() is capable of also allocating SPI-connected ram, its allocation strategy will prefer to
|
||||
allocate chunks less than this size in internal memory, while allocations larger than this will be
|
||||
done from external RAM. If allocation from the preferred region fails, an attempt is made to allocate
|
||||
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
|
||||
depends on SPIRAM_USE_MALLOC
|
||||
help
|
||||
Because some bits of the ESP32 code environment cannot be recompiled with the cache workaround,
|
||||
normally tasks cannot be safely run with their stack residing in external memory; for this reason
|
||||
xTaskCreate and friends always allocate stack in internal memory and xTaskCreateStatic will check if
|
||||
the memory passed to it is in internal memory. If you have a task that needs a large amount of stack
|
||||
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.
|
||||
|
||||
endmenu
|
||||
|
||||
config ESP32S2_MEMMAP_TRACEMEM
|
||||
|
@@ -44,7 +44,7 @@ we add more types of external RAM memory, this can be made into a more intellige
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_SPIRAM_SUPPORT
|
||||
#if CONFIG_SPIRAM
|
||||
|
||||
static const char* TAG = "spiram";
|
||||
|
||||
|
@@ -37,7 +37,7 @@
|
||||
#include "driver/spi_common.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
|
||||
#if CONFIG_SPIRAM_SUPPORT
|
||||
#if CONFIG_SPIRAM
|
||||
#include "soc/rtc.h"
|
||||
|
||||
//Commands for PSRAM chip
|
||||
@@ -900,4 +900,4 @@ static void IRAM_ATTR psram_cache_init(psram_cache_mode_t psram_cache_mode, psra
|
||||
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(0), SPI_MEM_CS_HOLD_TIME_V, 1, SPI_MEM_CS_HOLD_TIME_S);
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_SPIRAM_SUPPORT
|
||||
#endif // CONFIG_SPIRAM
|
||||
|
Reference in New Issue
Block a user