From b28629822b001a76d2d2dd3747774dad394a6590 Mon Sep 17 00:00:00 2001 From: Maja Piechotka Date: Sat, 6 Jan 2024 15:21:24 -0800 Subject: [PATCH] boot: Take maximum of READ_SIZE and WRITE_SIZE when checking sizes, fixes #2382 --- embassy-boot/boot/src/firmware_updater/asynch.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-boot/boot/src/firmware_updater/asynch.rs b/embassy-boot/boot/src/firmware_updater/asynch.rs index 64a4b32ec..2e43e1cc1 100644 --- a/embassy-boot/boot/src/firmware_updater/asynch.rs +++ b/embassy-boot/boot/src/firmware_updater/asynch.rs @@ -224,10 +224,10 @@ impl<'d, STATE: NorFlash> FirmwareState<'d, STATE> { /// /// # Safety /// - /// The `aligned` buffer must have a size of STATE::WRITE_SIZE, and follow the alignment rules for the flash being read from - /// and written to. + /// The `aligned` buffer must have a size of maximum of STATE::WRITE_SIZE and STATE::READ_SIZE, + /// and follow the alignment rules for the flash being read from and written to. pub fn new(state: STATE, aligned: &'d mut [u8]) -> Self { - assert_eq!(aligned.len(), STATE::WRITE_SIZE); + assert_eq!(aligned.len(), STATE::WRITE_SIZE.max(STATE::READ_SIZE)); Self { state, aligned } }