-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refactor/spi_ram_stack_with_heap_caps_config' into 'mas…
…ter' refactor(esp_psram): allow PSRAM as stack when PSRAM is only available via esp_heap_caps Closes IDFGH-11604 See merge request espressif/esp-idf!32832
- Loading branch information
Showing
9 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
components/esp_psram/test_apps/psram_no_malloc_task_stack/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 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) |
2 changes: 2 additions & 0 deletions
2
components/esp_psram/test_apps/psram_no_malloc_task_stack/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| Supported Targets | ESP32 | ESP32-P4 | | ||
| ----------------- | ----- | -------- | |
3 changes: 3 additions & 0 deletions
3
components/esp_psram/test_apps/psram_no_malloc_task_stack/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "test_psram_no_malloc_task_stack.c" | ||
INCLUDE_DIRS "." | ||
PRIV_REQUIRES unity esp_psram freertos heap) |
82 changes: 82 additions & 0 deletions
82
...nts/esp_psram/test_apps/psram_no_malloc_task_stack/main/test_psram_no_malloc_task_stack.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
*/ | ||
#include <stdio.h> | ||
#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(); | ||
} |
11 changes: 11 additions & 0 deletions
11
...nents/esp_psram/test_apps/psram_no_malloc_task_stack/pytest_psram_no_malloc_task_stack.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 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() |
4 changes: 4 additions & 0 deletions
4
components/esp_psram/test_apps/psram_no_malloc_task_stack/sdkconfig.defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONFIG_ESP_TASK_WDT_EN=n | ||
CONFIG_SPIRAM=y | ||
CONFIG_SPIRAM_USE_CAPS_ALLOC=y | ||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters