[OpenWrt-Devel] [PATCH 1/2] tools/firmware-utils: Allow changing the CRC32 poly value in mkbrnimg

Martin Blumenstingl martin.blumenstingl at googlemail.com
Sun May 31 17:30:23 EDT 2015


VGV7519 is currently the only device with brnboot support. It seems to
be happy with 0x2083b8ed as CRC32 poly. However, VGV7510KW22 fails to
validate the checksum - it requires 0x04c11db7 instead.

I have built an brnboot image manually on the command line, once with
the old code and then with the new code but passing the old CRC32
poly value. Both resulted in a brnboot image with the same sha1sum.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl at googlemail.com>
---
 tools/firmware-utils/src/mkbrnimg.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/firmware-utils/src/mkbrnimg.c b/tools/firmware-utils/src/mkbrnimg.c
index fff92c4..fde30b2 100644
--- a/tools/firmware-utils/src/mkbrnimg.c
+++ b/tools/firmware-utils/src/mkbrnimg.c
@@ -32,9 +32,14 @@
 
 static uint32_t crc32[1<<BPB];
 
+static char *output_file = "default-brnImage";
+static uint32_t magic = 0x12345678;
+static char *signature = "BRNDTW502";
+static uint32_t crc32_poly = 0x2083b8ed;
+
 static void init_crc32()
 {
-	const uint32_t poly = ntohl(0x2083b8ed);
+	const uint32_t poly = ntohl(crc32_poly);
 	int n;
 
 	for (n = 0; n < 1<<BPB; n++) {
@@ -61,21 +66,17 @@ static void usage(const char *) __attribute__ (( __noreturn__ ));
 static void usage(const char *mess)
 {
 	fprintf(stderr, "Error: %s\n", mess);
-	fprintf(stderr, "Usage: mkbrnimg [-o output_file] [-m magic] [-s signature] kernel_file [additional files]\n");
+	fprintf(stderr, "Usage: mkbrnimg [-o output_file] [-m magic] [-s signature] [-p crc32 poly] kernel_file [additional files]\n");
 	fprintf(stderr, "\n");
 	exit(1);
 }
 
-static char *output_file = "default-brnImage";
-static uint32_t magic = 0x12345678;
-static char *signature = "BRNDTW502";
-
 static void parseopts(int *argc, char ***argv)
 {
 	char *endptr;
 	int res;
 
-	while ((res = getopt(*argc, *argv, "o:m:s:")) != -1) {
+	while ((res = getopt(*argc, *argv, "o:m:s:p:")) != -1) {
 		switch (res) {
 		default:
 			usage("Unknown option");
@@ -91,6 +92,11 @@ static void parseopts(int *argc, char ***argv)
 		case 's':
 			signature = optarg;
 			break;
+		case 'p':
+			crc32_poly = strtoul(optarg, &endptr, 0);
+			if (endptr == optarg || *endptr != 0)
+				usage("'crc32 poly' must be a decimal or hexadecimal 32-bit value");
+			break;
 		}
 	}
 	*argc -= optind;
-- 
2.4.2
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list