diff --git a/components/esp_mm/test_apps/mm/CMakeLists.txt b/components/esp_mm/test_apps/mm/CMakeLists.txt index 3e976ca666..cf0f0e0182 100644 --- a/components/esp_mm/test_apps/mm/CMakeLists.txt +++ b/components/esp_mm/test_apps/mm/CMakeLists.txt @@ -10,6 +10,16 @@ set(COMPONENTS main esp_psram) include($ENV{IDF_PATH}/tools/cmake/project.cmake) 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) add_custom_target(check_test_app_sections ALL COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py @@ -18,6 +28,7 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES) find-refs --from-sections=.iram0.text --to-sections=.flash.text,.flash.rodata + --ignore-refs=${ignore_refs} --exit-code DEPENDS ${elf} ) diff --git a/components/esp_mm/test_apps/mm/main/test_mmap.c b/components/esp_mm/test_apps/mm/main/test_mmap.c index 2fd0f1a2c3..e0ee721d1b 100644 --- a/components/esp_mm/test_apps/mm/main/test_mmap.c +++ b/components/esp_mm/test_apps/mm/main/test_mmap.c @@ -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 */ @@ -70,3 +70,26 @@ TEST_CASE("Can find paddr caps by any paddr offset", "[mmu]") 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 diff --git a/components/esp_mm/test_apps/mm/pytest_mmap.py b/components/esp_mm/test_apps/mm/pytest_mmap.py index 5282a7f581..04accedf06 100644 --- a/components/esp_mm/test_apps/mm/pytest_mmap.py +++ b/components/esp_mm/test_apps/mm/pytest_mmap.py @@ -1,6 +1,5 @@ # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 - import pytest 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_esp32s2', marks=[pytest.mark.esp32s2]), pytest.param('psram_release_esp32s3', marks=[pytest.mark.esp32s3]), + pytest.param('psram_release_esp32p4', marks=[pytest.mark.esp32p4]), ] diff --git a/components/esp_mm/test_apps/mm/sdkconfig.ci.psram_release_esp32p4 b/components/esp_mm/test_apps/mm/sdkconfig.ci.psram_release_esp32p4 new file mode 100644 index 0000000000..460e79b5db --- /dev/null +++ b/components/esp_mm/test_apps/mm/sdkconfig.ci.psram_release_esp32p4 @@ -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 diff --git a/components/esp_mm/test_apps/mm/sdkconfig.ci.xip_psram_esp32p4 b/components/esp_mm/test_apps/mm/sdkconfig.ci.xip_psram_esp32p4 new file mode 100644 index 0000000000..c7d28cedd0 --- /dev/null +++ b/components/esp_mm/test_apps/mm/sdkconfig.ci.xip_psram_esp32p4 @@ -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