From a5b4fda2078d30cce5a924278f1caa419cf5c9a0 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 2 Jun 2020 17:03:32 +1000 Subject: [PATCH 1/2] bootloader: Force bootloader_image_hdr to be word aligned Possible due to linker order for this file to be placed unaligned, causing failure from bootloader_flash_read() function. --- components/bootloader_support/src/bootloader_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index 9cf02b02b..2a1f1e484 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -14,6 +14,7 @@ #include #include #include "sdkconfig.h" +#include "esp_attr.h" #include "esp_log.h" #include "bootloader_init.h" #include "bootloader_flash.h" @@ -30,7 +31,7 @@ static const char *TAG = "boot"; -esp_image_header_t bootloader_image_hdr; +esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr; void bootloader_clear_bss_section(void) { From bd3caffdcde813b57cf8e5f120f17cc08dec5aa3 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 4 Mar 2020 09:21:37 +0100 Subject: [PATCH 2/2] bootloader_support: force alignment of flash_read argument --- components/bootloader_support/src/esp_image_format.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c index f3693e58b..37d23a41f 100644 --- a/components/bootloader_support/src/esp_image_format.c +++ b/components/bootloader_support/src/esp_image_format.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -722,7 +723,7 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t length = (length + 15) & ~15; // Pad to next full 16 byte block // Verify checksum - uint8_t buf[16]; + WORD_ALIGNED_ATTR uint8_t buf[16]; esp_err_t err = bootloader_flash_read(data->start_addr + unpadded_length, buf, length - unpadded_length, true); uint8_t calc = buf[length - unpadded_length - 1]; uint8_t checksum = (checksum_word >> 24)