summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile1
-rw-r--r--tools/env/fw_env.c13
-rw-r--r--tools/env/fw_env.h4
-rw-r--r--tools/envcrc.c6
-rw-r--r--tools/mkenvimage.c14
-rw-r--r--tools/mkimage.c97
-rw-r--r--tools/mxsboot.c3
7 files changed, 78 insertions, 60 deletions
diff --git a/tools/Makefile b/tools/Makefile
index a5f989a6717..64bcc4db472 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -194,6 +194,7 @@ $(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o
$(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)mkimage$(SFX): $(obj)aisimage.o \
$(obj)crc32.o \
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 996682ebc7e..e292d2ba1db 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -45,6 +45,8 @@
#include "fw_env.h"
+#include <config.h>
+
#define WHITESPACE(c) ((c == '\t') || (c == ' '))
#define min(x, y) ({ \
@@ -390,15 +392,22 @@ int fw_env_write(char *name, char *value)
* Delete any existing definition
*/
if (oldval) {
+#ifndef CONFIG_ENV_OVERWRITE
/*
* Ethernet Address and serial# can be set only once
*/
- if ((strcmp (name, "ethaddr") == 0) ||
- (strcmp (name, "serial#") == 0)) {
+ if (
+ (strcmp(name, "serial#") == 0) ||
+ ((strcmp(name, "ethaddr") == 0)
+#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
+ && (strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0)
+#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
+ ) ) {
fprintf (stderr, "Can't overwrite \"%s\"\n", name);
errno = EROFS;
return -1;
}
+#endif /* CONFIG_ENV_OVERWRITE */
if (*++nxt == '\0') {
*env = '\0';
diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h
index 9258c796d87..2dcb373b62f 100644
--- a/tools/env/fw_env.h
+++ b/tools/env/fw_env.h
@@ -34,8 +34,12 @@
#define DEVICE2_NAME "/dev/mtd2"
#define DEVICE1_OFFSET 0x0000
#define ENV1_SIZE 0x4000
+#define DEVICE1_ESIZE 0x4000
+#define DEVICE1_ENVSECTORS 2
#define DEVICE2_OFFSET 0x0000
#define ENV2_SIZE 0x4000
+#define DEVICE2_ESIZE 0x4000
+#define DEVICE2_ENVSECTORS 2
#define CONFIG_BAUDRATE 115200
#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
diff --git a/tools/envcrc.c b/tools/envcrc.c
index 51e3f54a38a..08d2a8f550e 100644
--- a/tools/envcrc.c
+++ b/tools/envcrc.c
@@ -53,15 +53,15 @@
# endif
# if (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \
((CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) <= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN))
-# define ENV_IS_EMBEDDED 1
+# define ENV_IS_EMBEDDED
# endif
# if defined(CONFIG_ENV_ADDR_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND)
-# define CONFIG_SYS_REDUNDAND_ENVIRONMENT 1
+# define CONFIG_SYS_REDUNDAND_ENVIRONMENT
# endif
#endif /* CONFIG_ENV_IS_IN_FLASH */
#if defined(ENV_IS_EMBEDDED) && !defined(CONFIG_BUILD_ENVCRC)
-# define CONFIG_BUILD_ENVCRC 1
+# define CONFIG_BUILD_ENVCRC
#endif
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index c5ed373b992..f78173163f8 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -122,11 +122,11 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
case ':':
fprintf(stderr, "Missing argument for option -%c\n",
- option);
+ optopt);
usage(argv[0]);
return EXIT_FAILURE;
default:
- fprintf(stderr, "Wrong option -%c\n", option);
+ fprintf(stderr, "Wrong option -%c\n", optopt);
usage(prg);
return EXIT_FAILURE;
}
@@ -213,18 +213,18 @@ int main(int argc, char **argv)
/* Replace newlines separating variables with \0 */
for (fp = 0, ep = 0 ; fp < filesize ; fp++) {
if (filebuf[fp] == '\n') {
- if (fp == 0) {
+ if (ep == 0) {
/*
- * Newline at the beginning of the file ?
- * Ignore it.
+ * Newlines at the beginning of the file ?
+ * Ignore them.
*/
continue;
} else if (filebuf[fp-1] == '\\') {
/*
* Embedded newline in a variable.
*
- * The backslash was added to the envptr ;
- * rewind and replace it with a newline
+ * The backslash was added to the envptr; rewind
+ * and replace it with a newline
*/
ep--;
envptr[ep++] = '\n';
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 36e28ec9234..eeb1b106682 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -383,65 +383,66 @@ NXTARG: ;
exit (EXIT_FAILURE);
}
- if (!params.skipcpy &&
- (params.type == IH_TYPE_MULTI ||
- params.type == IH_TYPE_SCRIPT)) {
- char *file = params.datafile;
- uint32_t size;
-
- for (;;) {
- char *sep = NULL;
-
- if (file) {
- if ((sep = strchr(file, ':')) != NULL) {
- *sep = '\0';
+ if (!params.skipcpy) {
+ if (params.type == IH_TYPE_MULTI ||
+ params.type == IH_TYPE_SCRIPT) {
+ char *file = params.datafile;
+ uint32_t size;
+
+ for (;;) {
+ char *sep = NULL;
+
+ if (file) {
+ if ((sep = strchr(file, ':')) != NULL) {
+ *sep = '\0';
+ }
+
+ if (stat (file, &sbuf) < 0) {
+ fprintf (stderr, "%s: Can't stat %s: %s\n",
+ params.cmdname, file, strerror(errno));
+ exit (EXIT_FAILURE);
+ }
+ size = cpu_to_uimage (sbuf.st_size);
+ } else {
+ size = 0;
}
- if (stat (file, &sbuf) < 0) {
- fprintf (stderr, "%s: Can't stat %s: %s\n",
- params.cmdname, file, strerror(errno));
+ if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) {
+ fprintf (stderr, "%s: Write error on %s: %s\n",
+ params.cmdname, params.imagefile,
+ strerror(errno));
exit (EXIT_FAILURE);
}
- size = cpu_to_uimage (sbuf.st_size);
- } else {
- size = 0;
- }
- if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) {
- fprintf (stderr, "%s: Write error on %s: %s\n",
- params.cmdname, params.imagefile,
- strerror(errno));
- exit (EXIT_FAILURE);
- }
+ if (!file) {
+ break;
+ }
- if (!file) {
- break;
+ if (sep) {
+ *sep = ':';
+ file = sep + 1;
+ } else {
+ file = NULL;
+ }
}
- if (sep) {
- *sep = ':';
- file = sep + 1;
- } else {
- file = NULL;
- }
- }
+ file = params.datafile;
- file = params.datafile;
-
- for (;;) {
- char *sep = strchr(file, ':');
- if (sep) {
- *sep = '\0';
- copy_file (ifd, file, 1);
- *sep++ = ':';
- file = sep;
- } else {
- copy_file (ifd, file, 0);
- break;
+ for (;;) {
+ char *sep = strchr(file, ':');
+ if (sep) {
+ *sep = '\0';
+ copy_file (ifd, file, 1);
+ *sep++ = ':';
+ file = sep;
+ } else {
+ copy_file (ifd, file, 0);
+ break;
+ }
}
+ } else {
+ copy_file (ifd, params.datafile, 0);
}
- } else {
- copy_file (ifd, params.datafile, 0);
}
/* We're a bit of paranoid */
diff --git a/tools/mxsboot.c b/tools/mxsboot.c
index 176753d2ce0..8246831d8ef 100644
--- a/tools/mxsboot.c
+++ b/tools/mxsboot.c
@@ -606,6 +606,9 @@ int parse_ops(int argc, char **argv)
};
int type;
+ if (argc < 4)
+ return -1;
+
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "-w", 2))
type = PARAM_WRITE;