vial: add support for vibl bootloader and vfw package creation
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
.dep
|
.dep
|
||||||
*.o
|
*.o
|
||||||
*.bin
|
*.bin
|
||||||
|
*.vfw
|
||||||
*.eep
|
*.eep
|
||||||
*.elf
|
*.elf
|
||||||
*.hex
|
*.hex
|
||||||
|
@ -118,3 +118,9 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino)
|
|||||||
DFU_ARGS = -d 1EAF:0003 -a2 -R
|
DFU_ARGS = -d 1EAF:0003 -a2 -R
|
||||||
DFU_SUFFIX_ARGS = -v 1EAF -p 0003
|
DFU_SUFFIX_ARGS = -v 1EAF -p 0003
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(BOOTLOADER)), vibl)
|
||||||
|
DFU_ARGS =
|
||||||
|
DFU_SUFFIX_ARGS =
|
||||||
|
VIBL = 1
|
||||||
|
endif
|
||||||
|
@ -293,6 +293,9 @@ gccversion :
|
|||||||
$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\
|
$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\
|
||||||
fi
|
fi
|
||||||
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
|
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
|
||||||
|
if [ ! -z "$(VIBL)" ]; then \
|
||||||
|
python3 util/vial_generate_vfw.py $(TARGET).bin $(TARGET).vfw $(CONFIG_H) ;\
|
||||||
|
fi
|
||||||
|
|
||||||
BEGIN = gccversion sizebefore
|
BEGIN = gccversion sizebefore
|
||||||
|
|
||||||
|
49
util/vial_generate_vfw.py
Normal file
49
util/vial_generate_vfw.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import struct
|
||||||
|
import hashlib
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
inp = sys.argv[1]
|
||||||
|
out = sys.argv[2]
|
||||||
|
configs = sys.argv[3:]
|
||||||
|
|
||||||
|
# identify keyboard UID
|
||||||
|
uid = None
|
||||||
|
for config in configs:
|
||||||
|
with open(config, "r") as inf:
|
||||||
|
for line in inf:
|
||||||
|
uid = re.findall(r"#define.*VIAL_KEYBOARD_UID.*{(.*)}", line)
|
||||||
|
if uid:
|
||||||
|
break
|
||||||
|
if not uid:
|
||||||
|
print("Cannot identify keyboard UID from configuration files {}, ensure that you have VIAL_KEYBOARD_UID defined!".format(configs))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
uid = uid[0].split(",")
|
||||||
|
uid = [int(x, 16) for x in uid]
|
||||||
|
uid = struct.pack("BBBBBBBB", *uid)
|
||||||
|
|
||||||
|
# read firmware binary
|
||||||
|
with open(sys.argv[1], "rb") as inf:
|
||||||
|
firmware = inf.read()
|
||||||
|
|
||||||
|
with open(out, "wb") as outf:
|
||||||
|
outf.write(b"VIALFW00")
|
||||||
|
outf.write(uid)
|
||||||
|
outf.write(struct.pack("<Q", int(time.time())))
|
||||||
|
outf.write(b"\x00" * 8)
|
||||||
|
outf.write(hashlib.sha256(firmware).digest())
|
||||||
|
outf.write(firmware)
|
||||||
|
|
||||||
|
print("-" * 80)
|
||||||
|
print("Vial update package created at {}".format(out))
|
||||||
|
print("-" * 80)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
Reference in New Issue
Block a user