From: Piotr Dymacz Date: Wed, 5 Apr 2017 21:46:50 +0000 (+0200) Subject: Fix and improve recovery script X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0809ecc4176ca5653e3a448236c07c538e5dda45;p=oweals%2Fu-boot_mod.git Fix and improve recovery script - use itest for comparison - don't loop longer than for 10 seconds (in extreme cases that could result in endless loop) - show that counter variable value is hex - clear cnt variable at script end - clear stop_boot variable before loop --- diff --git a/u-boot/include/env_scripts.h b/u-boot/include/env_scripts.h index 558d079..0888b63 100644 --- a/u-boot/include/env_scripts.h +++ b/u-boot/include/env_scripts.h @@ -117,8 +117,9 @@ #if !defined(CONFIG_CMD_BUTTON) ||\ !defined(CONFIG_CMD_SLEEP) ||\ !defined(CONFIG_CMD_LED) ||\ + !defined(CONFIG_CMD_ITEST) ||\ !defined(CONFIG_CMD_SETEXPR) - #error "Commands setexpr, sleep, button and led{on, off} are required for recovery" + #error "Commands setexpr, itest, sleep, button and led{on, off} are required for recovery" #endif #if !defined(CONFIG_GPIO_RESET_BTN) @@ -130,16 +131,16 @@ "echo - 3s for web based recovery;" #define SCRIPT_HTTP_PART_2 \ - "elif test $cnt -ge 3; then " \ + "elif itest $cnt >= 3; then " \ "echo HTTP server is starting for firmware update...;" \ "setenv stop_boot 1;" \ "echo;" \ "httpd;" \ - "elif test $cnt -lt 3; then " + "elif itest $cnt < 3; then " #else #define SCRIPT_HTTP_PART_1 "" #define SCRIPT_HTTP_PART_2 \ - "elif test $cnt -lt 5; then " + "elif itest $cnt < 5; then " #endif #define CONFIG_ENV_BTN_RECOVERY_SCRIPT \ @@ -147,12 +148,13 @@ "if button; then " \ "sleep 600;" \ "setenv cnt 0;" \ + "setenv stop_boot;" \ "echo Keep button pressed for at least:;" \ SCRIPT_HTTP_PART_1 \ "echo - 5s for U-Boot console;" \ "echo - 7s for network console;" \ "echo;" \ - "while button; do " \ + "while button && itest $cnt < 0xA; do " \ "ledon;" \ "sleep 300;" \ "echo . \'\\\\c\';" \ @@ -161,14 +163,18 @@ "sleep 600;" \ "setexpr cnt $cnt + 1;" \ "done;" \ - "echo $cnt seconds;" \ + "echo 0x$cnt seconds;" \ "echo;" \ - "if test $cnt -ge 7; then " \ + "if itest $cnt >= 0xA; then " \ + "echo \\#\\# Error: 10s limit reached!;" \ + "echo Continuing normal boot...;" \ + "echo;" \ + "elif itest $cnt >= 7; then " \ "echo Starting network console...;" \ "setenv stop_boot 1;" \ "echo;" \ "startnc;" \ - "elif test $cnt -ge 5; then " \ + "elif itest $cnt >= 5; then " \ "echo Starting U-Boot console...;" \ "setenv stop_boot 1;" \ "echo;" \ @@ -176,7 +182,8 @@ "echo \\#\\# Error: button was not pressed long enough!;" \ "echo Continuing normal boot...;" \ "echo;" \ - "fi;"\ + "fi;" \ + "setenv cnt;" \ "fi\0" #endif /* CONFIG_BTN_RECOVERY_SCRIPT */