From e50e78b75f0b6946949512ead37eecf074fbbc1a Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Fri, 28 Jun 2024 11:57:59 +0300 Subject: [PATCH] Add temporary fix for mmu map and late init of psram --- patches/mmu_map.diff | 24 ++++++++++++++++++++++++ tools/install-esp-idf.sh | 1 + 2 files changed, 25 insertions(+) create mode 100644 patches/mmu_map.diff diff --git a/patches/mmu_map.diff b/patches/mmu_map.diff new file mode 100644 index 000000000..3bf56005a --- /dev/null +++ b/patches/mmu_map.diff @@ -0,0 +1,24 @@ +diff --git a/components/esp_mm/esp_mmu_map.c b/components/esp_mm/esp_mmu_map.c +index b7d927f8fe..6a8c4635f0 100644 +--- a/components/esp_mm/esp_mmu_map.c ++++ b/components/esp_mm/esp_mmu_map.c +@@ -315,6 +315,19 @@ esp_err_t esp_mmu_map_reserve_block_with_caps(size_t size, mmu_mem_caps_t caps, + s_mmu_ctx.mem_regions[found_region_id].max_slot_size -= aligned_size; + ESP_EARLY_LOGV(TAG, "found laddr is 0x%x", laddr); + ++ mem_block_t *mem_block = NULL; ++ mem_region_t *region = &s_mmu_ctx.mem_regions[found_region_id]; ++ TAILQ_FOREACH(mem_block, ®ion->mem_block_head, entries) { ++ if (mem_block == TAILQ_FIRST(®ion->mem_block_head) || mem_block == TAILQ_LAST(®ion->mem_block_head, mem_block_head_)) { ++ TAILQ_REMOVE(®ion->mem_block_head, mem_block, entries); ++ } else { ++ // probably the reservation of MMU region should be disallowed for this case - already some MMU mappings exist? ++ // assert/abort ++ ESP_EARLY_LOGE(TAG, "already some MMU mappings exist?"); ++ abort(); ++ } ++ } ++ + uint32_t vaddr = 0; + if (caps & MMU_MEM_CAP_EXEC) { + vaddr = mmu_ll_laddr_to_vaddr(laddr, MMU_VADDR_INSTRUCTION); diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 7ab329589..95b5e5587 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -38,6 +38,7 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then # Temporarily patch the ESP32-S2 I2C LL driver to keep the clock source cd $IDF_PATH patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff + patch -p1 -N -i ../patches/mmu_map.diff cd - fi