aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2013-10-07 15:01:05 +0000
committerJohn Crispin <blogic@openwrt.org>2013-10-07 15:01:05 +0000
commit5389f22eda4fb63c5a51ccc69098dc0fea17867c (patch)
treef7681f2f5824f262e89543248670b030e899a187
parent9f6f08e80de70ed4b62a93834ee880a61b846c47 (diff)
downloadmaster-187ad058-5389f22eda4fb63c5a51ccc69098dc0fea17867c.tar.gz
master-187ad058-5389f22eda4fb63c5a51ccc69098dc0fea17867c.tar.bz2
master-187ad058-5389f22eda4fb63c5a51ccc69098dc0fea17867c.zip
tools: add tool to generate dcs93xl images
Signed-off-by: John Crispin <blogic@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38317 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--tools/firmware-utils/Makefile1
-rw-r--r--tools/firmware-utils/src/mkdcs932.c39
2 files changed, 40 insertions, 0 deletions
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 45690f5949..770fcf5fd4 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -65,6 +65,7 @@ define Host/Compile
$(call cc,fix-u-media-header cyg_crc32,-Wall)
$(call cc,hcsmakeimage bcmalgo)
$(call cc,mkporayfw, -Wall)
+ $(call cc,mkdcs932, -Wall)
endef
define Host/Install
diff --git a/tools/firmware-utils/src/mkdcs932.c b/tools/firmware-utils/src/mkdcs932.c
new file mode 100644
index 0000000000..28c67aa3b3
--- /dev/null
+++ b/tools/firmware-utils/src/mkdcs932.c
@@ -0,0 +1,39 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License,
+ * version 2 as published by the Free Software Foundation.
+ *
+ * (C) John Crispin <blogic@openwrt.org>
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ uint32_t t = 0, sum = 0x55aa55aa;
+ int fd;
+
+ if ((argc != 2) || ((fd = open(argv[1], O_RDWR)) == -1)) {
+ fprintf(stderr, "Usage: %s input_file\n", *argv);
+ return -EINVAL;
+ }
+
+ lseek(fd, -4, SEEK_END);
+ write(fd, &t, 4);
+ lseek(fd, 0, SEEK_SET);
+
+ while (read(fd, &t, 4) > 0)
+ sum -= t;
+
+ lseek(fd, -4, SEEK_END);
+ write(fd, &sum, 4);
+ close(fd);
+
+ return 0;
+}