diff options
author | Adrian Reber <adrian@lisas.de> | 2016-06-15 10:29:55 +0200 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-07-27 15:56:26 +1000 |
commit | 9177b7e84b0af3e6a10a6444d72ead82b72c001f (patch) | |
tree | 4dbf6d3d39ff12e0eeee9efcea5f3ba619dffe5f /tools | |
parent | 54f14f328b311537bd53df505aa61cc7c7c86d48 (diff) | |
download | SLOF-9177b7e84b0af3e6a10a6444d72ead82b72c001f.zip SLOF-9177b7e84b0af3e6a10a6444d72ead82b72c001f.tar.gz SLOF-9177b7e84b0af3e6a10a6444d72ead82b72c001f.tar.bz2 |
tools: use crc checking code from romfs/tools
Added CRC check of the header and complete image
when dumping the header.
(cherry picked from commit 645bc2cbd550829d43b460663b998b9d4685a2d2)
Cherry picked from https://lisas.de/~adrian/slof/slof.git/
Signed-off-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile | 6 | ||||
-rw-r--r-- | tools/sloffs.c | 18 |
2 files changed, 21 insertions, 3 deletions
diff --git a/tools/Makefile b/tools/Makefile index a035960..6da2e17 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -13,16 +13,20 @@ include ../make.rules TARGETS = gen_reloc_table sloffs +HOSTCFLAGS += -I../romfs/tools all: $(TARGETS) +crclib.o: ../romfs/tools/crclib.c + $(HOSTCC) -W $(HOSTCFLAGS) -c $^ -o $@ + %.o: %.c $(HOSTCC) -W $(HOSTCFLAGS) -c $^ gen_reloc_table: gen_reloc_table.o $(HOSTCC) $(HOSTCFLAGS) -o $@ $^ -sloffs: sloffs.o +sloffs: sloffs.o crclib.o $(HOSTCC) $(HOSTCFLAGS) -o $@ $^ clean_here: diff --git a/tools/sloffs.c b/tools/sloffs.c index 4b9ba5e..4ec5d56 100644 --- a/tools/sloffs.c +++ b/tools/sloffs.c @@ -23,6 +23,7 @@ #include <getopt.h> #include <calculatecrc.h> +#include <crclib.h> #define VERSION 1 @@ -139,11 +140,24 @@ sloffs_dump(const void *data) printf(" (0x%lx) bytes\n", be64_to_cpu(header->flashlen)); printf(" Revision : %s\n", header->platform_revision); crc = be64_to_cpu(header->ui64CRC); - printf(" Header CRC : 0x%016lx\n", crc); + printf(" Header CRC : 0x%016lx CRC check: ", crc); + crc = calCRCword((unsigned char *)data, be64_to_cpu(sloffs->len), 0); + if (!crc) + printf("[OK]"); + else + printf("[FAILED]"); + printf("\n"); + crc = be64_to_cpu(header->flashlen); crc = *(uint64_t *)(unsigned char *)(data + crc - 8); crc = be64_to_cpu(crc); - printf(" Image CRC : 0x%016lx\n", crc); + printf(" Image CRC : 0x%016lx CRC check: ", crc); + crc = calCRCword((unsigned char *)data, be64_to_cpu(header->flashlen), 0); + if (!crc) + printf("[OK]"); + else + printf("[FAILED]"); + printf("\n"); /* count number of files */ sloffs = (struct sloffs *)data; |