Эх сурвалжийг харах

mmu: hal function to init, and hal function to unmap all

Armando 2 жил өмнө
parent
commit
bae6680207

+ 1 - 1
components/bootloader_support/bootloader_flash/src/bootloader_flash.c

@@ -241,7 +241,7 @@ void bootloader_munmap(const void *mapping)
         mmu_init(0);
 #else
         cache_hal_disable(CACHE_TYPE_ALL);
-        mmu_hal_init();
+        mmu_hal_unmap_all();
 #endif
         mapped = false;
         current_read_mapping = UINT32_MAX;

+ 2 - 2
components/bootloader_support/src/bootloader_utility.c

@@ -845,8 +845,8 @@ static void set_cache_and_start_app(
 #else
     cache_hal_disable(CACHE_TYPE_ALL);
 #endif
-
-    mmu_hal_init();
+    //reset MMU table first
+    mmu_hal_unmap_all();
 
     //-----------------------MAP DROM--------------------------
     uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK;

+ 1 - 4
components/bootloader_support/src/esp32c2/bootloader_esp32c2.c

@@ -38,7 +38,6 @@
 #include "esp_efuse.h"
 #include "hal/mmu_hal.h"
 #include "hal/cache_hal.h"
-#include "hal/mmu_ll.h"
 
 static const char *TAG = "boot.esp32c2";
 
@@ -113,10 +112,8 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     //init cache hal
     cache_hal_init();
-    //reset mmu
+    //init mmu
     mmu_hal_init();
-    // config mmu page size
-    mmu_ll_set_page_size(0, SPI_FLASH_MMU_PAGE_SIZE);
     // update flash ID
     bootloader_flash_update_id();
 #if !CONFIG_APP_BUILD_TYPE_RAM

+ 1 - 1
components/bootloader_support/src/esp32c3/bootloader_esp32c3.c

@@ -161,7 +161,7 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     //init cache hal
     cache_hal_init();
-    //reset mmu
+    //init mmu
     mmu_hal_init();
     // update flash ID
     bootloader_flash_update_id();

+ 1 - 4
components/bootloader_support/src/esp32c6/bootloader_esp32c6.c

@@ -40,7 +40,6 @@
 #include "esp_private/bootloader_flash_internal.h"
 #include "esp_efuse.h"
 #include "hal/mmu_hal.h"
-#include "hal/mmu_ll.h"
 #include "hal/cache_hal.h"
 #include "hal/clk_tree_ll.h"
 #include "soc/lp_wdt_reg.h"
@@ -169,10 +168,8 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     //init cache hal
     cache_hal_init();
-    //reset mmu
+    //init mmu
     mmu_hal_init();
-    // config mmu page size
-    mmu_ll_set_page_size(0, SPI_FLASH_MMU_PAGE_SIZE);
     // update flash ID
     bootloader_flash_update_id();
     // Check and run XMC startup flow

+ 1 - 4
components/bootloader_support/src/esp32h2/bootloader_esp32h2.c

@@ -40,7 +40,6 @@
 #include "esp_private/bootloader_flash_internal.h"
 #include "esp_efuse.h"
 #include "hal/mmu_hal.h"
-#include "hal/mmu_ll.h"
 #include "hal/cache_hal.h"
 #include "soc/lp_wdt_reg.h"
 #include "hal/efuse_hal.h"
@@ -159,10 +158,8 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     //init cache hal
     cache_hal_init();
-    //reset mmu
+    //init mmu
     mmu_hal_init();
-    // config mmu page size
-    mmu_ll_set_page_size(0, SPI_FLASH_MMU_PAGE_SIZE);
     // update flash ID
     bootloader_flash_update_id();
     // Check and run XMC startup flow

+ 1 - 1
components/bootloader_support/src/esp32h4/bootloader_esp32h4.c

@@ -120,7 +120,7 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     //init cache hal
     cache_hal_init();   //TODO IDF-4649
-    //reset mmu
+    //init mmu
     mmu_hal_init();
     // update flash ID
     bootloader_flash_update_id();

+ 1 - 1
components/bootloader_support/src/esp32s2/bootloader_esp32s2.c

@@ -142,7 +142,7 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     // init cache hal
     cache_hal_init();
-    // reset mmu
+    //init mmu
     mmu_hal_init();
     // Workaround: normal ROM bootloader exits with DROM0 cache unmasked, but 2nd bootloader exits with it masked.
     REG_CLR_BIT(EXTMEM_PRO_ICACHE_CTRL1_REG, EXTMEM_PRO_ICACHE_MASK_DROM0);

+ 1 - 1
components/bootloader_support/src/esp32s3/bootloader_esp32s3.c

@@ -180,7 +180,7 @@ esp_err_t bootloader_init(void)
 #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
     //init cache hal
     cache_hal_init();
-    //reset mmu
+    //init mmu
     mmu_hal_init();
     // update flash ID
     bootloader_flash_update_id();

+ 6 - 1
components/hal/include/hal/mmu_hal.h

@@ -14,10 +14,15 @@ extern "C" {
 #endif
 
 /**
- * Unmap all the MMU table. After this all external memory vaddr are not available
+ * MMU Hal layer initialisation
  */
 void mmu_hal_init(void);
 
+/**
+ * Unmap all the MMU table. After this all external memory vaddr are not available
+ */
+void mmu_hal_unmap_all(void);
+
 /**
  * Helper functions to convert the MMU page numbers into bytes. e.g.:
  * - When MMU page size is 16KB, page_num = 2 will be converted into 32KB

+ 5 - 0
components/hal/mmu_hal.c

@@ -19,7 +19,12 @@ void mmu_hal_init(void)
 #if CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT
     ROM_Boot_Cache_Init();
 #endif
+    mmu_ll_set_page_size(0, CONFIG_MMU_PAGE_SIZE);
+    mmu_hal_unmap_all();
+}
 
+void mmu_hal_unmap_all(void)
+{
     mmu_ll_unmap_all(0);
 #if !CONFIG_FREERTOS_UNICORE
     mmu_ll_unmap_all(1);