diff options
author | Eric Sun <jian.sun@freescale.com> | 2012-02-20 15:24:44 +0800 |
---|---|---|
committer | Lily Zhang <r58066@freescale.com> | 2012-02-27 13:01:09 +0800 |
commit | 39320e8b20031f7a5f670cf5bd8eeb1a0954eb98 (patch) | |
tree | c0c7aaffd5415c67e63d0e757817aa27763fdced /common/cmd_nvedit.c | |
parent | 1f94eca51ded562db2aae2d1d75e3c7a2a1ba71c (diff) | |
download | u-boot-imx-39320e8b20031f7a5f670cf5bd8eeb1a0954eb98.zip u-boot-imx-39320e8b20031f7a5f670cf5bd8eeb1a0954eb98.tar.gz u-boot-imx-39320e8b20031f7a5f670cf5bd8eeb1a0954eb98.tar.bz2 |
ENGR00174841 [U-Boot]Add a command to erase any pre-saved environment
A "destroyenv" command is provided to erase any pre-save environment in the
boot storage. The command simply add 1 to the CRC section and write it back
to the storage. Per the logic of U-Boot, this means after a reset, the
software will recognize the stored environment settings as "damaged" and turn
to use the default one, which is defined in "default_environment"
With this command, platform bring up owner can maintain a "ready-to-use"
environment settings in software which others can use very conviniently.
U-boot users can also use it to do a environment restore if they want.
-----------------------------------
Usage Example:
> destroyenv
invalidate the CRC
write invalidate enviroment data to storage
Erasing SPI flash...Erasing SPI NOR flash 0xc0000 [0x2000 bytes]
..SUCCESS
Writing to SPI flash...Writing SPI NOR flash
0xc0000 [0x2000 bytes] <- ram 0x276009b8
SUCCESS
done
>
-----------------------------------
Signed-off-by: Eric Sun <jian.sun@freescale.com>
Diffstat (limited to 'common/cmd_nvedit.c')
-rw-r--r-- | common/cmd_nvedit.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index cf718e7..c1980da 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -5,7 +5,7 @@ * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Andreas Heppel <aheppel@sysgo.de> * - * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. + * Copyright (C) 2010-2012 Freescale Semiconductor, Inc. * * See file CREDITS for list of people who contributed to this * project. @@ -427,6 +427,16 @@ int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return _do_setenv (flag, argc, argv); } +#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) +int do_destroyenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + printf("invalidate the CRC\n"); + env_crc_destroy(); + printf("write invalidate enviroment data to storage\n"); + return saveenv() ? 1 : 0; +} +#endif + /************************************************************************ * Prompt for environment variable */ @@ -616,6 +626,15 @@ U_BOOT_CMD( " - delete environment variable 'name'" ); +#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) +U_BOOT_CMD( + destroyenv, CONFIG_SYS_MAXARGS, 0, do_destroyenv, + "destroy enviroment variables stored in medium", + "\n - destroy all environment variables in medium" + "\n after reset the default settings will be used" +); +#endif + #if defined(CONFIG_CMD_ASKENV) U_BOOT_CMD( |