mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
Add 'editenv' command
The editenv command can be used to edit an environment variable. Editing an environment variable is useful when one wants to tweak an existing variable, for example fix a typo or change the baudrate in the 'bootargs' environment variable. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
This commit is contained in:
parent
b0fa8e5063
commit
246c69225c
4 changed files with 43 additions and 0 deletions
1
README
1
README
|
@ -620,6 +620,7 @@ The following options need to be configured:
|
||||||
CONFIG_CMD_DS4510_RST * ds4510 I2C rst command
|
CONFIG_CMD_DS4510_RST * ds4510 I2C rst command
|
||||||
CONFIG_CMD_DTT * Digital Therm and Thermostat
|
CONFIG_CMD_DTT * Digital Therm and Thermostat
|
||||||
CONFIG_CMD_ECHO echo arguments
|
CONFIG_CMD_ECHO echo arguments
|
||||||
|
CONFIG_CMD_EDITENV edit env variable
|
||||||
CONFIG_CMD_EEPROM * EEPROM read/write support
|
CONFIG_CMD_EEPROM * EEPROM read/write support
|
||||||
CONFIG_CMD_ELF * bootelf, bootvx
|
CONFIG_CMD_ELF * bootelf, bootvx
|
||||||
CONFIG_CMD_SAVEENV saveenv
|
CONFIG_CMD_SAVEENV saveenv
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <environment.h>
|
#include <environment.h>
|
||||||
|
#if defined(CONFIG_CMD_EDITENV)
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
#include <linux/stddef.h>
|
#include <linux/stddef.h>
|
||||||
|
@ -502,6 +505,34 @@ int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* Interactively edit an environment variable
|
||||||
|
*/
|
||||||
|
#if defined(CONFIG_CMD_EDITENV)
|
||||||
|
int do_editenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char buffer[CONFIG_SYS_CBSIZE];
|
||||||
|
char *init_val;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
cmd_usage(cmdtp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set read buffer to initial value or empty sting */
|
||||||
|
init_val = getenv(argv[1]);
|
||||||
|
if (init_val)
|
||||||
|
len = sprintf(buffer, "%s", init_val);
|
||||||
|
else
|
||||||
|
buffer[0] = '\0';
|
||||||
|
|
||||||
|
readline_into_buffer("edit: ", buffer);
|
||||||
|
|
||||||
|
return setenv(argv[1], buffer);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CMD_EDITENV */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Look up variable from environment,
|
* Look up variable from environment,
|
||||||
* return address of storage for that variable,
|
* return address of storage for that variable,
|
||||||
|
@ -597,6 +628,15 @@ int envmatch (uchar *s1, int i2)
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_CMD_EDITENV)
|
||||||
|
U_BOOT_CMD(
|
||||||
|
editenv, 2, 0, do_editenv,
|
||||||
|
"edit environment variable",
|
||||||
|
"name\n"
|
||||||
|
" - edit environment variable 'name'"
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
printenv, CONFIG_SYS_MAXARGS, 1, do_printenv,
|
printenv, CONFIG_SYS_MAXARGS, 1, do_printenv,
|
||||||
"print environment variables",
|
"print environment variables",
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#define CONFIG_CMD_DOC /* Disk-On-Chip Support */
|
#define CONFIG_CMD_DOC /* Disk-On-Chip Support */
|
||||||
#define CONFIG_CMD_DTT /* Digital Therm and Thermostat */
|
#define CONFIG_CMD_DTT /* Digital Therm and Thermostat */
|
||||||
#define CONFIG_CMD_ECHO /* echo arguments */
|
#define CONFIG_CMD_ECHO /* echo arguments */
|
||||||
|
#define CONFIG_CMD_EDITENV /* editenv */
|
||||||
#define CONFIG_CMD_EEPROM /* EEPROM read/write support */
|
#define CONFIG_CMD_EEPROM /* EEPROM read/write support */
|
||||||
#define CONFIG_CMD_ELF /* ELF (VxWorks) load/boot cmd */
|
#define CONFIG_CMD_ELF /* ELF (VxWorks) load/boot cmd */
|
||||||
#define CONFIG_CMD_SAVEENV /* saveenv */
|
#define CONFIG_CMD_SAVEENV /* saveenv */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define CONFIG_CMD_BOOTD /* bootd */
|
#define CONFIG_CMD_BOOTD /* bootd */
|
||||||
#define CONFIG_CMD_CONSOLE /* coninfo */
|
#define CONFIG_CMD_CONSOLE /* coninfo */
|
||||||
#define CONFIG_CMD_ECHO /* echo arguments */
|
#define CONFIG_CMD_ECHO /* echo arguments */
|
||||||
|
#define CONFIG_CMD_EDITENV /* editenv */
|
||||||
#define CONFIG_CMD_FPGA /* FPGA configuration Support */
|
#define CONFIG_CMD_FPGA /* FPGA configuration Support */
|
||||||
#define CONFIG_CMD_IMI /* iminfo */
|
#define CONFIG_CMD_IMI /* iminfo */
|
||||||
#define CONFIG_CMD_ITEST /* Integer (and string) test */
|
#define CONFIG_CMD_ITEST /* Integer (and string) test */
|
||||||
|
|
Loading…
Reference in a new issue