From 5915d4090467902ea9dff6c4e4def1b533ffa7fa Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Mon, 6 Jul 2020 14:04:15 +0200 Subject: [PATCH] Fix logic in emergency update --- src/update_flash.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/update_flash.c b/src/update_flash.c index f7e582d7..90811fd0 100644 --- a/src/update_flash.c +++ b/src/update_flash.c @@ -266,8 +266,18 @@ void RAMFUNCTION wolfBoot_start(void) (wolfBoot_verify_integrity(&boot) < 0) || (wolfBoot_verify_authenticity(&boot) < 0)) { if (wolfBoot_update(1) < 0) { + /* panic: no boot option available. */ while(1) - /* panic */; + ; + } else { + /* Emergency update successful, try to re-open boot image */ + if ((wolfBoot_open_image(&boot, PART_BOOT) < 0) || + (wolfBoot_verify_integrity(&boot) < 0) || + (wolfBoot_verify_authenticity(&boot) < 0)) { + /* panic: something went wrong after the emergency update */ + while(1) + ; + } } } hal_prepare_boot();