From 9f73145ca314ae1310c1e539e5e9e3dfb2c67f18 Mon Sep 17 00:00:00 2001 From: Ofir Shemesh Date: Thu, 22 May 2025 19:51:13 +0300 Subject: [PATCH] boot: bootutil: avoid full erase on BOOT_MAGIC_BAD in boot_set_next Previously, boot_set_next() would perform a full slot erase when BOOT_MAGIC_BAD was detected. This is no longer done, as the decision on how to handle a corrupted image should be left to user code. Signed-off-by: Ofir Shemesh --- boot/bootutil/src/bootutil_public.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/boot/bootutil/src/bootutil_public.c b/boot/bootutil/src/bootutil_public.c index 1021188644..1c3a347e25 100644 --- a/boot/bootutil/src/bootutil_public.c +++ b/boot/bootutil/src/bootutil_public.c @@ -573,10 +573,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm) if (active) { rc = BOOT_EBADVECT; } else { - /* The image slot is corrupt. There is no way to recover, so erase the - * slot to allow future upgrades. - */ - flash_area_erase(fa, 0, flash_area_get_size(fa)); + /* This image will not be boot next time anyway */ rc = BOOT_EBADIMAGE; } break;