From: Valentin Longchamp Date: Tue, 3 May 2011 16:13:09 +0200 Subject: [U-Boot] [PATCH v2 1/8] arm/km: introduce and manage bootcount environment variable In-Reply-To: <1304431996-24058-1-git-send-email-valentin.longchamp@keymile.com> References: <1304431996-24058-1-git-send-email-valentin.longchamp@keymile.com> Message-ID: <1304431996-24058-2-git-send-email-valentin.longchamp@keymile.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This environment variable is used to set the bootcount address for the kernel. Signed-off-by: Valentin Longchamp Signed-off-by: Holger Brunck Acked-by: Heiko Schocher cc: Prafulla Wadaskar cc: Wolfgang Denk cc: Detlev Zundel --- 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(-) 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" \ -- 1.7.0.5