test(mmu): added test for checking esp_mmu_vaddr_to_paddr with psram vaddrs

This commit is contained in:
Armando 2025-02-14 11:56:14 +08:00
parent 299d8115ed
commit fd09700aab
5 changed files with 49 additions and 2 deletions

View File

@ -10,6 +10,16 @@ set(COMPONENTS main esp_psram)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(mm_test) project(mm_test)
string(JOIN "," ignore_refs)
if(CONFIG_SOC_MMU_PER_EXT_MEM_TARGET AND CONFIG_SPIRAM_FLASH_LOAD_TO_PSRAM)
# On SOC_MMU_PER_EXT_MEM_TARGET chips, when xip_psram, we need
# - _instruction_reserved_start, _instruction_reserved_end
# - _rodata_reserved_start, _rodata_reserved_end
# to do some calculation. As we don't access the addresses, so we disable this check
list(APPEND ignore_refs esp_mmu_map_init/*)
endif()
if(CONFIG_COMPILER_DUMP_RTL_FILES) if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(check_test_app_sections ALL add_custom_target(check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
@ -18,6 +28,7 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES)
find-refs find-refs
--from-sections=.iram0.text --from-sections=.iram0.text
--to-sections=.flash.text,.flash.rodata --to-sections=.flash.text,.flash.rodata
--ignore-refs=${ignore_refs}
--exit-code --exit-code
DEPENDS ${elf} DEPENDS ${elf}
) )

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -70,3 +70,26 @@ TEST_CASE("Can find paddr caps by any paddr offset", "[mmu]")
TEST_ESP_OK(esp_mmu_unmap(ptr0)); TEST_ESP_OK(esp_mmu_unmap(ptr0));
} }
#if CONFIG_SPIRAM
#if !CONFIG_IDF_TARGET_ESP32 //ESP32 doesn't support using `esp_mmu_map` to map to PSRAM
TEST_CASE("Can find paddr when mapping to psram", "[mmu]")
{
esp_paddr_t paddr = 0;
mmu_target_t target = MMU_TARGET_FLASH0;
void *vaddr = NULL;
esp_err_t err = ESP_FAIL;
vaddr = heap_caps_malloc(10, MALLOC_CAP_SPIRAM);
err = esp_mmu_vaddr_to_paddr(vaddr, &paddr, &target);
if (err == ESP_OK) {
ESP_LOGI("MMU", "Virtual Address: %p, Physical Address: 0x%lx, Target: %d", vaddr, paddr, target);
} else {
ESP_LOGE("MMU", "Failed to convert virtual address to physical address: %s", esp_err_to_name(err));
}
TEST_ASSERT(target == MMU_TARGET_PSRAM0);
}
#endif //#if !CONFIG_IDF_TARGET_ESP32
#endif //#if CONFIG_SPIRAM

View File

@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
import pytest import pytest
from pytest_embedded import Dut from pytest_embedded import Dut
@ -24,6 +23,7 @@ PSRAM_RELEASE_CONFIGS = [
pytest.param('psram_release_esp32', marks=[pytest.mark.esp32]), pytest.param('psram_release_esp32', marks=[pytest.mark.esp32]),
pytest.param('psram_release_esp32s2', marks=[pytest.mark.esp32s2]), pytest.param('psram_release_esp32s2', marks=[pytest.mark.esp32s2]),
pytest.param('psram_release_esp32s3', marks=[pytest.mark.esp32s3]), pytest.param('psram_release_esp32s3', marks=[pytest.mark.esp32s3]),
pytest.param('psram_release_esp32p4', marks=[pytest.mark.esp32p4]),
] ]

View File

@ -0,0 +1,6 @@
CONFIG_IDF_TARGET="esp32p4"
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_SPIRAM=y

View File

@ -0,0 +1,7 @@
CONFIG_IDF_TARGET="esp32p4"
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_XIP_FROM_PSRAM=y