vial: add support for vibl bootloader and vfw package creation
This commit is contained in:
parent
6d9ad020fc
commit
77ddf078f5
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
.dep
|
||||
*.o
|
||||
*.bin
|
||||
*.vfw
|
||||
*.eep
|
||||
*.elf
|
||||
*.hex
|
||||
|
@ -118,3 +118,9 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino)
|
||||
DFU_ARGS = -d 1EAF:0003 -a2 -R
|
||||
DFU_SUFFIX_ARGS = -v 1EAF -p 0003
|
||||
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 ;\
|
||||
fi
|
||||
$(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
|
||||
|
||||
|
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())
|
Loading…
Reference in New Issue
Block a user