2002-12-17 01:51:00 +00:00
|
|
|
/*
|
2008-05-07 03:16:15 +00:00
|
|
|
* (C) Copyright 2002-2008
|
2002-12-17 01:51:00 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2013-10-07 11:07:26 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2002-12-17 01:51:00 +00:00
|
|
|
*/
|
|
|
|
|
2015-12-09 12:13:24 +00:00
|
|
|
#include <aes.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-12-20 14:30:27 +00:00
|
|
|
/* Pull in the current config to define the default environment */
|
2015-06-17 15:58:32 +00:00
|
|
|
#include <linux/kconfig.h>
|
|
|
|
|
2012-12-20 14:30:27 +00:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#define __ASSEMBLY__ /* get only #defines from config.h */
|
|
|
|
#include <config.h>
|
|
|
|
#undef __ASSEMBLY__
|
|
|
|
#else
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2012-01-05 08:09:10 +00:00
|
|
|
* To build the utility with the static configuration
|
|
|
|
* comment out the next line.
|
2011-05-01 18:44:23 +00:00
|
|
|
* See included "fw_env.config" sample file
|
2003-01-11 09:48:40 +00:00
|
|
|
* for notes on configuration.
|
|
|
|
*/
|
2003-04-20 14:04:18 +00:00
|
|
|
#define CONFIG_FILE "/etc/fw_env.config"
|
2003-01-11 09:48:40 +00:00
|
|
|
|
2012-10-03 09:38:46 +00:00
|
|
|
#ifndef CONFIG_FILE
|
2002-12-17 01:51:00 +00:00
|
|
|
#define HAVE_REDUND /* For systems with 2 env sectors */
|
|
|
|
#define DEVICE1_NAME "/dev/mtd1"
|
|
|
|
#define DEVICE2_NAME "/dev/mtd2"
|
2003-01-11 09:48:40 +00:00
|
|
|
#define DEVICE1_OFFSET 0x0000
|
2002-12-17 01:51:00 +00:00
|
|
|
#define ENV1_SIZE 0x4000
|
2011-12-01 03:30:04 +00:00
|
|
|
#define DEVICE1_ESIZE 0x4000
|
|
|
|
#define DEVICE1_ENVSECTORS 2
|
2003-01-11 09:48:40 +00:00
|
|
|
#define DEVICE2_OFFSET 0x0000
|
2002-12-17 01:51:00 +00:00
|
|
|
#define ENV2_SIZE 0x4000
|
2011-12-01 03:30:04 +00:00
|
|
|
#define DEVICE2_ESIZE 0x4000
|
|
|
|
#define DEVICE2_ENVSECTORS 2
|
2012-10-03 09:38:46 +00:00
|
|
|
#endif
|
2002-12-17 01:51:00 +00:00
|
|
|
|
2012-12-20 14:30:27 +00:00
|
|
|
#ifndef CONFIG_BAUDRATE
|
|
|
|
#define CONFIG_BAUDRATE 115200
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_BOOTDELAY
|
|
|
|
#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_BOOTCOMMAND
|
|
|
|
#define CONFIG_BOOTCOMMAND \
|
|
|
|
"bootp; " \
|
|
|
|
"setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} " \
|
|
|
|
"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
|
|
|
|
"bootm"
|
|
|
|
#endif
|
|
|
|
|
2015-12-09 12:13:24 +00:00
|
|
|
struct common_args {
|
|
|
|
#ifdef CONFIG_FILE
|
|
|
|
char *config_file;
|
|
|
|
#endif
|
|
|
|
uint8_t aes_key[AES_KEY_LENGTH];
|
|
|
|
int aes_flag; /* Is AES encryption used? */
|
|
|
|
};
|
|
|
|
extern struct common_args common_args;
|
|
|
|
|
2015-12-09 12:13:23 +00:00
|
|
|
struct printenv_args {
|
2015-12-09 12:13:24 +00:00
|
|
|
int name_suppress;
|
2015-12-09 12:13:23 +00:00
|
|
|
};
|
|
|
|
extern struct printenv_args printenv_args;
|
|
|
|
|
|
|
|
struct setenv_args {
|
|
|
|
char *script_file;
|
|
|
|
};
|
|
|
|
extern struct setenv_args setenv_args;
|
|
|
|
|
2015-12-09 12:13:24 +00:00
|
|
|
int parse_aes_key(char *key, uint8_t *bin_key);
|
|
|
|
|
2008-05-07 03:16:15 +00:00
|
|
|
extern int fw_printenv(int argc, char *argv[]);
|
2007-11-27 09:23:20 +00:00
|
|
|
extern char *fw_getenv (char *name);
|
|
|
|
extern int fw_setenv (int argc, char *argv[]);
|
2010-05-24 10:08:16 +00:00
|
|
|
extern int fw_parse_script(char *fname);
|
|
|
|
extern int fw_env_open(void);
|
|
|
|
extern int fw_env_write(char *name, char *value);
|
|
|
|
extern int fw_env_close(void);
|
2002-12-17 01:51:00 +00:00
|
|
|
|
|
|
|
extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned);
|