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()
This commit is contained in:
harshal.patil
2025-03-13 10:34:26 +05:30
parent f58c78b644
commit c67901fc07
6 changed files with 74 additions and 4 deletions

View File

@@ -1,8 +1,11 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/esp_psram/test_apps/psram:
enable:
- if: CONFIG_NAME == "psram_no_boot_init" and SOC_SPIRAM_SUPPORTED == 1
disable:
- if: SOC_SPIRAM_SUPPORTED != 1
- if: CONFIG_NAME == "xip_psram_no_boot_init" and SOC_SPIRAM_XIP_SUPPORTED != 1
depends_components:
- esp_psram
- esp_mm

View File

@@ -1,10 +1,15 @@
idf_build_get_property(target IDF_TARGET)
set(srcs "test_app_main.c"
"test_psram.c")
set(srcs "test_app_main.c")
if(${target} STREQUAL "esp32")
list(APPEND srcs "test_himem.c" "test_4mpsram.c")
if(CONFIG_SPIRAM_BOOT_INIT)
list(APPEND srcs "test_psram.c")
if(${target} STREQUAL "esp32")
list(APPEND srcs "test_himem.c" "test_4mpsram.c")
endif()
else()
list(APPEND srcs "test_psram_no_boot_init.c")
endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,

View File

@@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "sdkconfig.h"
#include "unity.h"
#include "esp_psram.h"
#include "esp_private/esp_psram_extram.h"
TEST_CASE("test psram no boot init", "[psram_no_boot_init]")
{
#if CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION
// As PSRAM is just enabled and not initialised during the boot up, the API
// esp_psram_get_heap_size_to_protect() manually calculates the size of the PSRAM heap
size_t manually_calculated_psram_heap = esp_psram_get_heap_size_to_protect();
#endif /* CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION */
TEST_ESP_OK(esp_psram_init());
#if CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION
size_t final_psram_heap = esp_psram_get_heap_size_to_protect();
TEST_ASSERT_EQUAL(final_psram_heap, manually_calculated_psram_heap);
#endif /* CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION */
}

View File

@@ -112,3 +112,29 @@ def test_psram_esp32c5(dut: Dut) -> None:
@idf_parametrize('target', ['esp32c61'], indirect=['target'])
def test_psram_esp32c61(dut: Dut) -> None:
dut.run_all_single_board_cases()
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
'xip_psram_no_boot_init',
],
indirect=True,
)
@idf_parametrize('target', ['esp32s2', 'esp32s3', 'esp32c5', 'esp32c61'], indirect=['target'])
def test_xip_psram_no_boot_init(dut: Dut) -> None:
dut.run_all_single_board_cases()
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
'psram_no_boot_init',
],
indirect=True,
)
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
def test_psram_no_boot_init(dut: Dut) -> None:
dut.run_all_single_board_cases()

View File

@@ -0,0 +1,4 @@
CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_HW_INIT=y
CONFIG_SPIRAM_BOOT_INIT=n
CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION=y

View File

@@ -0,0 +1,7 @@
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_BOOT_HW_INIT=y
CONFIG_SPIRAM_BOOT_INIT=n
CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION=y