Patchwork [U-Boot,v2,1/8] arm/km: introduce and manage bootcount environment variable

login
register
mail settings
Submitter Valentin Longchamp
Date May 3, 2011, 2:13 p.m.
Message ID <1304431996-24058-2-git-send-email-valentin.longchamp@keymile.com>
Download mbox | patch
Permalink /patch/93798/
State Changes Requested
Headers show

Comments

Valentin Longchamp - May 3, 2011, 2:13 p.m.
This environment variable is used to set the bootcount address
for the kernel.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Acked-by: Heiko Schocher <hs@denx.de>
cc: Prafulla Wadaskar <prafulla@marvell.com>
cc: Wolfgang Denk <wd@denx.de>
cc: Detlev Zundel <dzu@denx.de>
---
Changes for v2:
   - split up first large patch series to three independent smaller
     patch series
   - taken Wolfgang Denk's comments into account

 board/keymile/km_arm/km_arm.c |   14 ++++++++++++++
 include/configs/km_arm.h      |    3 +++
 2 files changed, 17 insertions(+), 0 deletions(-)

Patch

diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index c772ee2..f147f1f 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -145,6 +145,17 @@  int initialize_unit_leds(void)
 	return 0;
 }
 
+#if defined(CONFIG_BOOTCOUNT_LIMIT)
+void set_bootcount_addr(void)
+{
+	uchar buf[32];
+	unsigned int bootcountaddr;
+	bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR;
+	sprintf((char *)buf, "0x%x", bootcountaddr);
+	setenv("bootcountaddr", (char *)buf);
+}
+#endif
+
 int misc_init_r(void)
 {
 	char *str;
@@ -215,6 +226,9 @@  int board_init(void)
 int last_stage_init(void)
 {
 	set_km_env();
+#if defined(CONFIG_BOOTCOUNT_LIMIT)
+	set_bootcount_addr();
+#endif
 	return 0;
 }
 
diff --git a/include/configs/km_arm.h b/include/configs/km_arm.h
index 70113d4..89f9d35 100644
--- a/include/configs/km_arm.h
+++ b/include/configs/km_arm.h
@@ -64,6 +64,9 @@ 
 #define CONFIG_KM_KERNEL_ADDR	0x2000000	/* 4096KBytes */
 
 #define CONFIG_KM_DEF_ENV_CPU						\
+	"addbootcount="							\
+		"setenv bootargs ${bootargs} "				\
+		"bootcountaddr=${bootcountaddr}\0"			\
 	"addmtdparts=setenv bootargs ${bootargs} ${mtdparts}\0"		\
 	"boot=bootm ${actual_kernel_addr} - -\0"			\
 	"cramfsloadfdt=echo \\\\c\0"					\