diff --git a/components/esp_app_format/esp_app_desc.c b/components/esp_app_format/esp_app_desc.c index e7fe7e6ca02a..075e6f426576 100644 --- a/components/esp_app_format/esp_app_desc.c +++ b/components/esp_app_format/esp_app_desc.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,6 +10,12 @@ #include "esp_app_desc.h" #include "sdkconfig.h" +#include "hal/efuse_hal.h" +#include "esp_log.h" +#include "esp_private/startup_internal.h" + +static const char *TAG = "app_init"; + // Application version info const __attribute__((weak)) __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = { .magic_word = ESP_APP_DESC_MAGIC_WORD, @@ -62,7 +68,7 @@ char app_elf_sha256_str[CONFIG_APP_RETRIEVE_LEN_ELF_SHA + 1] = { 0 }; * For this reason we do a reading of esp_app_desc.app_elf_sha256 and convert to string while start up in esp_system_init_app_elf_sha256() * and keep it in the static app_elf_sha256_str variable. */ -__attribute__((constructor)) void esp_app_format_init_elf_sha256(void) +static void esp_app_format_init_elf_sha256(void) { if (*((int *)&app_elf_sha256_str) != 0) { // app_elf_sha256_str is already set @@ -94,3 +100,38 @@ int esp_app_get_elf_sha256(char* dst, size_t size) dst[n - 1] = 0; return n; } + +ESP_SYSTEM_INIT_FN(init_show_app_info, CORE, BIT(0), 20) +{ + // Load the current ELF SHA256 + esp_app_format_init_elf_sha256(); + + // Display information about the current running image. + if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { + ESP_EARLY_LOGI(TAG, "Application information:"); +#ifndef CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR + ESP_EARLY_LOGI(TAG, "Project name: %s", esp_app_desc.project_name); +#endif +#ifndef CONFIG_APP_EXCLUDE_PROJECT_VER_VAR + ESP_EARLY_LOGI(TAG, "App version: %s", esp_app_desc.version); +#endif +#ifdef CONFIG_BOOTLOADER_APP_SECURE_VERSION + ESP_EARLY_LOGI(TAG, "Secure version: %d", esp_app_desc.secure_version); +#endif +#ifdef CONFIG_APP_COMPILE_TIME_DATE + ESP_EARLY_LOGI(TAG, "Compile time: %s %s", esp_app_desc.date, esp_app_desc.time); +#endif + char buf[17]; + esp_app_get_elf_sha256(buf, sizeof(buf)); + ESP_EARLY_LOGI(TAG, "ELF file SHA256: %s...", buf); + ESP_EARLY_LOGI(TAG, "ESP-IDF: %s", esp_app_desc.idf_ver); + + // TODO: To be moved to the eFuse initialization routine + ESP_EARLY_LOGI(TAG, "Min chip rev: v%d.%d", CONFIG_ESP_REV_MIN_FULL / 100, CONFIG_ESP_REV_MIN_FULL % 100); + ESP_EARLY_LOGI(TAG, "Max chip rev: v%d.%d %s", CONFIG_ESP_REV_MAX_FULL / 100, CONFIG_ESP_REV_MAX_FULL % 100, + efuse_hal_get_disable_wafer_version_major() ? "(constraint ignored)" : ""); + unsigned revision = efuse_hal_chip_revision(); + ESP_EARLY_LOGI(TAG, "Chip rev: v%d.%d", revision / 100, revision % 100); + } + return ESP_OK; +} diff --git a/components/esp_system/startup_funcs.c b/components/esp_system/startup_funcs.c index 7c5e909f28b4..0fcf3c60e5d4 100644 --- a/components/esp_system/startup_funcs.c +++ b/components/esp_system/startup_funcs.c @@ -37,7 +37,6 @@ #endif #if __has_include("esp_app_desc.h") -#define WITH_APP_IMAGE_INFO #include "esp_app_desc.h" #endif @@ -77,40 +76,6 @@ ESP_SYSTEM_INIT_FN(init_show_cpu_freq, CORE, BIT(0), 10) return ESP_OK; } -#ifdef WITH_APP_IMAGE_INFO -ESP_SYSTEM_INIT_FN(init_show_app_info, CORE, BIT(0), 20) -{ - // Display information about the current running image. - if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { - const esp_app_desc_t *app_desc = esp_app_get_description(); - ESP_EARLY_LOGI(TAG, "Application information:"); -#ifndef CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR - ESP_EARLY_LOGI(TAG, "Project name: %s", app_desc->project_name); -#endif -#ifndef CONFIG_APP_EXCLUDE_PROJECT_VER_VAR - ESP_EARLY_LOGI(TAG, "App version: %s", app_desc->version); -#endif -#ifdef CONFIG_BOOTLOADER_APP_SECURE_VERSION - ESP_EARLY_LOGI(TAG, "Secure version: %d", app_desc->secure_version); -#endif -#ifdef CONFIG_APP_COMPILE_TIME_DATE - ESP_EARLY_LOGI(TAG, "Compile time: %s %s", app_desc->date, app_desc->time); -#endif - char buf[17]; - esp_app_get_elf_sha256(buf, sizeof(buf)); - ESP_EARLY_LOGI(TAG, "ELF file SHA256: %s...", buf); - ESP_EARLY_LOGI(TAG, "ESP-IDF: %s", app_desc->idf_ver); - - ESP_EARLY_LOGI(TAG, "Min chip rev: v%d.%d", CONFIG_ESP_REV_MIN_FULL / 100, CONFIG_ESP_REV_MIN_FULL % 100); - ESP_EARLY_LOGI(TAG, "Max chip rev: v%d.%d %s", CONFIG_ESP_REV_MAX_FULL / 100, CONFIG_ESP_REV_MAX_FULL % 100, - efuse_hal_get_disable_wafer_version_major() ? "(constraint ignored)" : ""); - unsigned revision = efuse_hal_chip_revision(); - ESP_EARLY_LOGI(TAG, "Chip rev: v%d.%d", revision / 100, revision % 100); - } - return ESP_OK; -} -#endif // WITH_APP_IMAGE_INFO - ESP_SYSTEM_INIT_FN(init_heap, CORE, BIT(0), 100) { heap_caps_init(); diff --git a/components/esp_system/system_init_fn.txt b/components/esp_system/system_init_fn.txt index b7fd750ab38f..03e511a19177 100644 --- a/components/esp_system/system_init_fn.txt +++ b/components/esp_system/system_init_fn.txt @@ -19,7 +19,7 @@ # Log some information about the system CORE: 10: init_show_cpu_freq in components/esp_system/startup_funcs.c on BIT(0) -CORE: 20: init_show_app_info in components/esp_system/startup_funcs.c on BIT(0) +CORE: 20: init_show_app_info in components/esp_app_format/esp_app_desc.c on BIT(0) # Initialize heap allocator. WARNING: This *needs* to happen *after* the app cpu has booted. # If the heap allocator is initialized first, it will put free memory linked list items into