summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorNicolas Schodet2013-05-01 12:30:06 +0200
committerNicolas Schodet2019-10-07 00:01:14 +0200
commitb248612634e76d1537f275e1b125f488b263df45 (patch)
tree44e152e996e4072e8dfd82a813d46b5e2871ccc8 /build
parent996aca5612de78239a01f52bc79d75a5e403d5c7 (diff)
build: compute CRC32 when building a .bin
Diffstat (limited to 'build')
-rw-r--r--build/arch.mk8
-rwxr-xr-xbuild/tools/crc13
-rw-r--r--build/top.mk3
3 files changed, 21 insertions, 3 deletions
diff --git a/build/arch.mk b/build/arch.mk
index 62f0687..99f0c5f 100644
--- a/build/arch.mk
+++ b/build/arch.mk
@@ -88,16 +88,17 @@ define arch_bin_rules
hex: hex.$1
srec: srec.$1
bin: bin.$1
+crc: crc.$1
all.$1: hex.$1
ifneq ($$(wildcard *.$1.srec),)
all.$1: srec.$1
endif
ifneq ($$(wildcard *.$1.bin),)
-all.$1: bin.$1
+all.$1: bin.$1 crc.$1
endif
-.PHONY: hex.$1 srec.$1 bin.$1
+.PHONY: hex.$1 srec.$1 bin.$1 crc.$1
hex.$1: $$($1_PROGS:%=%.$1.hex)
srec.$1: $$($1_PROGS:%=%.$1.srec)
@@ -113,6 +114,9 @@ bin.$1: $$($1_PROGS:%=%.$1.bin)
@echo "BIN [$1] $$@"
$$Q$$($1_OBJCOPY) -O binary $$< $$@
+crc.$1: $$($1_PROGS:%=%.$1.bin)
+ $Q$$(BASE)/build/tools/crc $$^
+
$1_EXTRA_CLEAN += $$($1_PROGS:%=%.$1.hex) \
$$($1_PROGS:%=%.$1.srec) \
$$($1_PROGS:%=%.$1.bin)
diff --git a/build/tools/crc b/build/tools/crc
new file mode 100755
index 0000000..cb85a7f
--- /dev/null
+++ b/build/tools/crc
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+"""Output CRC32 of files."""
+import optparse
+import zlib
+
+parser = optparse.OptionParser(usage='%prog [options] files...')
+options, args = parser.parse_args()
+
+for f in args:
+ with open(f) as fd:
+ content = fd.read()
+ crc = zlib.crc32(content) & 0xffffffff
+ print '%08x %s' % (crc, f)
diff --git a/build/top.mk b/build/top.mk
index d4f53fe..5d87aa6 100644
--- a/build/top.mk
+++ b/build/top.mk
@@ -33,11 +33,12 @@ size:
hex:
srec:
bin:
+crc:
clean:
rmdir $(OBJDIR) 2> /dev/null || true
-.PHONY: all lst size hex srec bin clean
+.PHONY: all lst size hex srec bin crc clean
# Modules and sources setup.