Merge branch 'bugfix/elf_sha256_first_byte_skip_v4.1' into 'release/v4.1'

app_update: fix incorrect first byte from esp_ota_get_app_elf_sha256 (v4.1)

See merge request espressif/esp-idf!13664
This commit is contained in:
Angus Gratton 2021-06-24 01:55:30 +00:00
commit 1e9367f48e

View File

@ -89,7 +89,10 @@ int IRAM_ATTR esp_ota_get_app_elf_sha256(char* dst, size_t size)
static bool first_call = true;
if (first_call) {
first_call = false;
const uint8_t* src = esp_app_desc.app_elf_sha256;
// At -O2 optimization level, GCC optimizes out the copying of the first byte of the app_elf_sha256,
// because it is zero at compile time, and only modified afterwards by esptool.
// Casting to volatile disables the optimization.
const volatile uint8_t* src = (const volatile uint8_t*)esp_app_desc.app_elf_sha256;
for (size_t i = 0; i < sizeof(s_app_elf_sha256); ++i) {
s_app_elf_sha256[i] = src[i];
}