From 45db752f2fd20cbf705433f79ec86ca03797ed0f Mon Sep 17 00:00:00 2001 From: armando Date: Mon, 12 May 2025 15:12:19 +0800 Subject: [PATCH] feat(mmu): supported esp_mmu_map and flash_mmap drivers on esp32h21 --- components/hal/esp32h21/include/hal/mmu_ll.h | 2 -- .../esp32h21/include/soc/Kconfig.soc_caps.in | 8 ++++++ .../soc/esp32h21/include/soc/ext_mem_defs.h | 25 +++++++++++++------ .../soc/esp32h21/include/soc/soc_caps.h | 4 +-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/components/hal/esp32h21/include/hal/mmu_ll.h b/components/hal/esp32h21/include/hal/mmu_ll.h index 39a7a102b2..cc4e484f92 100644 --- a/components/hal/esp32h21/include/hal/mmu_ll.h +++ b/components/hal/esp32h21/include/hal/mmu_ll.h @@ -14,8 +14,6 @@ #include "hal/mmu_types.h" #include "hal/efuse_ll.h" -//TODO: [ESP32H21] IDF-11540, inherit from h2 - #ifdef __cplusplus extern "C" { #endif diff --git a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in index 6db11d52bb..d40758f3a1 100644 --- a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in @@ -255,6 +255,14 @@ config SOC_CPU_PMP_REGION_GRANULARITY int default 4 +config SOC_MMU_PAGE_SIZE_CONFIGURABLE + bool + default y + +config SOC_MMU_PAGE_SIZE_8KB_SUPPORTED + bool + default y + config SOC_MMU_PERIPH_NUM int default 1 diff --git a/components/soc/esp32h21/include/soc/ext_mem_defs.h b/components/soc/esp32h21/include/soc/ext_mem_defs.h index 1d4f57afbd..68398ad85a 100644 --- a/components/soc/esp32h21/include/soc/ext_mem_defs.h +++ b/components/soc/esp32h21/include/soc/ext_mem_defs.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -75,25 +75,34 @@ extern "C" { #if (SOC_MMU_PAGE_SIZE == 0x10000) /** * - 64KB MMU page size: the last 0xFFFF, which is the offset - * - 128 MMU entries, needs 0x7F to hold it. + * - 256 MMU entries, needs 0xFF to hold it. + * + * Therefore, 0xFF,FFFF + */ +#define SOC_MMU_LINEAR_ADDR_MASK 0xFFFFFF + +#elif (SOC_MMU_PAGE_SIZE == 0x8000) +/** + * - 32KB MMU page size: the last 0x7FFF, which is the offset + * - 256 MMU entries, needs 0xFF to hold it. * * Therefore, 0x7F,FFFF */ #define SOC_MMU_LINEAR_ADDR_MASK 0x7FFFFF -#elif (SOC_MMU_PAGE_SIZE == 0x8000) +#elif (SOC_MMU_PAGE_SIZE == 0x4000) /** - * - 32KB MMU page size: the last 0x7FFF, which is the offset - * - 128 MMU entries, needs 0x7F to hold it. + * - 16KB MMU page size: the last 0x3FFF, which is the offset + * - 256 MMU entries, needs 0xFF to hold it. * * Therefore, 0x3F,FFFF */ #define SOC_MMU_LINEAR_ADDR_MASK 0x3FFFFF -#elif (SOC_MMU_PAGE_SIZE == 0x4000) +#elif (SOC_MMU_PAGE_SIZE == 0x2000) /** - * - 16KB MMU page size: the last 0x3FFF, which is the offset - * - 128 MMU entries, needs 0x7F to hold it. + * - 8KB MMU page size: the last 0x1FFF, which is the offset + * - 256 MMU entries, needs 0xFF to hold it. * * Therefore, 0x1F,FFFF */ diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index 1081cb9efc..caf715af0b 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -161,8 +161,8 @@ #define SOC_CPU_PMP_REGION_GRANULARITY 4 /*-------------------------- MMU CAPS ----------------------------------------*/ -// #define SOC_MMU_PAGE_SIZE_CONFIGURABLE (1) -// #define SOC_MMU_PAGE_SIZE_8KB_SUPPORTED (1) +#define SOC_MMU_PAGE_SIZE_CONFIGURABLE (1) +#define SOC_MMU_PAGE_SIZE_8KB_SUPPORTED (1) #define SOC_MMU_PERIPH_NUM (1U) #define SOC_MMU_LINEAR_ADDRESS_REGION_NUM (1U) #define SOC_MMU_DI_VADDR_SHARED (1) /*!< D/I vaddr are shared */