Skip to content

Commit

Permalink
Merge pull request #79 from bgermann/makefile_signing
Browse files Browse the repository at this point in the history
Add checksum support in Makefile
  • Loading branch information
pzanna authored Aug 1, 2017
2 parents 3e983a9 + 446778c commit 1773a53
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ZodiacFX/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ LD = $(ARMGCC)ld
OBJCOPY = $(ARMGCC)objcopy
OBJDUMP = $(ARMGCC)objdump
SIZE = $(ARMGCC)size
PERL = perl

PROJECT=ZodiacFX

Expand Down Expand Up @@ -268,8 +269,19 @@ CPPASINC += -I./src/ASF/sam/drivers/afec
# ARM/GNU Archiver
ARFLAGS += -r

# Use perl for the checksum as shells have difficulties with NUL bytes.
checksum = $(PERL) -e '\
open(my $$fh, "+<:raw", "$1");\
my $$csum = do {\
local $$/;\
unpack("%32W*", readline($$fh));\
};\
print $$fh pack("V", $$csum) . "\x00\x00\x00\x00";\
close($$fh)'

%.bin: %.elf
$(OBJCOPY) --output-target binary $< $@
$(call checksum,$@)
$(SIZE) $<

# This is I/O bound, so let's compress it to tradeoff CPU for I/O
Expand Down

0 comments on commit 1773a53

Please sign in to comment.