From e6fe39351d3363273365ef9be3c4ed4fa274e602 Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 6 Apr 2017 14:13:38 -0500 Subject: 2nd attempt:patch to prevent inadvertant erasure of environment and allow deliberate erasure --- recipes-bsp/multitech/u-boot-linux-utils/crc_erase.patch | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes-bsp/multitech/u-boot-linux-utils/crc_erase.patch b/recipes-bsp/multitech/u-boot-linux-utils/crc_erase.patch index 67cd5ef..5d78703 100644 --- a/recipes-bsp/multitech/u-boot-linux-utils/crc_erase.patch +++ b/recipes-bsp/multitech/u-boot-linux-utils/crc_erase.patch @@ -3,7 +3,7 @@ # Allow the deliberate erasure of the environment with the # clearenv command. diff --git a/src/u_boot.c b/src/u_boot.c -index e240475..f10eaa3 100644 +index e240475..94f18ed 100644 --- a/src/u_boot.c +++ b/src/u_boot.c @@ -64,6 +64,8 @@ static int write_uboot_env(const char *device, struct environment *env) @@ -54,7 +54,7 @@ index e240475..f10eaa3 100644 crc1_ok = 0; } -@@ -315,20 +324,26 @@ int main(int argc, char *argv[]) { +@@ -315,20 +324,27 @@ int main(int argc, char *argv[]) { error("read_uboot_env failed"); return 1; } @@ -75,8 +75,10 @@ index e240475..f10eaa3 100644 crc2_ok = 0; } - if (!crc1_ok && !crc2_ok) { +- if (!crc1_ok && !crc2_ok) { - error("both environments are bad: loading DEFAULT_ENV"); ++ if (!crc1_ok && !crc2_ok && env1->crc == 0xffffffff && ++ (env1->flags == 0xff) && (env2->flags == 0xff) && (env2->crc == 0xffffffff)) { + error("both environments are bad: not loading DEFAULT_ENV"); env = env1; env->flags = 0; @@ -85,7 +87,7 @@ index e240475..f10eaa3 100644 } else if (crc1_ok && !crc2_ok) { env = env1; } else if (!crc1_ok && crc2_ok) { -@@ -353,6 +368,9 @@ int main(int argc, char *argv[]) { +@@ -353,6 +369,9 @@ int main(int argc, char *argv[]) { err = cmd_printenv(env, argc, argv); } else if (!tokcmp(cmd, "setenv")) { err = cmd_setenv(env, argc, argv); -- cgit v1.2.3