Skip to content

Commit

Permalink
Add flash target for UF2 bootloaders (qmk#16525)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlK90 authored and waffle87 committed Mar 23, 2022
1 parent 788326e commit 7bddcb8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docs/flashing.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,14 @@ Flashing sequence:
2. Wait for the OS to detect the device
3. Copy the .uf2 file to the new USB disk
4. Wait for the keyboard to become available

or

CLI Flashing sequence:

1. Enter the bootloader using any of the following methods:
* Tap the `RESET` keycode
* Double-tap the `nRST` button on the PCB.
2. Wait for the OS to detect the device
3. Flash via QMK CLI eg. `qmk flash --keyboard handwired/onekey/blackpill_f411_tinyuf2 --keymap default`
4. Wait for the keyboard to become available
14 changes: 14 additions & 0 deletions platforms/chibios/flash.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ endef
dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
$(call EXEC_DFU_UTIL)

define EXEC_UF2_UTIL_DEPLOY
if ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; then \
printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
sleep $(BOOTLOADER_RETRY_TIME) ;\
while ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; do \
printf "." ;\
sleep $(BOOTLOADER_RETRY_TIME) ;\
done ;\
printf "\n" ;\
fi
endef

# TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
# within the emulated eeprom via dfu-util or another tool
ifneq (,$(filter $(MAKECMDGOALS),dfu-util-split-left))
Expand Down Expand Up @@ -90,6 +102,8 @@ ifneq ($(strip $(PROGRAM_CMD)),)
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
else ifeq ($(strip $(BOOTLOADER)),kiibohd)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL)
else ifeq ($(strip $(BOOTLOADER)),tinyuf2)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_UF2_UTIL_DEPLOY)
else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY)
else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062)
Expand Down
2 changes: 1 addition & 1 deletion util/uf2conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def load_families():
def main():
global appstartaddr, familyid
def error(msg):
print(msg)
print(msg, file=sys.stderr)
sys.exit(1)
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
Expand Down

0 comments on commit 7bddcb8

Please sign in to comment.