From acbf871d2f6eb661e433618a1f1c8c94b2dc7536 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Tue, 23 Nov 2021 16:08:56 -0300 Subject: [PATCH 1/2] bootloader_support: Fix unused-variable compiler warning Builds for every chip other than ESP32 resulted in a compiler warning due to "drom_load_addr_aligned" and "irom_load_addr_aligned" not being used, besides being possible to actually reuse them. Furthermore, extended the logic for the other similar variables. Signed-off-by: Gustavo Henrique Nihei --- .../src/bootloader_utility.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/bootloader_support/src/bootloader_utility.c b/components/bootloader_support/src/bootloader_utility.c index 82982c3305..5265b25510 100644 --- a/components/bootloader_support/src/bootloader_utility.c +++ b/components/bootloader_support/src/bootloader_utility.c @@ -736,8 +736,8 @@ static void set_cache_and_start_app( #endif /* Clear the MMU entries that are already set up, - so the new app only has the mappings it creates. - */ + * so the new app only has the mappings it creates. + */ #if CONFIG_IDF_TARGET_ESP32 for (int i = 0; i < DPORT_FLASH_MMU_TABLE_SIZE; i++) { DPORT_PRO_FLASH_MMU_TABLE[i] = DPORT_FLASH_MMU_TABLE_INVALID_VAL; @@ -748,27 +748,29 @@ static void set_cache_and_start_app( } #endif uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK; + uint32_t drom_addr_aligned = drom_addr & MMU_FLASH_MASK; uint32_t drom_page_count = bootloader_cache_pages_to_map(drom_size, drom_load_addr); ESP_LOGV(TAG, "d mmu set paddr=%08x vaddr=%08x size=%d n=%d", - drom_addr & MMU_FLASH_MASK, drom_load_addr_aligned, drom_size, drom_page_count); + drom_addr_aligned, drom_load_addr_aligned, drom_size, drom_page_count); #if CONFIG_IDF_TARGET_ESP32 - rc = cache_flash_mmu_set(0, 0, drom_load_addr_aligned, drom_addr & MMU_FLASH_MASK, 64, drom_page_count); + rc = cache_flash_mmu_set(0, 0, drom_load_addr_aligned, drom_addr_aligned, 64, drom_page_count); #elif CONFIG_IDF_TARGET_ESP32S2 - rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count, 0); + rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr_aligned, drom_addr_aligned, 64, drom_page_count, 0); #else // map rodata with DBUS - rc = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count, 0); + rc = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr_aligned, drom_addr_aligned, 64, drom_page_count, 0); #endif ESP_LOGV(TAG, "rc=%d", rc); #if CONFIG_IDF_TARGET_ESP32 - rc = cache_flash_mmu_set(1, 0, drom_load_addr_aligned, drom_addr & MMU_FLASH_MASK, 64, drom_page_count); + rc = cache_flash_mmu_set(1, 0, drom_load_addr_aligned, drom_addr_aligned, 64, drom_page_count); ESP_LOGV(TAG, "rc=%d", rc); #endif uint32_t irom_load_addr_aligned = irom_load_addr & MMU_FLASH_MASK; + uint32_t irom_addr_aligned = irom_addr & MMU_FLASH_MASK; uint32_t irom_page_count = bootloader_cache_pages_to_map(irom_size, irom_load_addr); ESP_LOGV(TAG, "i mmu set paddr=%08x vaddr=%08x size=%d n=%d", - irom_addr & MMU_FLASH_MASK, irom_load_addr_aligned, irom_size, irom_page_count); + irom_addr_aligned, irom_load_addr_aligned, irom_size, irom_page_count); #if CONFIG_IDF_TARGET_ESP32 - rc = cache_flash_mmu_set(0, 0, irom_load_addr_aligned, irom_addr & MMU_FLASH_MASK, 64, irom_page_count); + rc = cache_flash_mmu_set(0, 0, irom_load_addr_aligned, irom_addr_aligned, 64, irom_page_count); #else // access text with IBUS #if CONFIG_IDF_TARGET_ESP32S2 uint32_t iram1_used = 0; @@ -781,11 +783,11 @@ static void set_cache_and_start_app( REG_CLR_BIT(EXTMEM_PRO_ICACHE_CTRL1_REG, EXTMEM_PRO_ICACHE_MASK_IRAM1); } #endif - rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count, 0); + rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, irom_load_addr_aligned, irom_addr_aligned, 64, irom_page_count, 0); #endif ESP_LOGV(TAG, "rc=%d", rc); #if CONFIG_IDF_TARGET_ESP32 - rc = cache_flash_mmu_set(1, 0, irom_load_addr_aligned, irom_addr & MMU_FLASH_MASK, 64, irom_page_count); + rc = cache_flash_mmu_set(1, 0, irom_load_addr_aligned, irom_addr_aligned, 64, irom_page_count); ESP_LOGV(TAG, "rc=%d", rc); DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG, (DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) | From c6391f12dbaa9bc930a5b8c923ad4f423efa91d6 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Tue, 23 Nov 2021 16:12:05 -0300 Subject: [PATCH 2/2] bootloader_support: Fix unused-but-set-variable compiler warning When building with BOOTLOADER_LOG_LEVEL lesser then VERBOSE, an error code variable was being set but not consumed, resulting in a compiler warning. Signed-off-by: Gustavo Henrique Nihei --- components/bootloader_support/src/bootloader_utility.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/bootloader_utility.c b/components/bootloader_support/src/bootloader_utility.c index 5265b25510..b3bfa0fb97 100644 --- a/components/bootloader_support/src/bootloader_utility.c +++ b/components/bootloader_support/src/bootloader_utility.c @@ -722,7 +722,8 @@ static void set_cache_and_start_app( uint32_t irom_size, uint32_t entry_addr) { - int rc; + int rc __attribute__((unused)); + ESP_LOGD(TAG, "configure drom and irom and start"); #if CONFIG_IDF_TARGET_ESP32 Cache_Read_Disable(0);