From 342f4f315c24aa333b0f3a5e80a117b822dad0f5 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 6 Jul 2022 11:17:40 +0800 Subject: [PATCH] psram: make SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY configurable on S2 and S3 SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY was always enabled on S2 and S3, but this option is not compatible with ESP_COREDUMP_ENABLE_TO_FLASH. Make it configurable to allow users to deactive it so that ESP_COREDUMP_ENABLE_TO_FLASH can be used. --- components/esp_psram/esp32s2/Kconfig.spiram | 15 +++++++++++---- components/esp_psram/esp32s3/Kconfig.spiram | 15 +++++++++++---- docs/en/api-guides/external-ram.rst | 9 +-------- docs/zh_CN/api-guides/external-ram.rst | 9 +-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/components/esp_psram/esp32s2/Kconfig.spiram b/components/esp_psram/esp32s2/Kconfig.spiram index 20929f1442..19444ccf9e 100644 --- a/components/esp_psram/esp32s2/Kconfig.spiram +++ b/components/esp_psram/esp32s2/Kconfig.spiram @@ -8,10 +8,6 @@ config SPIRAM menu "SPI RAM config" depends on SPIRAM - config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY - bool - default "y" - config SPIRAM_MODE_QUAD bool default "y" @@ -33,6 +29,17 @@ menu "SPI RAM config" bool "ESP-PSRAM64 or LY68L6400" endchoice + config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY + bool "Allow external memory as an argument to xTaskCreateStatic" + default y + help + Accessing memory in SPIRAM has certain restrictions, so task stacks allocated by xTaskCreate + are by default allocated from internal RAM. + + This option allows for passing memory allocated from SPIRAM to be passed to xTaskCreateStatic. + This should only be used for tasks where the stack is never accessed while the cache is disabled. + Cannot be used together with ESP_COREDUMP_ENABLE_TO_FLASH. + menu "PSRAM clock and cs IO for ESP32S2" depends on SPIRAM config DEFAULT_PSRAM_CLK_IO diff --git a/components/esp_psram/esp32s3/Kconfig.spiram b/components/esp_psram/esp32s3/Kconfig.spiram index 58eff2f3bc..48fe595370 100644 --- a/components/esp_psram/esp32s3/Kconfig.spiram +++ b/components/esp_psram/esp32s3/Kconfig.spiram @@ -8,10 +8,6 @@ config SPIRAM menu "SPI RAM config" depends on SPIRAM - config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY - bool - default "y" - choice SPIRAM_MODE prompt "Mode (QUAD/OCT) of SPI RAM chip in use" default SPIRAM_MODE_QUAD @@ -42,6 +38,17 @@ menu "SPI RAM config" bool "ESP-PSRAM64 , LY68L6400 or APS6408" endchoice + config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY + bool "Allow external memory as an argument to xTaskCreateStatic" + default y + help + Accessing memory in SPIRAM has certain restrictions, so task stacks allocated by xTaskCreate + are by default allocated from internal RAM. + + This option allows for passing memory allocated from SPIRAM to be passed to xTaskCreateStatic. + This should only be used for tasks where the stack is never accessed while the cache is disabled. + Cannot be used together with ESP_COREDUMP_ENABLE_TO_FLASH. + menu "PSRAM Clock and CS IO for ESP32S3" depends on SPIRAM config DEFAULT_PSRAM_CLK_IO diff --git a/docs/en/api-guides/external-ram.rst b/docs/en/api-guides/external-ram.rst index a94bb89c58..f01bfb67e2 100644 --- a/docs/en/api-guides/external-ram.rst +++ b/docs/en/api-guides/external-ram.rst @@ -139,14 +139,7 @@ External RAM use has the following restrictions: * In general, external RAM will not be used as task stack memory. :cpp:func:`xTaskCreate` and similar functions will always allocate internal memory for stack and task TCBs. -.. only:: esp32 - - The option :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` can be used to place task stacks into external memory. In these cases :cpp:func:`xTaskCreateStatic` must be used to specify a task stack buffer allocated from external memory, otherwise task stacks will still be allocated from internal memory. - - -.. only:: not esp32 - - :cpp:func:`xTaskCreateStatic` can be used to explicitly place task stacks into external memory. +The option :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` can be used to allow placing task stacks into external memory. In these cases :cpp:func:`xTaskCreateStatic` must be used to specify a task stack buffer allocated from external memory, otherwise task stacks will still be allocated from internal memory. Failure to initialize diff --git a/docs/zh_CN/api-guides/external-ram.rst b/docs/zh_CN/api-guides/external-ram.rst index 6d3ece3660..8d0cbc25ef 100644 --- a/docs/zh_CN/api-guides/external-ram.rst +++ b/docs/zh_CN/api-guides/external-ram.rst @@ -139,15 +139,8 @@ ESP-IDF 启动过程中,片外 RAM 被映射到以 {IDF_TARGET_PSRAM_ADDR_STAR * 一般来说,片外 RAM 不会用作任务堆栈存储器。:cpp:func:`xTaskCreate` 及类似函数始终会为堆栈和任务 TCB 分配片上储存器。 -.. only:: esp32 - - 可以使用 :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` 选项将任务堆栈放入片外存储器。这时,必须使用 :cpp:func:`xTaskCreateStatic` 指定从片外存储器分配的任务堆栈缓冲区,否则任务堆栈将会从片上存储器分配。 - - -.. only:: not esp32 - - 可以使用 :cpp:func:`xTaskCreateStatic` 显式地将任务堆栈放入片外存储器。 +可以使用 :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` 选项将任务堆栈放入片外存储器。这时,必须使用 :cpp:func:`xTaskCreateStatic` 指定从片外存储器分配的任务堆栈缓冲区,否则任务堆栈将会从片上存储器分配。 初始化失败 =====================