From c36acfeef9f698148d255ba986ac94242406d7a3 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Thu, 6 Apr 2017 00:06:16 +0200 Subject: [PATCH] Run recovery script only if 'recovery' variable exists This partially solves #131 --- u-boot/common/main.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/u-boot/common/main.c b/u-boot/common/main.c index 4a59988..9ca775d 100644 --- a/u-boot/common/main.c +++ b/u-boot/common/main.c @@ -162,25 +162,32 @@ void main_loop(void) gd->flags &= ~(GD_FLG_SILENT); #endif - /* - * Always clear values of variables used in recovery script - * as they could be accidentally saved before - */ - setenv("stop_boot", NULL); - setenv("cnt", NULL); + /* Do we have recovery script in env var at all? */ + c = getenv("recovery"); + if (c == NULL) { + puts("** Warning: recovery script is missing\n"); + puts(" in env, use 'defenv' to reset env\n\n"); + } else { + /* + * Always clear values of variables used in recovery + * script as they could be accidentally saved before + */ + setenv("stop_boot", NULL); + setenv("cnt", NULL); - run_command("run recovery", 0); + run_command("run recovery", 0); - /* Should we stop booting after recovery mode? */ - c = getenv("stop_boot"); - stop_boot = c ? (int)simple_strtol(c, NULL, 10) : 0; + /* Should we stop booting after recovery mode? */ + c = getenv("stop_boot"); + stop_boot = c ? (int)simple_strtol(c, NULL, 10) : 0; - if (stop_boot) { - setenv("stop_boot", NULL); - bootcmd = NULL; - } + if (stop_boot) { + setenv("stop_boot", NULL); + bootcmd = NULL; + } - setenv("cnt", NULL); + setenv("cnt", NULL); + } } #endif /* CONFIG_RECOVERY_MODE */ -- 2.25.1