Skip to content

Commit c67901f

Browse files
committed
ci(esp_psram): Add a test to validate non-bootup PSRAM initialisation
- Also adds a test for the newly added PSRAM helper APIs: esp_psram_get_heap_pool_size() and esp_psram_get_effective_mapped_size()
1 parent f58c78b commit c67901f

File tree

6 files changed

+74
-4
lines changed

6 files changed

+74
-4
lines changed

components/esp_psram/test_apps/.build-test-rules.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
22

33
components/esp_psram/test_apps/psram:
4+
enable:
5+
- if: CONFIG_NAME == "psram_no_boot_init" and SOC_SPIRAM_SUPPORTED == 1
46
disable:
57
- if: SOC_SPIRAM_SUPPORTED != 1
8+
- if: CONFIG_NAME == "xip_psram_no_boot_init" and SOC_SPIRAM_XIP_SUPPORTED != 1
69
depends_components:
710
- esp_psram
811
- esp_mm

components/esp_psram/test_apps/psram/main/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
idf_build_get_property(target IDF_TARGET)
22

3-
set(srcs "test_app_main.c"
4-
"test_psram.c")
3+
set(srcs "test_app_main.c")
54

6-
if(${target} STREQUAL "esp32")
7-
list(APPEND srcs "test_himem.c" "test_4mpsram.c")
5+
if(CONFIG_SPIRAM_BOOT_INIT)
6+
list(APPEND srcs "test_psram.c")
7+
8+
if(${target} STREQUAL "esp32")
9+
list(APPEND srcs "test_himem.c" "test_4mpsram.c")
10+
endif()
11+
else()
12+
list(APPEND srcs "test_psram_no_boot_init.c")
813
endif()
914

1015
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
6+
#include "sdkconfig.h"
7+
#include "unity.h"
8+
#include "esp_psram.h"
9+
#include "esp_private/esp_psram_extram.h"
10+
11+
TEST_CASE("test psram no boot init", "[psram_no_boot_init]")
12+
{
13+
#if CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION
14+
// As PSRAM is just enabled and not initialised during the boot up, the API
15+
// esp_psram_get_heap_size_to_protect() manually calculates the size of the PSRAM heap
16+
size_t manually_calculated_psram_heap = esp_psram_get_heap_size_to_protect();
17+
#endif /* CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION */
18+
19+
TEST_ESP_OK(esp_psram_init());
20+
21+
#if CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION
22+
size_t final_psram_heap = esp_psram_get_heap_size_to_protect();
23+
TEST_ASSERT_EQUAL(final_psram_heap, manually_calculated_psram_heap);
24+
#endif /* CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION */
25+
}

components/esp_psram/test_apps/psram/pytest_psram.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,29 @@ def test_psram_esp32c5(dut: Dut) -> None:
112112
@idf_parametrize('target', ['esp32c61'], indirect=['target'])
113113
def test_psram_esp32c61(dut: Dut) -> None:
114114
dut.run_all_single_board_cases()
115+
116+
117+
@pytest.mark.generic
118+
@pytest.mark.parametrize(
119+
'config',
120+
[
121+
'xip_psram_no_boot_init',
122+
],
123+
indirect=True,
124+
)
125+
@idf_parametrize('target', ['esp32s2', 'esp32s3', 'esp32c5', 'esp32c61'], indirect=['target'])
126+
def test_xip_psram_no_boot_init(dut: Dut) -> None:
127+
dut.run_all_single_board_cases()
128+
129+
130+
@pytest.mark.generic
131+
@pytest.mark.parametrize(
132+
'config',
133+
[
134+
'psram_no_boot_init',
135+
],
136+
indirect=True,
137+
)
138+
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
139+
def test_psram_no_boot_init(dut: Dut) -> None:
140+
dut.run_all_single_board_cases()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_SPIRAM=y
2+
CONFIG_SPIRAM_BOOT_HW_INIT=y
3+
CONFIG_SPIRAM_BOOT_INIT=n
4+
CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION=y
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_SPIRAM=y
2+
CONFIG_SPIRAM_XIP_FROM_PSRAM=y
3+
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
4+
CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y
5+
CONFIG_SPIRAM_BOOT_HW_INIT=y
6+
CONFIG_SPIRAM_BOOT_INIT=n
7+
CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION=y

0 commit comments

Comments
 (0)