From a4a1da69ac1d176d591782937681b745c9fd614a Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Wed, 31 Jan 2024 14:47:05 +0100 Subject: [PATCH 1/2] Re-calculate the bootloader's SHA256 --- espflash/src/image_format/idf_bootloader.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/espflash/src/image_format/idf_bootloader.rs b/espflash/src/image_format/idf_bootloader.rs index 4d671844..3f654f54 100644 --- a/espflash/src/image_format/idf_bootloader.rs +++ b/espflash/src/image_format/idf_bootloader.rs @@ -73,6 +73,13 @@ impl<'a> IdfBootloaderFormat<'a> { bytes_of(&header).iter().copied(), ); + // re-calculate hash of the bootloader - needed since we modified the header + let bootloader_len = bootloader.len(); + let mut hasher = Sha256::new(); + hasher.update(&bootloader[..bootloader_len - 32]); + let hash = hasher.finalize(); + bootloader.to_mut()[bootloader_len - 32..].copy_from_slice(&hash); + // write the header of the app // use the same settings as the bootloader // just update the entry point From c0bbbd40504325d013bc9a7944660bb10a9a18a2 Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Wed, 31 Jan 2024 14:50:04 +0100 Subject: [PATCH 2/2] CHANGELOG.md entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a97ef2e..ccdb5dbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed `defmt` parsing when data is read in parts (#503) - Use partition table instead of hard-coded values for the location of partitions (#516) - Fixed a missed `flush` call that may be causing communication errors (#521) +- Fix "SHA-256 comparison failed: [...] attempting to boot anyway..." (#567) ### Changed - Created `FlashData`, `FlashDataBuilder` and `FlashSettings` structs to reduce number of input arguments in some functions (#512, #566)