From b2ed553bbf12abb20830c8734d08f8cf3b3d925f Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 28 Nov 2019 12:13:18 +1100 Subject: [PATCH] bootloader_support: Reduce log spam about chip revisions * Don't bother checking the chip revision if it looks like the partition doesn't really contain an app * Don't print the "info" level about the revision & min revision unless we're in the bootloader (otherwise it gets printed at random times during the OTA process) --- .../bootloader_support/src/bootloader_common.c | 4 +++- .../bootloader_support/src/esp_image_format.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index d3db882434..a87e301aea 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -293,7 +293,9 @@ esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hd ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev); err = ESP_FAIL; } else if (revision != img_hdr->min_chip_rev) { - ESP_LOGI(TAG, "min. %s chip revision: %d", type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev); +#ifdef BOOTLOADER_BUILD + ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev); +#endif } return err; } diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c index cfad3acf75..e44bb94abf 100644 --- a/components/bootloader_support/src/esp_image_format.c +++ b/components/bootloader_support/src/esp_image_format.c @@ -311,9 +311,6 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t } err = ESP_ERR_IMAGE_INVALID; } - if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) { - err = ESP_ERR_IMAGE_INVALID; - } if (!silent) { if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) { ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode); @@ -325,6 +322,16 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t ESP_LOGW(TAG, "image at 0x%x has invalid SPI size %d", src_addr, image->spi_size); } } + + if (err == ESP_OK) { + // Checking the chip revision header *will* print a bunch of other info + // regardless of silent setting as this may be important, but don't bother checking it + // if it looks like the app partition is erased or otherwise garbage + if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) { + err = ESP_ERR_IMAGE_INVALID; + } + } + return err; }