diff --git a/.gitignore b/.gitignore index 91d283e69b..2285d9ec20 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .dep *.o *.bin +*.vfw *.eep *.elf *.hex diff --git a/bootloader.mk b/bootloader.mk index ab1ced0ea4..0179863429 100644 --- a/bootloader.mk +++ b/bootloader.mk @@ -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 diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index a7053d185c..45b026e73b 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -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 diff --git a/util/vial_generate_vfw.py b/util/vial_generate_vfw.py new file mode 100644 index 0000000000..d4a713116f --- /dev/null +++ b/util/vial_generate_vfw.py @@ -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("