Merge branch 'feat/optimize_bootloader_size' into 'master'

change(bootloader): optimize bootloader size

See merge request espressif/esp-idf!51573
This commit is contained in:
Marius Vikhammer
2026-08-06 22:06:38 +08:00
6 changed files with 11 additions and 18 deletions

View File

@@ -64,7 +64,7 @@ esp_err_t bootloader_check_bootloader_validity(void)
unsigned int efuse_revision = efuse_hal_blk_version();
unsigned int efuse_major_rev = efuse_revision / 100;
unsigned int efuse_minor_rev = efuse_revision % 100;
ESP_EARLY_LOGI(TAG, "efuse block revision: v%d.%d", efuse_major_rev, efuse_minor_rev);
ESP_EARLY_LOGD(TAG, "efuse block revision: v%d.%d", efuse_major_rev, efuse_minor_rev);
#endif // !CONFIG_IDF_TARGET_ESP32
/* compare with the one set in bootloader image header */
if (bootloader_common_check_chip_validity(&bootloader_image_hdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
@@ -113,7 +113,7 @@ void bootloader_config_wdt(void)
void bootloader_enable_random(void)
{
ESP_EARLY_LOGI(TAG, "Enabling RNG early entropy source...");
ESP_EARLY_LOGD(TAG, "Enabling RNG early entropy source...");
bootloader_random_enable();
}
@@ -134,7 +134,7 @@ void bootloader_print_banner(void)
ESP_EARLY_LOGW(TAG, "Unicore bootloader");
#endif
#else
ESP_EARLY_LOGI(TAG, "Multicore bootloader");
ESP_EARLY_LOGD(TAG, "Multicore bootloader");
#endif
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -28,14 +28,11 @@ bootloader_sha256_handle_t bootloader_sha256_start()
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len)
{
assert(handle != NULL);
ets_sha_update(&ctx, data, data_len, false);
}
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
{
assert(handle != NULL);
if (digest == NULL) {
bzero(&ctx, sizeof(ctx));
return;
@@ -54,14 +51,11 @@ bootloader_sha_handle_t bootloader_sha512_start(bool is384)
void bootloader_sha512_data(bootloader_sha_handle_t handle, const void *data, size_t data_len)
{
assert(handle != NULL);
ets_sha_update(&ctx, data, data_len, false);
}
void bootloader_sha512_finish(bootloader_sha_handle_t handle, uint8_t *digest)
{
assert(handle != NULL);
if (digest == NULL) {
bzero(&ctx, sizeof(ctx));
return;
@@ -91,7 +85,6 @@ bootloader_sha256_handle_t bootloader_sha256_start(void)
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len)
{
assert(handle != NULL);
assert(data_len % 4 == 0);
const uint32_t *w = (const uint32_t *)data;

View File

@@ -266,7 +266,6 @@ bool bootloader_utility_load_partition_table(bootloader_state_t *bs)
bootloader_munmap(partitions);
ESP_LOGI(TAG, "End of partition table");
return true;
}
@@ -786,7 +785,7 @@ static void load_image(const esp_image_metadata_t *image_data)
}
#endif
ESP_LOGI(TAG, "Disabling RNG early entropy source...");
ESP_LOGD(TAG, "Disabling RNG early entropy source...");
bootloader_random_disable();
/* Disable glitch reset after all the security checks are completed.

View File

@@ -131,15 +131,15 @@ uint32_t esp_image_bootloader_offset_get(void)
void esp_image_bootloader_offset_set(const uint32_t offset)
{
s_bootloader_partition_offset = offset;
ESP_LOGI(TAG, "Bootloader offsets for PRIMARY: 0x%x, Secondary: 0x%" PRIx32, ESP_PRIMARY_BOOTLOADER_OFFSET, s_bootloader_partition_offset);
ESP_LOGD(TAG, "Bootloader offsets for PRIMARY: 0x%x, Secondary: 0x%" PRIx32, ESP_PRIMARY_BOOTLOADER_OFFSET, s_bootloader_partition_offset);
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
uint32_t recovery_offset = efuse_hal_get_recovery_bootloader_address();
if (efuse_hal_recovery_bootloader_enabled()) {
ESP_LOGI(TAG, "Bootloader offset for RECOVERY: 0x%" PRIx32, recovery_offset);
ESP_LOGD(TAG, "Bootloader offset for RECOVERY: 0x%" PRIx32, recovery_offset);
} else if (recovery_offset == 0) {
ESP_LOGI(TAG, "Bootloader offset for RECOVERY: has not been set yet");
ESP_LOGD(TAG, "Bootloader offset for RECOVERY: has not been set yet");
} else {
ESP_LOGI(TAG, "Bootloader offset for RECOVERY: is disabled");
ESP_LOGD(TAG, "Bootloader offset for RECOVERY: is disabled");
}
#endif
}