From 58ebdb7ae3255a37f2d95bbceca7abbc99ced08b Mon Sep 17 00:00:00 2001 From: Armando Date: Tue, 21 May 2024 16:45:58 +0800 Subject: [PATCH] change(image): move image_process driver from bootloader_support to esp_system --- components/bootloader_support/CMakeLists.txt | 9 ++------- components/bootloader_support/linker.lf | 5 ----- components/esp_system/linker.lf | 3 +++ components/esp_system/port/CMakeLists.txt | 4 ++++ .../src => esp_system/port}/image_process.c | 11 +++++++++++ .../port/include/private}/esp_private/image_process.h | 0 6 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 components/bootloader_support/linker.lf rename components/{bootloader_support/src => esp_system/port}/image_process.c (96%) rename components/{bootloader_support/include => esp_system/port/include/private}/esp_private/image_process.h (100%) diff --git a/components/bootloader_support/CMakeLists.txt b/components/bootloader_support/CMakeLists.txt index 8d70b1f8c6..fbe9adf5fd 100644 --- a/components/bootloader_support/CMakeLists.txt +++ b/components/bootloader_support/CMakeLists.txt @@ -28,10 +28,6 @@ if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) ) endif() -if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP AND NOT BOOTLOADER_BUILD) - list(APPEND srcs "src/image_process.c") -endif() - if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT) list(APPEND srcs "src/bootloader_utility.c" @@ -64,7 +60,7 @@ else() set(include_dirs "include" "bootloader_flash/include") set(priv_include_dirs "private_include") # heap is required for `heap_memory_layout.h` header - set(priv_requires spi_flash mbedtls efuse heap esp_bootloader_format esp_app_format esp_mm) + set(priv_requires spi_flash mbedtls efuse heap esp_bootloader_format esp_app_format) endif() if(BOOTLOADER_BUILD) @@ -116,8 +112,7 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" REQUIRES "${requires}" - PRIV_REQUIRES "${priv_requires}" - LDFRAGMENTS linker.lf) + PRIV_REQUIRES "${priv_requires}") if(NOT BOOTLOADER_BUILD) if(CONFIG_SECURE_SIGNED_ON_UPDATE) diff --git a/components/bootloader_support/linker.lf b/components/bootloader_support/linker.lf deleted file mode 100644 index d2cf44a6e0..0000000000 --- a/components/bootloader_support/linker.lf +++ /dev/null @@ -1,5 +0,0 @@ -[mapping:bootloader_support] -archive: libbootloader_support.a -entries: - if APP_BUILD_TYPE_RAM = n: - image_process (noflash) diff --git a/components/esp_system/linker.lf b/components/esp_system/linker.lf index f3eac77bc0..666714c495 100644 --- a/components/esp_system/linker.lf +++ b/components/esp_system/linker.lf @@ -30,6 +30,9 @@ entries: usb_console:esp_usb_console_before_restart (noflash) usb_console:esp_usb_console_on_restart_timeout (noflash) + if APP_BUILD_TYPE_RAM = n: + image_process (noflash) + [mapping:vfs_cdcacm] archive: libvfs.a entries: diff --git a/components/esp_system/port/CMakeLists.txt b/components/esp_system/port/CMakeLists.txt index 7f6861b512..05a476f8cf 100644 --- a/components/esp_system/port/CMakeLists.txt +++ b/components/esp_system/port/CMakeLists.txt @@ -8,6 +8,10 @@ target_include_directories(${COMPONENT_LIB} PRIVATE ${INCLUDE_FILES} include/pri set(srcs "cpu_start.c" "panic_handler.c" "esp_system_chip.c") +if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) + list(APPEND srcs "image_process.c") +endif() + if(CONFIG_SOC_BOD_SUPPORTED) list(APPEND srcs "brownout.c") endif() diff --git a/components/bootloader_support/src/image_process.c b/components/esp_system/port/image_process.c similarity index 96% rename from components/bootloader_support/src/image_process.c rename to components/esp_system/port/image_process.c index 4c0100e474..d4ff4ed8d0 100644 --- a/components/bootloader_support/src/image_process.c +++ b/components/esp_system/port/image_process.c @@ -23,6 +23,11 @@ #include "esp_private/image_process.h" #include "esp_private/esp_cache_esp32_private.h" +/** + * ESP32 bootloader size is not enough, not enable this feature for now + */ +#define IMAGE_PROCESS_SUPPORTED_TARGETS (!CONFIG_IDF_TARGET_ESP32) + #if CONFIG_IDF_TARGET_ESP32 #define MMAP_MMU_SIZE 0x320000 #elif CONFIG_IDF_TARGET_ESP32S2 @@ -94,6 +99,7 @@ static esp_err_t flash_read(size_t src_addr, void *dest, size_t size) return ESP_OK; } +#if IMAGE_PROCESS_SUPPORTED_TARGETS static esp_err_t process_image_header(esp_image_metadata_t *data, uint32_t part_offset) { bzero(data, sizeof(esp_image_metadata_t)); @@ -105,6 +111,7 @@ static esp_err_t process_image_header(esp_image_metadata_t *data, uint32_t part_ return ESP_OK; } +#endif static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, esp_image_metadata_t *metadata, int *cnt) { @@ -189,6 +196,7 @@ void image_process_get_flash_segments_info(uint32_t *out_drom_paddr_start, uint3 esp_err_t image_process(void) { +#if IMAGE_PROCESS_SUPPORTED_TARGETS esp_err_t ret = ESP_FAIL; /** * We use the MMU_LL_END_DROM_ENTRY_ID mmu entry as a map page for app to find the boot partition @@ -210,6 +218,9 @@ esp_err_t image_process(void) } mmu_ll_set_entry_invalid(0, MMU_LL_END_DROM_ENTRY_ID); +#else + (void)s_image_process_driver; +#endif return ESP_OK; } diff --git a/components/bootloader_support/include/esp_private/image_process.h b/components/esp_system/port/include/private/esp_private/image_process.h similarity index 100% rename from components/bootloader_support/include/esp_private/image_process.h rename to components/esp_system/port/include/private/esp_private/image_process.h