Merge "Change flash name."
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 340c73e..a34f20f 100755
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -188,15 +188,10 @@
#ifndef CONFIG_ENV_OVERWRITE
/*
- * Ethernet Address and serial# can be set only once,
+ * Serial# can be set only once,
* ver is readonly.
*/
- if ( (strcmp (name, "serial#") == 0) ||
- ((strcmp (name, "ethaddr") == 0)
-#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
- && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
-#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
- ) ) {
+ if ((strcmp (name, "serial#") == 0)) {
printf ("Can't overwrite \"%s\"\n", name);
return 1;
}
@@ -401,6 +396,7 @@
if (argc >= 2 && is_sysvar_shared(argv[1])) {
printf("ERR: %s is a sysvar-shared variable.\n"
" Please use setvar/sysvar instead\n", argv[1]);
+ return 1;
}
return _do_setenv (flag, argc, argv);
diff --git a/common/cmd_sysvar.c b/common/cmd_sysvar.c
index 4eacbb5..49bab01 100644
--- a/common/cmd_sysvar.c
+++ b/common/cmd_sysvar.c
@@ -20,10 +20,6 @@
const char *uboot_name;
};
-struct sysvar_uboot_map {
- struct sysvar_uboot *map;
-};
-
static const struct sysvar_uboot su_mappings[] = {
{
.sysvar_name = ACTIVATED_KERNEL_NAME_SV,
@@ -35,10 +31,6 @@
},
};
-static const struct sysvar_uboot_map su_map = {
- .map = su_mappings,
-};
-
// Some bit twiddling for erasing the correct sector on Atheros flash. This
// only erases multiples of 64kb.
#define __SYSVAR_ERASE_SECTOR(x) (((x) >> 16) & 0xff)
@@ -693,9 +685,9 @@
int is_sysvar_shared(const char *var) {
int i;
- for (i = 0; i < ARRAY_SIZE(su_map.map); ++i) {
- if (strcmp(var, su_map.map[i].uboot_name) == 0 ||
- strcmp(var, su_map.map[i].sysvar_name) == 0) {
+ for (i = 0; i < ARRAY_SIZE(su_mappings); ++i) {
+ if (strcmp(var, su_mappings[i].uboot_name) == 0 ||
+ strcmp(var, su_mappings[i].sysvar_name) == 0) {
return true;
}
}
@@ -704,9 +696,9 @@
const char *get_uboot_name(const char *sysvar_name) {
int i;
- for (i = 0; i < ARRAY_SIZE(su_map.map); ++i) {
- if (strcmp(sysvar_name, su_map.map[i].uboot_name) == 0) {
- return su_map.map[i].uboot_name;
+ for (i = 0; i < ARRAY_SIZE(su_mappings); ++i) {
+ if (strcmp(sysvar_name, su_mappings[i].sysvar_name) == 0) {
+ return su_mappings[i].uboot_name;
}
}
return NULL;
@@ -714,8 +706,8 @@
void delete_uboot_vars(void) {
int i;
- for (i = 0; i < ARRAY_SIZE(su_map.map); ++i) {
- setenv(su_map.map[i].sysvar_name, NULL);
- setenv(su_map.map[i].uboot_name, NULL);
+ for (i = 0; i < ARRAY_SIZE(su_mappings); ++i) {
+ setenv(su_mappings[i].sysvar_name, NULL);
+ setenv(su_mappings[i].uboot_name, NULL);
}
}
diff --git a/common/env_common.c b/common/env_common.c
index a188fa3..2b11e73 100755
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -303,3 +303,54 @@
return found;
}
#endif
+
+int env_restore_defaults(void)
+{
+ int i;
+ const uchar delim = '=';
+ const int default_env_size = sizeof(default_environment) - 1;
+ char *s;
+ uchar *key = NULL;
+ uchar *val = NULL;
+ uchar *tmp_null = NULL;
+ for (i = 0; i < default_env_size; ++i) {
+ if (key == NULL) {
+ key = default_environment + i;
+ }
+ /* If delim is encountered, we know to check for key/val. */
+ if (default_environment[i] == delim) {
+ /* Ignore empty keys. */
+ if (key == (default_environment + i)) {
+ return -1;
+ }
+ /*
+ * Does in-place changing of null terminator to avoid
+ * extra buffers.
+ */
+ tmp_null = default_environment + i;
+ val = tmp_null + 1;
+ *tmp_null = '\0';
+ s = getenv(key);
+ if (!s) {
+ setenv(key, val);
+ }
+ *tmp_null = delim;
+ /*
+ * Advances pointer until we encounter the end of the
+ * 'val' string.
+ */
+ for ( ; i < default_env_size; ++i) {
+ if (default_environment[i] == '\0') {
+ break;
+ }
+ }
+ key = NULL;
+ }
+ }
+ if (key != NULL && *key != '\0') {
+ printf("%s: incomplete parsing while restoring env.\n", __FILE__);
+ printf("\tPlease check default_environment var\n");
+ return -1;
+ }
+ return 0;
+}
diff --git a/common/main.c b/common/main.c
index 46b2564..80e16bb 100755
--- a/common/main.c
+++ b/common/main.c
@@ -29,6 +29,9 @@
#include <watchdog.h>
#include <command.h>
+#define XMK_STR(x) #x
+#define MK_STR(x) XMK_STR(x)
+
#ifdef CONFIG_MODEM_SUPPORT
#include <malloc.h> /* for free() prototype */
#endif
@@ -405,24 +408,20 @@
}
else
#endif /* CONFIG_BOOTCOUNT_LIMIT */
- s = getenv ("bootcmd");
- if (!s) {
-#ifdef CONFIG_ROOTFS_FLASH
- /* XXX if rootfs is in flash, expect uImage to be in flash */
-#ifdef CONFIG_AR7100
- setenv ("bootcmd", "bootm 0xbf200000");
-#else
- setenv ("bootcmd", "bootm 0xbf450000");
-#endif /* CONFIG_AR7100 */
-#else
- setenv ("bootcmd", "tftpboot 0x8022c090 uImage; bootm 0x8022c090");
-#endif
- }
#ifdef CONFIG_DUALIMAGE_SUPPORT
findbdr(0);
#endif
- s = getenv ("bootcmd");
+
+ if (env_restore_defaults()) {
+ printf("Warning: Unable to completely restore default env.\n");
+ }
+
+ s = getenv ("bootcmd");
+ if (!s) {
+ setenv("bootcmd", CONFIG_BOOTCOMMAND);
+ s = CONFIG_BOOTCOMMAND;
+ }
// debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
diff --git a/include/common.h b/include/common.h
index a39a27c..2d7aa6c 100755
--- a/include/common.h
+++ b/include/common.h
@@ -223,6 +223,9 @@
const char *get_uboot_name(const char *sysvar_name);
void delete_uboot_vars(void);
+/* common/env_common.c */
+int env_restore_defaults(void);
+
/* common/cmd_nvedit.c */
int env_init (void);
void env_relocate (void);
diff --git a/include/configs/board953x.h b/include/configs/board953x.h
index 69f4fe2..dc94ede 100755
--- a/include/configs/board953x.h
+++ b/include/configs/board953x.h
@@ -194,7 +194,7 @@
# define ATH_F_FILE fs_name(${bc}-nand-jffs2)
# define ATH_F_LEN 0x700000
# define ATH_F_ADDR 0x1c0000
-# define ATH_K_FILE vmlinux${bc}.lzma.uImage
+# define ATH_K_FILE kernel.img
# define ATH_K_ADDR 0x80000
# define ATH_F_CMD nand_gen_cmd(lf, ATH_F_ADDR, ATH_F_FILE, ATH_F_LEN)
# define ATH_K_CMD nand_gen_cmd(lk, ATH_K_ADDR, ATH_K_FILE, 0x140000)
@@ -205,7 +205,7 @@
# define ATH_F_FILE fs_name(${bc}-jffs2)
# define ATH_F_LEN $filesize
# define ATH_F_ADDR 0x9f010000
-# define ATH_K_FILE vmlinux${bc}.lzma.uImage
+# define ATH_K_FILE kernel.img
# define ATH_K_ADDR 0x9f300000
/*
* For compressed uboot, environment sector is not used.
@@ -238,7 +238,7 @@
# define MTDPARTS_DEFAULT "mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env)," ATH_ROOTFS_SIZE ",1408k(uImage)," ATH_MTDPARTS_MIB0 ",64k(ART)"
# define ATH_F_ADDR 0x9f050000
# endif
-# define ATH_K_FILE vmlinux${bc}.lzma.uImage
+# define ATH_K_FILE kernel.img
# endif
#endif /*CONFIG_MI124*/