Merge branch 'docs/update_bootloader_chip_revision_print' into 'master'
bootloader_support: fix logging prints around chip revision See merge request espressif/esp-idf!6324
This commit is contained in:
commit
c1ccfde6dd
4 changed files with 14 additions and 8 deletions
|
@ -28,6 +28,11 @@ typedef enum {
|
||||||
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
|
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
|
||||||
} esp_comm_gpio_hold_t;
|
} esp_comm_gpio_hold_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ESP_IMAGE_BOOTLOADER,
|
||||||
|
ESP_IMAGE_APPLICATION
|
||||||
|
} esp_image_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculate crc for the OTA data select.
|
* @brief Calculate crc for the OTA data select.
|
||||||
*
|
*
|
||||||
|
@ -152,12 +157,13 @@ uint8_t bootloader_common_get_chip_revision(void);
|
||||||
/**
|
/**
|
||||||
* @brief Check if the image (bootloader and application) has valid chip ID and revision
|
* @brief Check if the image (bootloader and application) has valid chip ID and revision
|
||||||
*
|
*
|
||||||
* @param img_hdr: image header
|
* @param[in] img_hdr: image header
|
||||||
|
* @param[in] type: image type, bootloader or application
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK: image and chip are matched well
|
* - ESP_OK: image and chip are matched well
|
||||||
* - ESP_FAIL: image doesn't match to the chip
|
* - ESP_FAIL: image doesn't match to the chip
|
||||||
*/
|
*/
|
||||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr);
|
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||||
|
|
|
@ -303,20 +303,20 @@ uint8_t bootloader_common_get_chip_revision(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr)
|
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type)
|
||||||
{
|
{
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
|
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
|
||||||
if (chip_id != img_hdr->chip_id) {
|
if (chip_id != img_hdr->chip_id) {
|
||||||
ESP_LOGE(TAG, "mismatch chip ID, expect %d, found %d", chip_id, img_hdr->chip_id);
|
ESP_LOGE(TAG, "mismatch chip ID, expected %d, found %d", chip_id, img_hdr->chip_id);
|
||||||
err = ESP_FAIL;
|
err = ESP_FAIL;
|
||||||
}
|
}
|
||||||
uint8_t revision = bootloader_common_get_chip_revision();
|
uint8_t revision = bootloader_common_get_chip_revision();
|
||||||
if (revision < img_hdr->min_chip_rev) {
|
if (revision < img_hdr->min_chip_rev) {
|
||||||
ESP_LOGE(TAG, "can't run on lower chip revision, expect %d, found %d", revision, img_hdr->min_chip_rev);
|
ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev);
|
||||||
err = ESP_FAIL;
|
err = ESP_FAIL;
|
||||||
} else if (revision != img_hdr->min_chip_rev) {
|
} else if (revision != img_hdr->min_chip_rev) {
|
||||||
ESP_LOGI(TAG, "mismatch chip revision, expect %d, found %d", revision, img_hdr->min_chip_rev);
|
ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ static esp_err_t bootloader_main(void)
|
||||||
/* Check chip ID and minimum chip revision that supported by this image */
|
/* Check chip ID and minimum chip revision that supported by this image */
|
||||||
uint8_t revision = bootloader_common_get_chip_revision();
|
uint8_t revision = bootloader_common_get_chip_revision();
|
||||||
ESP_LOGI(TAG, "Chip Revision: %d", revision);
|
ESP_LOGI(TAG, "Chip Revision: %d", revision);
|
||||||
if (bootloader_common_check_chip_validity(&fhdr) != ESP_OK) {
|
if (bootloader_common_check_chip_validity(&fhdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
|
||||||
}
|
}
|
||||||
err = ESP_ERR_IMAGE_INVALID;
|
err = ESP_ERR_IMAGE_INVALID;
|
||||||
}
|
}
|
||||||
if (bootloader_common_check_chip_validity(image) != ESP_OK) {
|
if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) {
|
||||||
err = ESP_ERR_IMAGE_INVALID;
|
err = ESP_ERR_IMAGE_INVALID;
|
||||||
}
|
}
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
|
|
Loading…
Reference in a new issue