different loaders using the GNU objcopy program. This option
should not be selected if you are not using the GNU toolchain.
+config SAMSUNG_NS2
+ bool "Samsung NS2 binary format"
+ select RAW_BINARY
+ default n
+ ---help---
+ Create the tinyara.head.bin from the raw binary, putting
+ a checksum value into it. It is used with S5J boot loaders,
+ which check the integrity of the binary using SHA256 at boot.
+
menuconfig UBOOT_UIMAGE
bool "U-Boot uImage"
select RAW_BINARY
@echo "CP: $(BIN_EXE).bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(BIN).bin
endif
+ifeq ($(CONFIG_SAMSUNG_NS2),y)
+ @echo "ATTACHNS2: $(BIN).bin --> $(BIN).head.bin"
+ $(Q) tools/s5jchksum.py $(BIN).bin $(BIN).head.bin
+endif
ifeq ($(CONFIG_UBOOT_UIMAGE),y)
@echo "MKIMAGE: uImage"
$(Q) mkimage -A arm -O linux -C none -T kernel -a $(CONFIG_UIMAGE_LOAD_ADDRESS) \
@echo "CP: $(BIN_EXE).bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(BIN).bin
endif
+ifeq ($(CONFIG_SAMSUNG_NS2),y)
+ @echo "ATTACHNS2: $(BIN) --> $(BIN).head.bin"
+ $(Q) tools/s5jchksum.py $(BIN).bin $(BIN).head.bin
+endif
# $(BIN)
#
--- /dev/null
+#!/usr/bin/python
+
+import os
+import sys
+import hashlib
+
+inputfile = sys.argv[1]
+outputfile = sys.argv[2]
+
+header = 32
+tail = 272
+
+with open(inputfile, 'rb') as fin, open(outputfile, 'wb') as fout:
+ data = fin.read()
+ fout.write(data)
+
+ size = fin.tell()
+ fin.seek(header, 0)
+ size -= (header + tail)
+
+ data = fin.read(size)
+ h = hashlib.sha256(data);
+ digest = h.digest()[:4]
+
+ fout.seek(4, 0)
+ fout.write(digest)