diff --git a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32p4 b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32p4 index 0d33cfbf8f43..5470efa12084 100644 --- a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32p4 +++ b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32p4 @@ -5,4 +5,4 @@ CONFIG_SPIRAM=y CONFIG_SPIRAM_XIP_FROM_PSRAM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y diff --git a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 index fd9b7e865c3c..3c7418b55d97 100644 --- a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 +++ b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 @@ -5,4 +5,4 @@ CONFIG_SPIRAM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_RODATA=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y diff --git a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 index 3b1db1f233fd..53125cb9b8ba 100644 --- a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 +++ b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 @@ -5,4 +5,4 @@ CONFIG_SPIRAM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_RODATA=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y diff --git a/components/esp_hw_support/esp_memory_utils.c b/components/esp_hw_support/esp_memory_utils.c index 766ca5a2c183..62627cbcb970 100644 --- a/components/esp_hw_support/esp_memory_utils.c +++ b/components/esp_hw_support/esp_memory_utils.c @@ -67,7 +67,7 @@ bool esp_ptr_external_ram(const void *p) #endif //CONFIG_SPIRAM } -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM bool esp_stack_ptr_in_extram(uint32_t sp) { //Check if stack ptr is on PSRAM, and 16 byte aligned. diff --git a/components/esp_hw_support/include/esp_memory_utils.h b/components/esp_hw_support/include/esp_memory_utils.h index 427dc4912eaf..d17d6f269655 100644 --- a/components/esp_hw_support/include/esp_memory_utils.h +++ b/components/esp_hw_support/include/esp_memory_utils.h @@ -352,7 +352,7 @@ inline static bool esp_stack_ptr_in_dram(uint32_t sp) return !(sp < SOC_DRAM_LOW + 0x10 || sp > SOC_DRAM_HIGH - 0x10 || ((sp & 0xF) != 0)); } -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM /** * @brief Check if the stack pointer is in external ram * @@ -374,7 +374,7 @@ __attribute__((always_inline)) inline static bool esp_stack_ptr_is_sane(uint32_t sp) { return esp_stack_ptr_in_dram(sp) -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM || esp_stack_ptr_in_extram(sp) #endif #if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP diff --git a/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s2 b/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s2 index 51f7a5a04519..8345d72b95f7 100644 --- a/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s2 +++ b/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s2 @@ -1,6 +1,6 @@ CONFIG_IDF_TARGET="esp32s2" CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y CONFIG_SPIRAM_RODATA=y diff --git a/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s3 b/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s3 index 31f93b587662..7669b3050c80 100644 --- a/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s3 +++ b/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.pm_xip_psram_esp32s3 @@ -1,6 +1,6 @@ CONFIG_IDF_TARGET="esp32s3" CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y CONFIG_SPIRAM_RODATA=y diff --git a/components/esp_psram/esp32/Kconfig.spiram b/components/esp_psram/esp32/Kconfig.spiram index f7eb1725a45e..04c32ff5faf1 100644 --- a/components/esp_psram/esp32/Kconfig.spiram +++ b/components/esp_psram/esp32/Kconfig.spiram @@ -259,19 +259,6 @@ menu "SPI RAM config" any himem calls, the reservation is not done and the original amount of memory will be available to malloc/esp_heap_alloc_caps. - config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY - bool "Allow external memory as an argument to xTaskCreateStatic" - default n - depends on SPIRAM_USE_CAPS_ALLOC || 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 related task creaton functions) 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 enable this to cause xTaskCreateStatic to allow tasks stack in external - memory. - choice SPIRAM_OCCUPY_SPI_HOST prompt "SPI host to use for 32MBit PSRAM" default SPIRAM_OCCUPY_VSPI_HOST diff --git a/components/esp_psram/esp32c5/Kconfig.spiram b/components/esp_psram/esp32c5/Kconfig.spiram index 75e0ec8da9df..ca941e8f1d55 100644 --- a/components/esp_psram/esp32c5/Kconfig.spiram +++ b/components/esp_psram/esp32c5/Kconfig.spiram @@ -17,16 +17,6 @@ menu "SPI RAM config" 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. - choice SPIRAM_SPEED prompt "Set RAM clock speed" default SPIRAM_SPEED_40M diff --git a/components/esp_psram/esp32c61/Kconfig.spiram b/components/esp_psram/esp32c61/Kconfig.spiram index 0ef577983fd9..fefbd96463cb 100644 --- a/components/esp_psram/esp32c61/Kconfig.spiram +++ b/components/esp_psram/esp32c61/Kconfig.spiram @@ -17,16 +17,6 @@ menu "SPI RAM config" 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. - choice SPIRAM_SPEED prompt "Set RAM clock speed" default SPIRAM_SPEED_40M diff --git a/components/esp_psram/esp32p4/Kconfig.spiram b/components/esp_psram/esp32p4/Kconfig.spiram index f17fb795eeca..821188d2f3ff 100644 --- a/components/esp_psram/esp32p4/Kconfig.spiram +++ b/components/esp_psram/esp32p4/Kconfig.spiram @@ -91,17 +91,6 @@ menu "PSRAM config" If enabled, 1/8 of the PSRAM total size will be reserved for error-correcting code. - config SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY - bool "Allow external memory as an argument to xTaskCreateStatic" - default y - help - Accessing memory in PSRAM has certain restrictions, so task stacks allocated by xTaskCreate - are by default allocated from internal RAM. - - This option allows for passing memory allocated from PSRAM to be passed to xTaskCreateStatic. - This should only be used for tasks where the stack is never accessed while the L2Cache is - disabled, e.g. during SPI Flash operations - source "$IDF_PATH/components/esp_psram/Kconfig.spiram.common" # insert non-chip-specific items here endmenu diff --git a/components/esp_psram/esp32s2/Kconfig.spiram b/components/esp_psram/esp32s2/Kconfig.spiram index 1af865756aaf..6135222a5af4 100644 --- a/components/esp_psram/esp32s2/Kconfig.spiram +++ b/components/esp_psram/esp32s2/Kconfig.spiram @@ -29,16 +29,6 @@ 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. - config SPIRAM_CLK_IO int default 30 diff --git a/components/esp_psram/esp32s3/Kconfig.spiram b/components/esp_psram/esp32s3/Kconfig.spiram index 466343762973..1bf74912d0c7 100644 --- a/components/esp_psram/esp32s3/Kconfig.spiram +++ b/components/esp_psram/esp32s3/Kconfig.spiram @@ -38,16 +38,6 @@ 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. - config SPIRAM_CLK_IO int default 30 diff --git a/components/esp_psram/test_apps/.build-test-rules.yml b/components/esp_psram/test_apps/.build-test-rules.yml index 88e270873461..c9b865f3012b 100644 --- a/components/esp_psram/test_apps/.build-test-rules.yml +++ b/components/esp_psram/test_apps/.build-test-rules.yml @@ -9,11 +9,3 @@ components/esp_psram/test_apps/psram: - esp_driver_gpio - esp_driver_spi - spi_flash - - -components/esp_psram/test_apps/psram_no_malloc_task_stack: - enable: - - if: IDF_TARGET in ["esp32", "esp32p4"] - depends_components: - - esp_psram - - freertos diff --git a/components/esp_psram/test_apps/psram_no_malloc_task_stack/CMakeLists.txt b/components/esp_psram/test_apps/psram_no_malloc_task_stack/CMakeLists.txt deleted file mode 100644 index 9debb1681bd8..000000000000 --- a/components/esp_psram/test_apps/psram_no_malloc_task_stack/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# The following five lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.16) - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(COMPONENTS main) -project(psram_no_malloc_task_stack) diff --git a/components/esp_psram/test_apps/psram_no_malloc_task_stack/README.md b/components/esp_psram/test_apps/psram_no_malloc_task_stack/README.md deleted file mode 100644 index 4873c15b15b5..000000000000 --- a/components/esp_psram/test_apps/psram_no_malloc_task_stack/README.md +++ /dev/null @@ -1,2 +0,0 @@ -| Supported Targets | ESP32 | ESP32-P4 | -| ----------------- | ----- | -------- | diff --git a/components/esp_psram/test_apps/psram_no_malloc_task_stack/main/CMakeLists.txt b/components/esp_psram/test_apps/psram_no_malloc_task_stack/main/CMakeLists.txt deleted file mode 100644 index 90939ebf279b..000000000000 --- a/components/esp_psram/test_apps/psram_no_malloc_task_stack/main/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -idf_component_register(SRCS "test_psram_no_malloc_task_stack.c" - INCLUDE_DIRS "." - PRIV_REQUIRES unity esp_psram freertos heap) diff --git a/components/esp_psram/test_apps/psram_no_malloc_task_stack/main/test_psram_no_malloc_task_stack.c b/components/esp_psram/test_apps/psram_no_malloc_task_stack/main/test_psram_no_malloc_task_stack.c deleted file mode 100644 index d0c48c608d25..000000000000 --- a/components/esp_psram/test_apps/psram_no_malloc_task_stack/main/test_psram_no_malloc_task_stack.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Unlicense OR CC0-1.0 - */ -#include -#include "esp_log.h" -#include "unity.h" -#include "unity_test_runner.h" -#include "unity_test_utils_memory.h" -#include "unity_test_utils.h" -#include "esp_heap_caps.h" -#include "esp_memory_utils.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -static const char* TAG = "psram_no_malloc_task_stack_test"; - -#define STACK_SIZE 4096 -#define WAIT_TICKS 2 -#define TEST_TASK_PRIORITY 6 // relatively high priority to let task finish quickly - -void setUp(void) -{ - unity_utils_set_leak_level(0); - unity_utils_record_free_mem(); -} - -void tearDown(void) -{ - unity_utils_evaluate_leaks(); -} - -static uint8_t *stack_memory; -static StaticTask_t *tcb_memory; -static bool is_external; -static SemaphoreHandle_t task_waiter; - -static void test_task(void *arg) -{ - int dummy = 47; - is_external = esp_ptr_external_ram(&dummy); - xSemaphoreGive(task_waiter); - vTaskDelay(portMAX_DELAY); -} - -TEST_CASE("FreeRTOS task with stack on SPIRAM works", "[psram]") -{ - stack_memory = heap_caps_malloc(STACK_SIZE, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); - TEST_ASSERT_NOT_NULL(stack_memory); - tcb_memory = heap_caps_malloc(sizeof(StaticTask_t), MALLOC_CAP_8BIT); - TEST_ASSERT_NOT_NULL(tcb_memory); - task_waiter = xSemaphoreCreateBinary(); - TEST_ASSERT_NOT_NULL(task_waiter); - - TaskHandle_t task = xTaskCreateStatic(test_task, - "heap caps static", - STACK_SIZE, - NULL, - TEST_TASK_PRIORITY, - stack_memory, - tcb_memory); - TEST_ASSERT_NOT_NULL(task); - - TEST_ASSERT_EQUAL(pdTRUE, xSemaphoreTake(task_waiter, WAIT_TICKS)); - - TEST_ASSERT_EQUAL(true, is_external); - - // use unity_utils_task_delete() to avoid deleting stack of a still running task - unity_utils_task_delete(task); - - vSemaphoreDelete(task_waiter); - heap_caps_free(tcb_memory); - heap_caps_free(stack_memory); -} - -void app_main(void) -{ - ESP_LOGI(TAG, "Running PSRAM task stack test app with SPIRAM_USE_CAPS_ALLOC"); - - unity_run_menu(); -} diff --git a/components/esp_psram/test_apps/psram_no_malloc_task_stack/pytest_psram_no_malloc_task_stack.py b/components/esp_psram/test_apps/psram_no_malloc_task_stack/pytest_psram_no_malloc_task_stack.py deleted file mode 100644 index 298f6f93c872..000000000000 --- a/components/esp_psram/test_apps/psram_no_malloc_task_stack/pytest_psram_no_malloc_task_stack.py +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: CC0-1.0 -import pytest -from pytest_embedded import Dut - - -@pytest.mark.esp32 -@pytest.mark.esp32p4 -@pytest.mark.generic -def test_psram_no_malloc_task_stack(dut: Dut) -> None: - dut.run_all_single_board_cases() diff --git a/components/esp_psram/test_apps/psram_no_malloc_task_stack/sdkconfig.defaults b/components/esp_psram/test_apps/psram_no_malloc_task_stack/sdkconfig.defaults deleted file mode 100644 index 5e67e04b0c44..000000000000 --- a/components/esp_psram/test_apps/psram_no_malloc_task_stack/sdkconfig.defaults +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_ESP_TASK_WDT_EN=n -CONFIG_SPIRAM=y -CONFIG_SPIRAM_USE_CAPS_ALLOC=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y diff --git a/components/esp_system/port/soc/esp32/system_internal.c b/components/esp_system/port/soc/esp32/system_internal.c index 75cae925114a..da76aa90d1a6 100644 --- a/components/esp_system/port/soc/esp32/system_internal.c +++ b/components/esp_system/port/soc/esp32/system_internal.c @@ -97,9 +97,9 @@ void IRAM_ATTR esp_restart_noos(void) wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); -#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM if (esp_ptr_external_ram(esp_cpu_get_sp())) { - // If stack_addr is from External Memory (CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY is used) + // If stack_addr is from External Memory (CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM is used) // then need to switch SP to Internal Memory otherwise // we will get the "Cache disabled but cached memory region accessed" error after Cache_Read_Disable. uint32_t new_sp = SOC_DRAM_LOW + (SOC_DRAM_HIGH - SOC_DRAM_LOW) / 2; diff --git a/components/esp_system/port/soc/esp32s2/system_internal.c b/components/esp_system/port/soc/esp32s2/system_internal.c index 3de3bafdf187..8eb6c0325c25 100644 --- a/components/esp_system/port/soc/esp32s2/system_internal.c +++ b/components/esp_system/port/soc/esp32s2/system_internal.c @@ -85,9 +85,9 @@ void IRAM_ATTR esp_restart_noos(void) wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); -#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM if (esp_ptr_external_ram(esp_cpu_get_sp())) { - // If stack_addr is from External Memory (CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY is used) + // If stack_addr is from External Memory (CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM is used) // then need to switch SP to Internal Memory otherwise // we will get the "Cache disabled but cached memory region accessed" error after Cache_Read_Disable. uint32_t new_sp = ALIGN_DOWN(_bss_end, 16); diff --git a/components/esp_system/port/soc/esp32s3/system_internal.c b/components/esp_system/port/soc/esp32s3/system_internal.c index ebdaccbcb25f..f0edae876cbb 100644 --- a/components/esp_system/port/soc/esp32s3/system_internal.c +++ b/components/esp_system/port/soc/esp32s3/system_internal.c @@ -92,9 +92,9 @@ void IRAM_ATTR esp_restart_noos(void) wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); -#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM if (esp_ptr_external_ram(esp_cpu_get_sp())) { - // If stack_addr is from External Memory (CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY is used) + // If stack_addr is from External Memory (CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM is used) // then need to switch SP to Internal Memory otherwise // we will get the "Cache disabled but cached memory region accessed" error after Cache_Read_Disable. uint32_t new_sp = ALIGN_DOWN(_bss_end, 16); diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_reset_reason.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_reset_reason.c index 3008f15b62cd..491c3299b45b 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_reset_reason.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_reset_reason.c @@ -318,7 +318,7 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_BROWNOUT after brownout event", do_brownout, check_reset_reason_brownout); -#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM #ifndef CONFIG_FREERTOS_UNICORE #if CONFIG_IDF_TARGET_ARCH_XTENSA #include "xt_instr_macros.h" @@ -402,6 +402,6 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_PANIC after an exception in a ta #endif //CONFIG_IDF_TARGET_ARCH_XTENSA #endif // CONFIG_FREERTOS_UNICORE -#endif // CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#endif // CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM /* Not tested here: ESP_RST_SDIO */ diff --git a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram index 482bcd8baa53..f29df53fffe5 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram +++ b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram @@ -1,2 +1,2 @@ CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y diff --git a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top index 440009beb18b..d1b0d3024436 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top +++ b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top @@ -1,4 +1,4 @@ CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y diff --git a/components/espcoredump/Kconfig b/components/espcoredump/Kconfig index c19b0eabbaeb..90b806d96aa5 100644 --- a/components/espcoredump/Kconfig +++ b/components/espcoredump/Kconfig @@ -108,7 +108,7 @@ menu "Core dump" config ESP_COREDUMP_USE_STACK_SIZE bool - default y if ESP_COREDUMP_ENABLE_TO_FLASH && SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY + default y if ESP_COREDUMP_ENABLE_TO_FLASH && FREERTOS_TASK_CREATE_ALLOW_EXT_MEM default n help Force the use of a custom DRAM stack for coredump when Task stacks can be in PSRAM. diff --git a/components/espcoredump/src/port/riscv/core_dump_port.c b/components/espcoredump/src/port/riscv/core_dump_port.c index 60a2ac39546a..7d872ce62e55 100644 --- a/components/espcoredump/src/port/riscv/core_dump_port.c +++ b/components/espcoredump/src/port/riscv/core_dump_port.c @@ -37,7 +37,7 @@ const static char TAG[] __attribute__((unused)) = "esp_core_dump_port"; /** * Union representing the registers of the CPU as they will be written * in the core dump. - * Registers can be adressed with their names thanks to the structure, or as + * Registers can be addressed with their names thanks to the structure, or as * an array of 32 words. */ #define RISCV_GP_REGS_COUNT 32 @@ -222,7 +222,7 @@ uint32_t esp_core_dump_get_isr_stack_end(void) static inline bool esp_core_dump_task_stack_end_is_sane(uint32_t sp) { return esp_ptr_in_dram((void *)sp) -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM || esp_stack_ptr_in_extram(sp) #endif #if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP @@ -315,7 +315,7 @@ bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz) } /** - * Get the task's registers dump when the panic occured. + * Get the task's registers dump when the panic occurred. * Returns the size, in bytes, of the data pointed by reg_dumps. * The data pointed by reg_dump are allocated statically, thus, they must be * used (or copied) before calling this function again. diff --git a/components/espcoredump/src/port/xtensa/core_dump_port.c b/components/espcoredump/src/port/xtensa/core_dump_port.c index cee4c1ebc1e0..8efae60d576e 100644 --- a/components/espcoredump/src/port/xtensa/core_dump_port.c +++ b/components/espcoredump/src/port/xtensa/core_dump_port.c @@ -299,7 +299,7 @@ uint32_t esp_core_dump_get_isr_stack_end(void) static inline bool esp_core_dump_task_stack_end_is_sane(uint32_t sp) { return esp_ptr_in_dram((void *)sp) -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM || esp_stack_ptr_in_extram(sp) #endif #if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index ba0bb786f48b..dec261a93c85 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -573,6 +573,33 @@ menu "FreeRTOS" endmenu # Port + menu "Extra" + + config FREERTOS_TASK_CREATE_ALLOW_EXT_MEM + depends on SPIRAM + depends on FREERTOS_SUPPORT_STATIC_ALLOCATION + bool "Allow external memory as an argument to xTaskCreateStatic (READ HELP)" + default n if IDF_TARGET_ESP32 + default y + help + Accessing memory in PSRAM 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. + + Extra notes for ESP32: + + 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 related task creation functions) 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 enable this to + cause xTaskCreateStatic to allow tasks stack in external memory. + + endmenu # Extra + # Hidden or compatibility options config FREERTOS_PORT diff --git a/components/freertos/heap_idf.c b/components/freertos/heap_idf.c index 57ff845f742f..60974047097e 100644 --- a/components/freertos/heap_idf.c +++ b/components/freertos/heap_idf.c @@ -99,7 +99,7 @@ bool xPortcheckValidStackMem(const void * ptr) #if CONFIG_IDF_TARGET_LINUX return true; #else /* CONFIG_IDF_TARGET_LINUX */ -#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM return esp_ptr_byte_accessible(ptr); #else return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr); diff --git a/components/freertos/sdkconfig.rename b/components/freertos/sdkconfig.rename index 5720544d0e79..da4c466482ae 100644 --- a/components/freertos/sdkconfig.rename +++ b/components/freertos/sdkconfig.rename @@ -5,3 +5,4 @@ CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK CONFIG_FREERTOS_ENABLE_STATIC_TASK_C CONFIG_TIMER_TASK_PRIORITY CONFIG_FREERTOS_TIMER_TASK_PRIORITY CONFIG_TIMER_TASK_STACK_DEPTH CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH CONFIG_TIMER_QUEUE_LENGTH CONFIG_FREERTOS_TIMER_QUEUE_LENGTH +CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM diff --git a/components/freertos/test_apps/freertos/misc/test_idf_additions.c b/components/freertos/test_apps/freertos/misc/test_idf_additions.c index 2f4d4a1fb769..5c5c3d69adda 100644 --- a/components/freertos/test_apps/freertos/misc/test_idf_additions.c +++ b/components/freertos/test_apps/freertos/misc/test_idf_additions.c @@ -89,7 +89,7 @@ TEST_CASE("IDF additions: Task creation with memory caps and self deletion", "[f xTaskNotifyGive(task_handle); } -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM TEST_CASE("IDF additions: Task creation with SPIRAM memory caps and self deletion stress test", "[freertos]") { @@ -115,7 +115,7 @@ TEST_CASE("IDF additions: Task creation with SPIRAM memory caps and self deletio } } -#endif /* CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */ +#endif /* CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM */ #if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) diff --git a/components/freertos/test_apps/freertos/pytest_freertos.py b/components/freertos/test_apps/freertos/pytest_freertos.py index ff27e9bc354f..e2cdb05bd2c8 100644 --- a/components/freertos/test_apps/freertos/pytest_freertos.py +++ b/components/freertos/test_apps/freertos/pytest_freertos.py @@ -7,7 +7,7 @@ CONFIGS = [ pytest.param('default', marks=[pytest.mark.supported_targets,]), pytest.param('freertos_options', marks=[pytest.mark.supported_targets]), - pytest.param('psram', marks=[pytest.mark.esp32]), + pytest.param('psram', marks=[pytest.mark.esp32, pytest.mark.esp32s3, pytest.mark.esp32p4, pytest.mark.esp32c5]), pytest.param('single_core', marks=[pytest.mark.esp32, pytest.mark.esp32p4]), # TODO: [ESP32C5] IDF-10335 # TODO: [ESP32C61] IDF-11146 diff --git a/components/freertos/test_apps/freertos/sdkconfig.ci.psram b/components/freertos/test_apps/freertos/sdkconfig.ci.psram index 1e3309831549..776e127a2aa4 100644 --- a/components/freertos/test_apps/freertos/sdkconfig.ci.psram +++ b/components/freertos/test_apps/freertos/sdkconfig.ci.psram @@ -5,7 +5,7 @@ CONFIG_IDF_TARGET="esp32" # Enable SPIRAM CONFIG_SPIRAM=y CONFIG_SPIRAM_OCCUPY_NO_HOST=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y # Disable encrypted flash reads/writes to save IRAM in this build configuration CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=n diff --git a/components/mbedtls/test_apps/main/test_aes.c b/components/mbedtls/test_apps/main/test_aes.c index 5ac71e82ec90..e95313c26651 100644 --- a/components/mbedtls/test_apps/main/test_aes.c +++ b/components/mbedtls/test_apps/main/test_aes.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -67,7 +67,7 @@ static const uint8_t iv[] = { print(as_c_array(plain)) ct = encryptor.update(plain) + encryptor.finalize() - print("Chipertext: {}".format(as_c_array(ct))) + print("Ciphertext: {}".format(as_c_array(ct))) */ TEST_CASE("mbedtls CBC AES-256 test", "[aes]") { @@ -85,11 +85,11 @@ TEST_CASE("mbedtls CBC AES-256 test", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -100,19 +100,19 @@ TEST_CASE("mbedtls CBC AES-256 test", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt memcpy(nonce, iv, 16); mbedtls_aes_setkey_dec(&ctx, key_256, 256); - mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, chipertext, decryptedtext); + mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -134,11 +134,11 @@ TEST_CASE("mbedtls CBC AES-256 DMA buffer align test", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -149,19 +149,19 @@ TEST_CASE("mbedtls CBC AES-256 DMA buffer align test", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt memcpy(nonce, iv, 16); mbedtls_aes_setkey_dec(&ctx, key_256, 256); - mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, chipertext, decryptedtext); + mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -183,11 +183,11 @@ TEST_CASE("mbedtls CTR AES-256 test", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -198,19 +198,19 @@ TEST_CASE("mbedtls CTR AES-256 test", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_ctr(&ctx, SZ, &nc_off, nonce, stream_block, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_ctr(&ctx, SZ, &nc_off, nonce, stream_block, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt nc_off = 0; memcpy(nonce, iv, 16); - mbedtls_aes_crypt_ctr(&ctx, SZ, &nc_off, nonce, stream_block, chipertext, decryptedtext); + mbedtls_aes_crypt_ctr(&ctx, SZ, &nc_off, nonce, stream_block, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -231,11 +231,11 @@ TEST_CASE("mbedtls OFB AES-256 test", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -246,19 +246,19 @@ TEST_CASE("mbedtls OFB AES-256 test", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt nc_off = 0; memcpy(nonce, iv, 16); - mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, chipertext, decryptedtext); + mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -278,11 +278,11 @@ TEST_CASE("mbedtls CFB-8 AES-256 test", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -293,18 +293,18 @@ TEST_CASE("mbedtls CFB-8 AES-256 test", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt memcpy(nonce, iv, 16); - mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, chipertext, decryptedtext); + mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -325,11 +325,11 @@ TEST_CASE("mbedtls CFB-128 AES-256 test", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -340,19 +340,19 @@ TEST_CASE("mbedtls CFB-128 AES-256 test", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_ENCRYPT, SZ, &nc_off, nonce, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_ENCRYPT, SZ, &nc_off, nonce, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt nc_off = 0; memcpy(nonce, iv, 16); - mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_DECRYPT, SZ, &nc_off, nonce, chipertext, decryptedtext); + mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_DECRYPT, SZ, &nc_off, nonce, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -401,11 +401,11 @@ static void aes_ctr_stream_test(void) memset(key, 0x44, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -419,7 +419,7 @@ static void aes_ctr_stream_test(void) for (int bytes_to_process = 1; bytes_to_process < SZ; bytes_to_process++) { ESP_LOGD("test", "bytes_to_process %d", bytes_to_process); memset(nonce, 0xEE, 16); - memset(chipertext, 0x0, SZ); + memset(ciphertext, 0x0, SZ); memset(decryptedtext, 0x0, SZ); size_t offset = 0; @@ -429,12 +429,12 @@ static void aes_ctr_stream_test(void) size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; mbedtls_aes_crypt_ctr(&ctx, length, &offset, nonce, - stream_block, plaintext + idx, chipertext + idx ); + stream_block, plaintext + idx, ciphertext + idx ); } ESP_LOG_BUFFER_HEXDUMP("expected", expected_cipher, SZ, ESP_LOG_DEBUG); - ESP_LOG_BUFFER_HEXDUMP("actual ", chipertext, SZ, ESP_LOG_DEBUG); + ESP_LOG_BUFFER_HEXDUMP("actual ", ciphertext, SZ, ESP_LOG_DEBUG); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, chipertext, SZ); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, ciphertext, SZ); // Decrypt memset(nonce, 0xEE, 16); @@ -444,7 +444,7 @@ static void aes_ctr_stream_test(void) // Limit length of last call to avoid exceeding buffer size size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; mbedtls_aes_crypt_ctr(&ctx, length, &offset, nonce, - stream_block, chipertext + idx, decryptedtext + idx ); + stream_block, ciphertext + idx, decryptedtext + idx ); } ESP_LOG_BUFFER_HEXDUMP("decrypted", decryptedtext, SZ, ESP_LOG_DEBUG); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); @@ -452,7 +452,7 @@ static void aes_ctr_stream_test(void) mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -505,11 +505,11 @@ TEST_CASE("mbedtls OFB stream test", "[aes]") memset(key, 0x44, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -529,10 +529,10 @@ TEST_CASE("mbedtls OFB stream test", "[aes]") for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = ( (idx + bytes_to_process) > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_aes_crypt_ofb(&ctx, length, &offset, iv, plaintext + idx, chipertext + idx); + mbedtls_aes_crypt_ofb(&ctx, length, &offset, iv, plaintext + idx, ciphertext + idx); } - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, chipertext, SZ); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, ciphertext, SZ); // Decrypt memset(iv, 0xEE, 16); @@ -541,14 +541,14 @@ TEST_CASE("mbedtls OFB stream test", "[aes]") for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_aes_crypt_ofb(&ctx, length, &offset, iv, chipertext + idx, decryptedtext + idx); + mbedtls_aes_crypt_ofb(&ctx, length, &offset, iv, ciphertext + idx, decryptedtext + idx); } TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); } mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -595,11 +595,11 @@ TEST_CASE("mbedtls CFB8 stream test", "[aes]") memset(key, 0x44, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -616,16 +616,16 @@ TEST_CASE("mbedtls CFB8 stream test", "[aes]") for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = ( (idx + bytes_to_process) > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_ENCRYPT, length, iv, plaintext + idx, chipertext + idx); + mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_ENCRYPT, length, iv, plaintext + idx, ciphertext + idx); } - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, chipertext, SZ); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, ciphertext, SZ); memset(iv, 0xEE, 16); for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = ( (idx + bytes_to_process) > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_DECRYPT, length, iv, chipertext + idx, decryptedtext + idx); + mbedtls_aes_crypt_cfb8(&ctx, MBEDTLS_AES_DECRYPT, length, iv, ciphertext + idx, decryptedtext + idx); } TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); @@ -633,7 +633,7 @@ TEST_CASE("mbedtls CFB8 stream test", "[aes]") mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -680,11 +680,11 @@ TEST_CASE("mbedtls CFB128 stream test", "[aes]") memset(key, 0x44, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -703,24 +703,24 @@ TEST_CASE("mbedtls CFB128 stream test", "[aes]") for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = ( (idx + bytes_to_process) > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_ENCRYPT, length, &offset, iv, plaintext + idx, chipertext + idx); + mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_ENCRYPT, length, &offset, iv, plaintext + idx, ciphertext + idx); } - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, chipertext, SZ); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, ciphertext, SZ); offset = 0; memset(iv, 0xEE, 16); for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = ( (idx + bytes_to_process) > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_DECRYPT, length, &offset, iv, chipertext + idx, decryptedtext + idx); + mbedtls_aes_crypt_cfb128(&ctx, MBEDTLS_AES_DECRYPT, length, &offset, iv, ciphertext + idx, decryptedtext + idx); } TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -804,11 +804,11 @@ TEST_CASE("mbedtls OFB, chained DMA descriptors", "[aes]") memcpy(nonce, iv, 16); // allocate internal memory - uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -819,20 +819,20 @@ TEST_CASE("mbedtls OFB, chained DMA descriptors", "[aes]") memset(decryptedtext, 0x0, SZ); // Encrypt - mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, plaintext, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, plaintext, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32); // Decrypt nc_off = 0; memcpy(nonce, iv, 16); - mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, chipertext, decryptedtext); + mbedtls_aes_crypt_ofb(&ctx, SZ, &nc_off, nonce, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -858,11 +858,11 @@ void aes_ctr_alignment_test(uint32_t input_buf_caps, uint32_t output_buf_caps) memset(key, 0x1E, 16); // allocate memory according the requested caps - uint8_t *chipertext = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, output_buf_caps); + uint8_t *ciphertext = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, output_buf_caps); uint8_t *plaintext = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, input_buf_caps); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(plaintext); TEST_ASSERT_NOT_NULL(decryptedtext); @@ -877,14 +877,14 @@ void aes_ctr_alignment_test(uint32_t input_buf_caps, uint32_t output_buf_caps) // Encrypt with input buffer in external ram offset = 0; memset(nonce, 0x2F, 16); - mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, plaintext + i, chipertext + i); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_ctr_end, chipertext + i + SZ - 32, 32); + mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, plaintext + i, ciphertext + i); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_ctr_end, ciphertext + i + SZ - 32, 32); // Decrypt offset = 0; memset(nonce, 0x2F, 16); // Decrypt with input buffer in instruction memory, the crypto DMA can't access this - mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, chipertext + i, decryptedtext); + mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, ciphertext + i, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); @@ -892,7 +892,7 @@ void aes_ctr_alignment_test(uint32_t input_buf_caps, uint32_t output_buf_caps) mbedtls_aes_free(&ctx); free(plaintext); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -1483,10 +1483,10 @@ void aes_ext_flash_ctr_test(uint32_t output_buf_caps) memset(nonce, 0x2F, 16); memset(key, 0x1E, 16); - uint8_t *chipertext = heap_caps_malloc(SZ, output_buf_caps); + uint8_t *ciphertext = heap_caps_malloc(SZ, output_buf_caps); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(chipertext); + TEST_ASSERT_NOT_NULL(ciphertext); TEST_ASSERT_NOT_NULL(decryptedtext); mbedtls_aes_init(&ctx); @@ -1497,19 +1497,19 @@ void aes_ext_flash_ctr_test(uint32_t output_buf_caps) // Encrypt with input buffer in external flash offset = 0; memset(nonce, 0x2F, 16); - mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, long_input, chipertext); - TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_long_input_end, chipertext + SZ - 32, 32); + mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, long_input, ciphertext); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_long_input_end, ciphertext + SZ - 32, 32); // Decrypt offset = 0; memset(nonce, 0x2F, 16); // Decrypt with input buffer in external flash, the crypto DMA can't access this - mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, chipertext, decryptedtext); + mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, ciphertext, decryptedtext); TEST_ASSERT_EQUAL_HEX8_ARRAY(long_input, decryptedtext, SZ); mbedtls_aes_free(&ctx); - free(chipertext); + free(ciphertext); free(decryptedtext); } @@ -1563,7 +1563,7 @@ TEST_CASE("mbedtls AES stack in RTC RAM", "[mbedtls]") #endif //CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY && CONFIG_SPIRAM_USE_MALLOC +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM && CONFIG_SPIRAM_USE_MALLOC TEST_CASE("mbedtls AES stack in PSRAM", "[mbedtls]") { @@ -1585,4 +1585,4 @@ TEST_CASE("mbedtls AES stack in PSRAM", "[mbedtls]") vSemaphoreDelete(done_sem); } -#endif //CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY && CONFIG_SPIRAM_USE_MALLOC +#endif //CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM && CONFIG_SPIRAM_USE_MALLOC diff --git a/components/mbedtls/test_apps/main/test_mbedtls_sha.c b/components/mbedtls/test_apps/main/test_mbedtls_sha.c index 003b35db8b5a..55e0a65e0985 100644 --- a/components/mbedtls/test_apps/main/test_mbedtls_sha.c +++ b/components/mbedtls/test_apps/main/test_mbedtls_sha.c @@ -587,7 +587,7 @@ TEST_CASE("mbedtls SHA stack in RTC RAM", "[mbedtls]") #endif //CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK -#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY && CONFIG_SPIRAM_USE_MALLOC +#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM && CONFIG_SPIRAM_USE_MALLOC TEST_CASE("mbedtls SHA stack in PSRAM", "[mbedtls]") { @@ -609,4 +609,4 @@ TEST_CASE("mbedtls SHA stack in PSRAM", "[mbedtls]") vSemaphoreDelete(done_sem); } -#endif //CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY && CONFIG_SPIRAM_USE_MALLOC +#endif //CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM && CONFIG_SPIRAM_USE_MALLOC diff --git a/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext b/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext index ad3452cf7b86..cd0e64116c8b 100644 --- a/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext +++ b/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext @@ -1,4 +1,4 @@ CONFIG_SPIRAM=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 diff --git a/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext_esp32p4_200m b/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext_esp32p4_200m index 1c29e19bb931..6ed71c76e361 100644 --- a/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext_esp32p4_200m +++ b/components/mbedtls/test_apps/sdkconfig.ci.psram_all_ext_esp32p4_200m @@ -1,7 +1,7 @@ CONFIG_IDF_TARGET="esp32p4" CONFIG_SPIRAM=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 CONFIG_IDF_EXPERIMENTAL_FEATURES=y diff --git a/docs/en/api-guides/external-ram.rst b/docs/en/api-guides/external-ram.rst index f8cebef14d42..2869531dbe20 100644 --- a/docs/en/api-guides/external-ram.rst +++ b/docs/en/api-guides/external-ram.rst @@ -213,7 +213,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. -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. +The option :ref:`CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM` 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/en/api-guides/inc/external-ram-esp32-notes.rst b/docs/en/api-guides/inc/external-ram-esp32-notes.rst index ac8f8d4764ce..b914ebd81657 100644 --- a/docs/en/api-guides/inc/external-ram-esp32-notes.rst +++ b/docs/en/api-guides/inc/external-ram-esp32-notes.rst @@ -1,4 +1,4 @@ -* Regarding stacks in PSRAM: For tasks that do not call ROM code in any way (directly or indirectly), the :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` option will eliminate the check in :cpp:func:`xTaskCreateStatic`, allowing a task's stack to be in external RAM. However, using this is **not advised**. +* Regarding stacks in PSRAM: For tasks that do not call ROM code in any way (directly or indirectly), the :ref:`CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM` option will eliminate the check in :cpp:func:`xTaskCreateStatic`, allowing a task's stack to be in external RAM. However, using this is **not advised**. * When used at 80 MHz clock speed, external RAM must also occupy either the HSPI or VSPI bus. Select which SPI host will be used by :ref:`CONFIG_SPIRAM_OCCUPY_SPI_HOST`. diff --git a/docs/zh_CN/api-guides/external-ram.rst b/docs/zh_CN/api-guides/external-ram.rst index 92bfa9eafcd6..7793385b285f 100644 --- a/docs/zh_CN/api-guides/external-ram.rst +++ b/docs/zh_CN/api-guides/external-ram.rst @@ -211,7 +211,7 @@ ESP-IDF 启动过程中,片外 RAM 被映射到数据虚拟地址空间,该 - 一般来说,片外 RAM 不会用作任务堆栈存储器。:cpp:func:`xTaskCreate` 及类似函数始终会为堆栈和任务 TCB 分配片上储存器。 -可以使用 :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` 选项将任务堆栈放入片外存储器。这时,必须使用 :cpp:func:`xTaskCreateStatic` 指定从片外存储器分配的任务堆栈缓冲区,否则任务堆栈将仍从片上存储器分配。 +可以使用 :ref:`CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM` 选项将任务堆栈放入片外存储器。这时,必须使用 :cpp:func:`xTaskCreateStatic` 指定从片外存储器分配的任务堆栈缓冲区,否则任务堆栈将仍从片上存储器分配。 初始化失败 diff --git a/docs/zh_CN/api-guides/inc/external-ram-esp32-notes.rst b/docs/zh_CN/api-guides/inc/external-ram-esp32-notes.rst index 6d93693c8de2..6c7186a32817 100644 --- a/docs/zh_CN/api-guides/inc/external-ram-esp32-notes.rst +++ b/docs/zh_CN/api-guides/inc/external-ram-esp32-notes.rst @@ -1,4 +1,4 @@ -* PSRAM 中的栈:对于不以任何直接或间接方式调用 ROM 中代码的任务,选项 :ref:`CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` 会取消 :cpp:func:`xTaskCreateStatic` 中的检查,允许任务栈存放在外部 RAM 中。但 **不建议** 使用此选项。 +* PSRAM 中的栈:对于不以任何直接或间接方式调用 ROM 中代码的任务,选项 :ref:`CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM` 会取消 :cpp:func:`xTaskCreateStatic` 中的检查,允许任务栈存放在外部 RAM 中。但 **不建议** 使用此选项。 * 在以 80 MHz 时钟速度运行时,外部 RAM 还必须占用 HSPI 或 VSPI 总线。设置 :ref:`CONFIG_SPIRAM_OCCUPY_SPI_HOST` 选项可以选择使用的 SPI 主机。 diff --git a/tools/test_apps/system/panic/main/include/test_panic.h b/tools/test_apps/system/panic/main/include/test_panic.h index 71733add77e4..32d051265544 100644 --- a/tools/test_apps/system/panic/main/include/test_panic.h +++ b/tools/test_apps/system/panic/main/include/test_panic.h @@ -31,7 +31,7 @@ void test_hw_stack_guard_cpu1(void); #endif // CONFIG_FREERTOS_UNICORE #endif // CONFIG_ESP_SYSTEM_HW_STACK_GUARD -#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM void test_panic_extram_stack_heap(void); #if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY void test_panic_extram_stack_bss(void); diff --git a/tools/test_apps/system/panic/main/test_app_main.c b/tools/test_apps/system/panic/main/test_app_main.c index b55f7de76526..a824e25e5bd1 100644 --- a/tools/test_apps/system/panic/main/test_app_main.c +++ b/tools/test_apps/system/panic/main/test_app_main.c @@ -95,7 +95,7 @@ void app_main(void) HANDLE_TEST(test_name, test_hw_stack_guard_cpu1); #endif // CONFIG_FREERTOS_UNICORE #endif // CONFIG_ESP_SYSTEM_HW_STACK_GUARD -#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM HANDLE_TEST(test_name, test_panic_extram_stack_heap); #if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY HANDLE_TEST(test_name, test_panic_extram_stack_bss); diff --git a/tools/test_apps/system/panic/main/test_panic.c b/tools/test_apps/system/panic/main/test_panic.c index 6f58469d826b..eafc9daddfee 100644 --- a/tools/test_apps/system/panic/main/test_panic.c +++ b/tools/test_apps/system/panic/main/test_panic.c @@ -96,7 +96,7 @@ void test_hw_stack_guard_cpu1(void) #endif // CONFIG_FREERTOS_UNICORE #endif // CONFIG_ESP_SYSTEM_HW_STACK_GUARD -#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM static void stack_in_extram(void* arg) { (void) arg; @@ -130,7 +130,7 @@ void test_panic_extram_stack_bss(void) vTaskDelay(1000); } #endif -#endif // ESP_COREDUMP_ENABLE_TO_FLASH && SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#endif // ESP_COREDUMP_ENABLE_TO_FLASH && FREERTOS_TASK_CREATE_ALLOW_EXT_MEM #if !CONFIG_FREERTOS_UNICORE diff --git a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32 b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32 index 26769c3c5981..065b49d68b24 100644 --- a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32 +++ b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32 @@ -5,7 +5,7 @@ CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y # We need to have the coredump info log CONFIG_LOG_DEFAULT_LEVEL_INFO=y CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_ESP_COREDUMP_USE_STACK_SIZE=y CONFIG_ESP_COREDUMP_CAPTURE_DRAM=y diff --git a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s2 b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s2 index ad1a91fa8119..7c372f58f2c2 100644 --- a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s2 +++ b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s2 @@ -5,7 +5,7 @@ CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y # We need to have the coredump info log CONFIG_LOG_DEFAULT_LEVEL_INFO=y CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_ESP_COREDUMP_USE_STACK_SIZE=y CONFIG_ESP_COREDUMP_CAPTURE_DRAM=y diff --git a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s3 b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s3 index 46903a022352..a1533240cb6b 100644 --- a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s3 +++ b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_bss_esp32s3 @@ -5,7 +5,7 @@ CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y # We need to have the coredump info log CONFIG_LOG_DEFAULT_LEVEL_INFO=y CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_ESP_COREDUMP_USE_STACK_SIZE=y CONFIG_ESP_COREDUMP_CAPTURE_DRAM=y diff --git a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32 b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32 index 18391318a374..a98716641a9a 100644 --- a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32 +++ b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32 @@ -5,5 +5,5 @@ CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y # We need to have the coredump info log CONFIG_LOG_DEFAULT_LEVEL_INFO=y CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_ESP_COREDUMP_USE_STACK_SIZE=y diff --git a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s2 b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s2 index 981803c0be23..dddebf12c098 100644 --- a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s2 +++ b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s2 @@ -5,5 +5,5 @@ CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y # We need to have the coredump info log CONFIG_LOG_DEFAULT_LEVEL_INFO=y CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_ESP_COREDUMP_USE_STACK_SIZE=y diff --git a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s3 b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s3 index ff952817bde2..552021189427 100644 --- a/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s3 +++ b/tools/test_apps/system/panic/sdkconfig.ci.coredump_flash_extram_stack_heap_esp32s3 @@ -5,5 +5,5 @@ CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y # We need to have the coredump info log CONFIG_LOG_DEFAULT_LEVEL_INFO=y CONFIG_SPIRAM=y -CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y CONFIG_ESP_COREDUMP_USE_STACK_SIZE=y