From 133a2173151444cfde91864bb57ce2890f1329f5 Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 26 Jul 2024 15:00:44 +0800 Subject: [PATCH 1/3] change(mmu): removed not-used SOC_MMU_PAGE_SIZE_CONFIGURABLE macro which is 0 on p4 --- components/hal/esp32c5/include/hal/mmu_ll.h | 12 ++---------- .../soc/esp32p4/include/soc/Kconfig.soc_caps.in | 4 ---- components/soc/esp32p4/include/soc/soc_caps.h | 1 - 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/components/hal/esp32c5/include/hal/mmu_ll.h b/components/hal/esp32c5/include/hal/mmu_ll.h index 610c45b7cb..398d2bd7a1 100644 --- a/components/hal/esp32c5/include/hal/mmu_ll.h +++ b/components/hal/esp32c5/include/hal/mmu_ll.h @@ -79,11 +79,7 @@ __attribute__((always_inline)) static inline mmu_page_size_t mmu_ll_get_page_size(uint32_t mmu_id) { (void)mmu_id; - uint32_t page_size_code = REG_GET_FIELD(SPI_MEM_MMU_POWER_CTRL_REG(0), SPI_MMU_PAGE_SIZE); - return (page_size_code == 0) ? MMU_PAGE_64KB : - (page_size_code == 1) ? MMU_PAGE_32KB : - (page_size_code == 2) ? MMU_PAGE_16KB : - MMU_PAGE_8KB; + return MMU_PAGE_64KB; } /** @@ -94,11 +90,7 @@ static inline mmu_page_size_t mmu_ll_get_page_size(uint32_t mmu_id) __attribute__((always_inline)) static inline void mmu_ll_set_page_size(uint32_t mmu_id, uint32_t size) { - uint8_t reg_val = (size == MMU_PAGE_64KB) ? 0 : - (size == MMU_PAGE_32KB) ? 1 : - (size == MMU_PAGE_16KB) ? 2 : - (size == MMU_PAGE_8KB) ? 3 : 0; - REG_SET_FIELD(SPI_MEM_MMU_POWER_CTRL_REG(0), SPI_MMU_PAGE_SIZE, reg_val); + HAL_ASSERT(size == MMU_PAGE_64KB); } /** diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 407dabbe59..813ba34378 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -883,10 +883,6 @@ config SOC_LEDC_FADE_PARAMS_BIT_WIDTH int default 10 -config SOC_MMU_PAGE_SIZE_CONFIGURABLE - bool - default n - config SOC_MMU_PERIPH_NUM int default 2 diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 3f9dfd3bd8..55af4b7118 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -346,7 +346,6 @@ #define SOC_LEDC_FADE_PARAMS_BIT_WIDTH (10) /*-------------------------- MMU CAPS ----------------------------------------*/ -#define SOC_MMU_PAGE_SIZE_CONFIGURABLE (0) #define SOC_MMU_PERIPH_NUM (2U) #define SOC_MMU_LINEAR_ADDRESS_REGION_NUM (2U) #define SOC_MMU_DI_VADDR_SHARED (1) /*!< D/I vaddr are shared */ From f6255dde5d84827a3185aef3ab340531fce720ca Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 26 Jul 2024 15:17:28 +0800 Subject: [PATCH 2/3] feat(mmu): added 8KB mmu page size option for c6 h2 --- components/soc/Kconfig | 5 +++++ components/soc/esp32c6/include/soc/Kconfig.soc_caps.in | 4 ++++ components/soc/esp32c6/include/soc/soc_caps.h | 1 + components/soc/esp32h2/include/soc/Kconfig.soc_caps.in | 4 ++++ components/soc/esp32h2/include/soc/soc_caps.h | 1 + 5 files changed, 15 insertions(+) diff --git a/components/soc/Kconfig b/components/soc/Kconfig index 8d7c21cf60..dcc3e39da3 100644 --- a/components/soc/Kconfig +++ b/components/soc/Kconfig @@ -7,6 +7,11 @@ menu "SoC Settings" # Be configured based on flash size selection. # Invisible to users. + config MMU_PAGE_SIZE_8KB + bool + depends on SOC_MMU_PAGE_SIZE_8KB_SUPPORTED + default n + config MMU_PAGE_SIZE_16KB bool default y if SOC_MMU_PAGE_SIZE_CONFIGURABLE && ESPTOOLPY_FLASHSIZE_1MB diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 077af618ff..24190f9730 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -707,6 +707,10 @@ 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/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index f9fcf1fe02..0eb47fef8f 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -285,6 +285,7 @@ /*-------------------------- MMU CAPS ----------------------------------------*/ #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 */ diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index e8be302fb5..28331e9ca7 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -411,6 +411,10 @@ 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/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index e47941cfd0..c929016b8c 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -155,6 +155,7 @@ /*-------------------------- MMU CAPS ----------------------------------------*/ #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 */ From e07111ae34392bd39ae5db23ba2fb82997419ea6 Mon Sep 17 00:00:00 2001 From: Armando Date: Mon, 29 Jul 2024 14:42:39 +0800 Subject: [PATCH 3/3] feat(mmu): supported on c61 --- components/hal/esp32c61/include/hal/mmu_ll.h | 3 ++- components/soc/esp32c61/include/soc/Kconfig.soc_caps.in | 4 ++++ components/soc/esp32c61/include/soc/soc_caps.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/components/hal/esp32c61/include/hal/mmu_ll.h b/components/hal/esp32c61/include/hal/mmu_ll.h index 44aac374f6..105c8485e8 100644 --- a/components/hal/esp32c61/include/hal/mmu_ll.h +++ b/components/hal/esp32c61/include/hal/mmu_ll.h @@ -302,7 +302,8 @@ static inline bool mmu_ll_check_entry_valid(uint32_t mmu_id, uint32_t entry_id) static inline mmu_target_t mmu_ll_get_entry_target(uint32_t mmu_id, uint32_t entry_id) { (void)mmu_id; - return MMU_TARGET_FLASH0; + mmu_target_t target = ((REG_READ(SPI_MEM_MMU_ITEM_CONTENT_REG(0)) & SOC_MMU_ACCESS_SPIRAM) == 0) ? MMU_TARGET_FLASH0 : MMU_TARGET_PSRAM0; + return target; } /** diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index 019cf85284..44fba65f96 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -243,6 +243,10 @@ 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/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 977594e2a7..99fbb8f7b2 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -278,6 +278,7 @@ /*-------------------------- MMU CAPS ----------------------------------------*/ #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 */