From 53fd571ddb4774d103340e1442efa671a3564567 Mon Sep 17 00:00:00 2001 From: John Youren <29236922+JYouren@users.noreply.github.com> Date: Fri, 20 Jun 2025 14:45:13 +0100 Subject: [PATCH] Only write to the flash what was read from the file The write method is given the full aligned buffer to write to flash even though it may not be fully populated. This change ensures only what has been read is written to flash. Preventing potential corrupted firmware and additional flash wear. --- examples/boot/application/rp/src/bin/a.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs index ede0c07da..e6d7b3d4f 100644 --- a/examples/boot/application/rp/src/bin/a.rs +++ b/examples/boot/application/rp/src/bin/a.rs @@ -54,7 +54,7 @@ async fn main(_s: Spawner) { for chunk in APP_B.chunks(4096) { buf.0[..chunk.len()].copy_from_slice(chunk); defmt::info!("writing block at offset {}", offset); - writer.write(offset, &buf.0[..]).unwrap(); + writer.write(offset, &buf.0[..chunk.len()]).unwrap(); offset += chunk.len() as u32; } watchdog.feed();