If there is no more active slot found in find_active_slot(), like when
all slots in BOOT_ORDER have a count of 0, the counters are reset to their
default value CONFIG_BOOTMETH_RAUC_DEFAULT_TRIES. The BOOT_ORDER is _not_
changed, which is logically correct (especially for the case when there is
only one (active) slot set, e.g. BOOT_ORDER only contains 'B', probably due
to RAUC option prevent-late-fallback being set). Resetting the counters of
inactive slots also does not harm here, and is fine as a generic solution.

But the log_info statement in this scenario
  INFO: Resetting boot order and all slot tries
is incorrect. Change this to
  INFO: Resetting all slot tries to 3
with the 3 being inserted by CONFIG_BOOTMETH_RAUC_DEFAULT_TRIES.

Signed-off-by: Andreas Pretzsch <[email protected]>
Reviewed-by: Martin Schwan <[email protected]>
---
Changes for v2:
  - add Reviewed-by of Martin Schwan

 boot/bootmeth_rauc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/boot/bootmeth_rauc.c b/boot/bootmeth_rauc.c
index 81a73046e83..f5d5a971e87 100644
--- a/boot/bootmeth_rauc.c
+++ b/boot/bootmeth_rauc.c
@@ -18,6 +18,7 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <string.h>
+#include <linux/stringify.h>
 #include <asm/cache.h>
 
 /* Length of env var "BOOT_*_LEFT" */
@@ -304,7 +305,7 @@ static int find_active_slot(char **slot_name, ulong 
*slot_tries)
        if (!slot_found) {
                if (IS_ENABLED(CONFIG_BOOTMETH_RAUC_RESET_ALL_ZERO_TRIES)) {
                        log_warning("WARNING: No valid slot found\n");
-                       log_info("INFO: Resetting boot order and all slot 
tries\n");
+                       log_info("INFO: Resetting all slot tries to " 
__stringify(CONFIG_BOOTMETH_RAUC_DEFAULT_TRIES) "\n");
                        boot_order_list = 
str_to_list(CONFIG_BOOTMETH_RAUC_BOOT_ORDER);
                        for (i = 0; boot_order_list[i]; i++) {
                                sprintf(boot_left, "BOOT_%s_LEFT", 
boot_order_list[i]);
-- 
2.43.0

Reply via email to