mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
Merge branch 'feature/remove_unnecessary_macro_define' into 'master'
app_update: remove unnecessary macro define See merge request sdk/ESP8266_RTOS_SDK!956
This commit is contained in:
@ -15,11 +15,3 @@ if(${OTADATA_PARTITION_OFFSET})
|
|||||||
add_custom_target(blank_ota_data ALL DEPENDS "${PROJECT_BINARY_DIR}/${BLANK_OTADATA_FILE}")
|
add_custom_target(blank_ota_data ALL DEPENDS "${PROJECT_BINARY_DIR}/${BLANK_OTADATA_FILE}")
|
||||||
add_dependencies(flash blank_ota_data)
|
add_dependencies(flash blank_ota_data)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_APP_UPDATE_CHECK_APP_SUM)
|
|
||||||
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SUM=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
|
||||||
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SHA256=1)
|
|
||||||
endif()
|
|
||||||
|
@ -2,14 +2,6 @@
|
|||||||
#
|
#
|
||||||
.PHONY: dump_otadata erase_ota blank_ota_data
|
.PHONY: dump_otadata erase_ota blank_ota_data
|
||||||
|
|
||||||
ifdef CONFIG_APP_UPDATE_CHECK_APP_SUM
|
|
||||||
CFLAGS += -DCONFIG_ENABLE_BOOT_CHECK_SUM=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
|
||||||
CFLAGS += -DCONFIG_ENABLE_BOOT_CHECK_SHA256=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
GEN_EMPTY_PART := $(PYTHON) $(COMPONENT_PATH)/gen_empty_partition.py
|
GEN_EMPTY_PART := $(PYTHON) $(COMPONENT_PATH)/gen_empty_partition.py
|
||||||
BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin
|
BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin
|
||||||
|
|
||||||
|
@ -12,11 +12,3 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
|
||||||
if(CONFIG_APP_UPDATE_CHECK_APP_SUM)
|
|
||||||
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SUM=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
|
||||||
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SHA256=1)
|
|
||||||
endif()
|
|
||||||
|
@ -360,7 +360,7 @@ static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, ui
|
|||||||
dest[w_i] = w ^ ((w_i & 1) ? ram_obfs_value[0] : ram_obfs_value[1]);
|
dest[w_i] = w ^ ((w_i & 1) ? ram_obfs_value[0] : ram_obfs_value[1]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_SHA256
|
#ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
||||||
// SHA_CHUNK determined experimentally as the optimum size
|
// SHA_CHUNK determined experimentally as the optimum size
|
||||||
// to call bootloader_sha256_data() with. This is a bit
|
// to call bootloader_sha256_data() with. This is a bit
|
||||||
// counter-intuitive, but it's ~3ms better than using the
|
// counter-intuitive, but it's ~3ms better than using the
|
||||||
@ -652,7 +652,7 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
|
|||||||
#if defined(CONFIG_SECURE_BOOT_ENABLED)
|
#if defined(CONFIG_SECURE_BOOT_ENABLED)
|
||||||
static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
|
static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
static esp_err_t __attribute__((unused)) verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
|
static esp_err_t __attribute__((unused)) verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *
|
|||||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||||
if (1) {
|
if (1) {
|
||||||
#else
|
#else
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_SHA256
|
#ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||||
if (data->image.hash_appended)
|
if (data->image.hash_appended)
|
||||||
#endif
|
#endif
|
||||||
@ -769,7 +769,7 @@ goto err;
|
|||||||
// secure boot images have a signature appended
|
// secure boot images have a signature appended
|
||||||
err = verify_secure_boot_signature(sha_handle, data);
|
err = verify_secure_boot_signature(sha_handle, data);
|
||||||
#else
|
#else
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_SHA256
|
#ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
||||||
// No secure boot, but SHA-256 can be appended for basic corruption detection
|
// No secure boot, but SHA-256 can be appended for basic corruption detection
|
||||||
if (sha_handle != NULL
|
if (sha_handle != NULL
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_OCD
|
#ifdef CONFIG_ENABLE_BOOT_CHECK_OCD
|
||||||
@ -812,7 +812,7 @@ goto err;
|
|||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
err = ESP_ERR_IMAGE_INVALID;
|
err = ESP_ERR_IMAGE_INVALID;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_SHA256
|
#ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
||||||
if (sha_handle != NULL) {
|
if (sha_handle != NULL) {
|
||||||
// Need to finish the hash process to free the handle
|
// Need to finish the hash process to free the handle
|
||||||
bootloader_sha256_finish(sha_handle, NULL);
|
bootloader_sha256_finish(sha_handle, NULL);
|
||||||
@ -858,7 +858,7 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
|||||||
ESP_LOGE(TAG, "bootloader_flash_read failed at 0x%08x", flash_addr);
|
ESP_LOGE(TAG, "bootloader_flash_read failed at 0x%08x", flash_addr);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_SHA256
|
#ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
||||||
if (sha_handle != NULL) {
|
if (sha_handle != NULL) {
|
||||||
bootloader_sha256_data(sha_handle, header, sizeof(esp_image_segment_header_t));
|
bootloader_sha256_data(sha_handle, header, sizeof(esp_image_segment_header_t));
|
||||||
}
|
}
|
||||||
@ -934,7 +934,7 @@ err:
|
|||||||
static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
|
static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SUM) || defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_SUM) || defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
const char *src = (const char *)data_addr;
|
const char *src = (const char *)data_addr;
|
||||||
#ifndef BOOTLOADER_BUILD
|
#ifndef BOOTLOADER_BUILD
|
||||||
uint32_t *pbuf;
|
uint32_t *pbuf;
|
||||||
@ -961,12 +961,12 @@ static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, ui
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SUM)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_SUM)
|
||||||
for (int i = 0; i < bytes / sizeof(uint32_t); i++)
|
for (int i = 0; i < bytes / sizeof(uint32_t); i++)
|
||||||
*checksum ^= pbuf[i];
|
*checksum ^= pbuf[i];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
if (sha_handle != NULL)
|
if (sha_handle != NULL)
|
||||||
bootloader_sha256_data(sha_handle, pbuf, bytes);
|
bootloader_sha256_data(sha_handle, pbuf, bytes);
|
||||||
#endif
|
#endif
|
||||||
@ -1043,7 +1043,7 @@ esp_err_t esp_image_verify_bootloader(uint32_t *length)
|
|||||||
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data)
|
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data)
|
||||||
{
|
{
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SUM) || defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_SUM) || defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
uint32_t unpadded_length = data->image_len;
|
uint32_t unpadded_length = data->image_len;
|
||||||
uint32_t length = unpadded_length + 1; // Add a byte for the checksum
|
uint32_t length = unpadded_length + 1; // Add a byte for the checksum
|
||||||
length = (length + 15) & ~15; // Pad to next full 16 byte block
|
length = (length + 15) & ~15; // Pad to next full 16 byte block
|
||||||
@ -1056,7 +1056,7 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
|
|||||||
return ESP_ERR_IMAGE_INVALID;
|
return ESP_ERR_IMAGE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SUM)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_SUM)
|
||||||
uint8_t calc = buf[length - unpadded_length - 1];
|
uint8_t calc = buf[length - unpadded_length - 1];
|
||||||
uint8_t checksum = (checksum_word >> 24)
|
uint8_t checksum = (checksum_word >> 24)
|
||||||
^ (checksum_word >> 16)
|
^ (checksum_word >> 16)
|
||||||
@ -1069,7 +1069,7 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ENABLE_BOOT_CHECK_SHA256
|
#ifdef CONFIG_APP_UPDATE_CHECK_APP_HASH
|
||||||
if (sha_handle != NULL) {
|
if (sha_handle != NULL) {
|
||||||
bootloader_sha256_data(sha_handle, buf, length - unpadded_length);
|
bootloader_sha256_data(sha_handle, buf, length - unpadded_length);
|
||||||
}
|
}
|
||||||
@ -1089,7 +1089,7 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
static void debug_log_hash(const uint8_t *image_hash, const char *caption);
|
static void debug_log_hash(const uint8_t *image_hash, const char *caption);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1141,7 +1141,7 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
static esp_err_t verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data)
|
static esp_err_t verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data)
|
||||||
{
|
{
|
||||||
uint8_t image_hash[HASH_LEN];
|
uint8_t image_hash[HASH_LEN];
|
||||||
@ -1169,7 +1169,7 @@ static esp_err_t verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_i
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_ENABLE_BOOT_CHECK_SHA256)
|
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_APP_UPDATE_CHECK_APP_HASH)
|
||||||
|
|
||||||
// Log a hash as a hex string
|
// Log a hash as a hex string
|
||||||
static void debug_log_hash(const uint8_t *image_hash, const char *label)
|
static void debug_log_hash(const uint8_t *image_hash, const char *label)
|
||||||
|
Reference in New Issue
Block a user