From 32066bf6a495d76418fccb8c6944fe36b8cb04aa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Fri, 9 Jan 2015 12:30:07 +0100 Subject: [PATCH] karo: remove dynamically created variables from the environment upon boot 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 | 2 +- board/karo/common/env.c | 40 ++++++++++++++++++++++++++++++++++++++ board/karo/common/karo.h | 2 ++ board/karo/tx28/tx28.c | 2 ++ board/karo/tx48/tx48.c | 2 ++ board/karo/tx51/tx51.c | 2 ++ board/karo/tx53/tx53.c | 2 ++ board/karo/tx6/tx6qdl.c | 2 ++ 8 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 board/karo/common/env.c diff --git a/board/karo/common/Makefile b/board/karo/common/Makefile index 64fe06c7a3..8e22489c3d 100644 --- a/board/karo/common/Makefile +++ b/board/karo/common/Makefile @@ -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 index 0000000000..c6def4f9ee --- /dev/null +++ b/board/karo/common/env.c @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2014 Lothar Waßmann + * + * 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 +#include +#include +#include + +#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); + } +} diff --git a/board/karo/common/karo.h b/board/karo/common/karo.h index 7264df1ab7..d078828d11 100644 --- a/board/karo/common/karo.h +++ b/board/karo/common/karo.h @@ -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); diff --git a/board/karo/tx28/tx28.c b/board/karo/tx28/tx28.c index cf64c5392f..ca0b3bcb71 100644 --- a/board/karo/tx28/tx28.c +++ b/board/karo/tx28/tx28.c @@ -835,6 +835,8 @@ int board_late_init(void) int ret = 0; const char *baseboard; + env_cleanup(); + karo_fdt_move_fdt(); baseboard = getenv("baseboard"); diff --git a/board/karo/tx48/tx48.c b/board/karo/tx48/tx48.c index 0bc8d9111a..539472a1b1 100644 --- a/board/karo/tx48/tx48.c +++ b/board/karo/tx48/tx48.c @@ -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(); diff --git a/board/karo/tx51/tx51.c b/board/karo/tx51/tx51.c index 3117bf9f5e..72c6584121 100644 --- a/board/karo/tx51/tx51.c +++ b/board/karo/tx51/tx51.c @@ -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(); diff --git a/board/karo/tx53/tx53.c b/board/karo/tx53/tx53.c index 06a9a4b5a2..3074ae9615 100644 --- a/board/karo/tx53/tx53.c +++ b/board/karo/tx53/tx53.c @@ -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(); diff --git a/board/karo/tx6/tx6qdl.c b/board/karo/tx6/tx6qdl.c index a577f48559..72141365d2 100644 --- a/board/karo/tx6/tx6qdl.c +++ b/board/karo/tx6/tx6qdl.c @@ -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); -- 2.39.2