[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:
23
platform/lpc15xx/lpccheck.py
Executable file
23
platform/lpc15xx/lpccheck.py
Executable 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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user