[platform][lpc15xx] add script and code to sign lk.bin

LPC wants you to stuff a checksum in the 8th vector slot.
This commit is contained in:
Travis Geiselbrecht
2014-03-15 20:31:01 -07:00
parent 7223cd305a
commit a5f45fb2a0
2 changed files with 35 additions and 0 deletions

23
platform/lpc15xx/lpccheck.py Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python
import sys, os, struct
if len(sys.argv) < 2:
print "not enough args, usage:"
print "%s <binfile>" % sys.argv[0]
sys.exit(1)
f = open(sys.argv[1], "r+b")
a = struct.unpack('iiiiiii', f.read(7*4))
s = 0
for i in a:
s += i
s = -s
f.seek(7*4)
f.write(struct.pack('i', s))
f.close()

View File

@@ -54,4 +54,16 @@ MODULE_DEPS += \
platform/lpc15xx/lpcopen \
lib/cbuf
LPCSIGNEDBIN := $(OUTBIN).sign
LPCCHECK := $(LOCAL_DIR)/lpccheck.py
EXTRA_BUILDDEPS += $(LPCSIGNEDBIN)
GENERATED += $(LPCSIGNEDBIN)
$(LPCSIGNEDBIN): $(OUTBIN) $(LPCCHECK)
@$(MKDIR)
$(NOECHO)echo generating $@; \
cp $< $@.tmp; \
$(LPCCHECK) $@.tmp; \
mv $@.tmp $@
include make/module.mk