]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
karo: remove dynamically created variables from the environment upon boot
authorLothar Waßmann <LW@KARO-electronics.de>
Fri, 9 Jan 2015 11:30:07 +0000 (12:30 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 9 Jan 2015 12:08:16 +0000 (13:08 +0100)
This prevents using stale values for variables that are dynamically
created (e.g. filesize) and may have been saved to flash.

board/karo/common/Makefile
board/karo/common/env.c [new file with mode: 0644]
board/karo/common/karo.h
board/karo/tx28/tx28.c
board/karo/tx48/tx48.c
board/karo/tx51/tx51.c
board/karo/tx53/tx53.c
board/karo/tx6/tx6qdl.c

index 64fe06c7a3363f0cde9787b520013868b2fc94cd..8e22489c3dd40abd87c07fbede8548fda55c9dd9 100644 (file)
@@ -28,7 +28,7 @@ ifeq ($(CONFIG_SPL_BUILD),)
 endif
 COBJS-$(CONFIG_CMD_NAND)               += nand.o
 COBJS-$(CONFIG_ENV_IS_IN_MMC)          += mmc.o
-
+COBJS-y                                += env.o
 COBJS   := $(COBJS-y)
 SOBJS  := 
 
diff --git a/board/karo/common/env.c b/board/karo/common/env.c
new file mode 100644 (file)
index 0000000..c6def4f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2014 Lothar Waßmann <LW@KARO-electronics.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <libfdt.h>
+#include <fdt_support.h>
+
+#include "karo.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const char const *cleanup_vars[] = {
+       "bootargs",
+       "fileaddr",
+       "filesize",
+};
+
+void env_cleanup(void)
+{
+       size_t i;
+
+       for (i = 0; i < ARRAY_SIZE(cleanup_vars); i++) {
+               setenv(cleanup_vars[i], NULL);
+       }
+}
index 7264df1ab7bf45ac873dc235463260985cc13c28..d078828d116f8ec881c1472979b43cfc136076c5 100644 (file)
@@ -22,6 +22,8 @@ struct fb_videomode;
 #define is_lvds()                      0
 #endif
 
+void env_cleanup(void);
+
 #ifdef CONFIG_OF_LIBFDT
 void karo_fdt_remove_node(void *blob, const char *node);
 void karo_fdt_move_fdt(void);
index cf64c5392f51cc67df0680aff91536cfad329b31..ca0b3bcb71837e802f04e663f44b539e28bc9688 100644 (file)
@@ -835,6 +835,8 @@ int board_late_init(void)
        int ret = 0;
        const char *baseboard;
 
+       env_cleanup();
+
        karo_fdt_move_fdt();
 
        baseboard = getenv("baseboard");
index 0bc8d9111a44f5a0ef7b22429c0be7324bee68f8..539472a1b1cd1f06bce3a11f0c53d72c92c396e7 100644 (file)
@@ -966,6 +966,8 @@ int board_late_init(void)
        int ret = 0;
        const char *baseboard;
 
+       env_cleanup();
+
        tx48_set_cpu_clock();
        karo_fdt_move_fdt();
 
index 3117bf9f5e58ca0e3b56a34edcd0563344e92e1b..72c6584121f15d15cd1294cb8e52b3a887234045 100644 (file)
@@ -1043,6 +1043,8 @@ int board_late_init(void)
        int ret = 0;
        const char *baseboard;
 
+       env_cleanup();
+
        tx51_set_cpu_clock();
        karo_fdt_move_fdt();
 
index 06a9a4b5a2cd2e2c4a616797be196a97f4a11522..3074ae9615766da10a30f8f237ff498477da2d51 100644 (file)
@@ -1323,6 +1323,8 @@ int board_late_init(void)
        int ret = 0;
        const char *baseboard;
 
+       env_cleanup();
+
        tx53_set_cpu_clock();
        karo_fdt_move_fdt();
 
index a577f485591e1a514661860eb33f65bb1015c645..72141365d276afb29b8ce70b52be8770654a97a9 100644 (file)
@@ -1112,6 +1112,8 @@ int board_late_init(void)
        int ret = 0;
        const char *baseboard;
 
+       env_cleanup();
+
        if (tx6_temp_check_enabled)
                check_cpu_temperature(1);