Skip to content

Commit

Permalink
Re-calculate the bootloader's SHA256
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Jan 31, 2024
1 parent 31817fa commit a4a1da6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions espflash/src/image_format/idf_bootloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4a1da6

Please sign in to comment.