diff options
author | Nick Brassel <nick@tzarc.org> | 2021-04-06 16:39:15 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 16:39:15 +1000 |
commit | 64a0f5a659190518a9361e0bd2e8caff0b3354f1 (patch) | |
tree | 845c9c7546d2054b7abb3bf773b13306d9118db1 /tmk_core | |
parent | 3ce8c9fc8feedd8e92ebb81a5ba1e5b18834e6f3 (diff) |
Add support for producing UF2-format binaries. (#12435)
* First stab at enabling builds of UF2-format binaries.
* Add description on producing a UF2 file.
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/rules.mk | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index bbcfc1e4d1..8dbed35fb5 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -223,6 +223,12 @@ ifneq ($(filter Darwin FreeBSD,$(shell uname -s)),) MD5SUM = md5 endif +# UF2 format settings +# To produce a UF2 file in your build, add to your keyboard's rules.mk: +# FIRMWARE_FORMAT = uf2 +UF2CONV = $(TOP_DIR)/util/uf2conv.py +UF2_FAMILY ?= 0x0 + # Compiler flags to generate dependency files. #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d GENDEPFLAGS = -MMD -MP -MF $(patsubst %.o,%.td,$@) @@ -255,6 +261,7 @@ DFU_SUFFIX_ARGS ?= elf: $(BUILD_DIR)/$(TARGET).elf hex: $(BUILD_DIR)/$(TARGET).hex +uf2: $(BUILD_DIR)/$(TARGET).uf2 cpfirmware: $(FIRMWARE_FORMAT) $(SILENT) || printf "Copying $(TARGET).$(FIRMWARE_FORMAT) to qmk_firmware folder" | $(AWK_CMD) $(COPY) $(BUILD_DIR)/$(TARGET).$(FIRMWARE_FORMAT) $(TARGET).$(FIRMWARE_FORMAT) && $(PRINT_OK) @@ -283,32 +290,44 @@ gccversion : # Create final output files (.hex, .eep) from ELF output file. %.hex: %.elf - @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD) $(eval CMD=$(HEX) $< $@) + #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n" + @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD) + @$(BUILD_CMD) + +%.uf2: %.hex + $(eval CMD=$(UF2CONV) $(BUILD_DIR)/$(TARGET).hex -o $(BUILD_DIR)/$(TARGET).uf2 -c -f $(UF2_FAMILY) >/dev/null 2>&1) + #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n" + @$(SILENT) || printf "$(MSG_UF2) $@" | $(AWK_CMD) @$(BUILD_CMD) %.eep: %.elf - @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD) $(eval CMD=$(EEP) $< $@ || exit 0) + #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n" + @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD) @$(BUILD_CMD) # Create extended listing file from ELF output file. %.lss: %.elf - @$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD) $(eval CMD=$(OBJDUMP) -h -S -z $< > $@) + #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n" + @$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD) @$(BUILD_CMD) # Create a symbol table from ELF output file. %.sym: %.elf - @$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD) $(eval CMD=$(NM) -n $< > $@ ) + #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n" + @$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD) @$(BUILD_CMD) %.bin: %.elf - @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD) $(eval CMD=$(BIN) $< $@ || exit 0) + #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n" + @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD) @$(BUILD_CMD) if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \ + #$(SILENT) || printf "$(MSG_EXECUTING) '$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null':\n" ;\ $(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\ fi $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; @@ -476,7 +495,7 @@ $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null))) # Listing of phony targets. .PHONY : all dump_vars finish sizebefore sizeafter qmkversion \ -gccversion build elf hex eep lss sym coff extcoff \ +gccversion build elf hex uf2 eep lss sym coff extcoff \ clean clean_list debug gdb-config show_path \ program teensy dfu dfu-ee dfu-start \ flash dfu-split-left dfu-split-right \ |