Sfoglia il codice sorgente

tools: add tool to generate dcs93xl images

Signed-off-by: John Crispin <[email protected]>

SVN-Revision: 38317
John Crispin 12 anni fa
parent
commit
fa4ca9d7eb
2 ha cambiato i file con 40 aggiunte e 0 eliminazioni
  1. 1 0
      tools/firmware-utils/Makefile
  2. 39 0
      tools/firmware-utils/src/mkdcs932.c

+ 1 - 0
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

+ 39 - 0
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 <[email protected]>
+ */
+
+#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;
+}