forked from mirrors/qmk_firmware
Update LUFA (18-07-2021) and add QMK-HID Bootloader support (#13588)
Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
parent
a030950fd6
commit
71e9f8fc11
6 changed files with 81 additions and 10 deletions
|
@ -26,6 +26,7 @@
|
|||
# atmel-dfu Atmel factory DFU
|
||||
# lufa-dfu LUFA DFU
|
||||
# qmk-dfu QMK DFU (LUFA + blinkenlight)
|
||||
# qmk-hid QMK HID (LUFA + blinkenlight)
|
||||
# bootloadHID HIDBootFlash compatible (ATmega32A)
|
||||
# USBasp USBaspLoader (ATmega328P)
|
||||
# ARM:
|
||||
|
@ -67,6 +68,11 @@ ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
|
|||
BOOTLOADER_SIZE = 8192
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), qmk-hid)
|
||||
OPT_DEFS += -DBOOTLOADER_QMK_HID
|
||||
OPT_DEFS += -DBOOTLOADER_HID
|
||||
BOOTLOADER_SIZE = 4096
|
||||
endif
|
||||
ifeq ($(strip $(BOOTLOADER)), halfkay)
|
||||
OPT_DEFS += -DBOOTLOADER_HALFKAY
|
||||
ifeq ($(strip $(MCU)), atmega32u4)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
},
|
||||
"bootloader": {
|
||||
"type": "string",
|
||||
"enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"]
|
||||
"enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"]
|
||||
},
|
||||
"diode_direction": {
|
||||
"type": "string",
|
||||
|
|
|
@ -95,3 +95,4 @@ The device name here is the name that appears in Zadig, and may not be what the
|
|||
|`stm32-dfu` |STM32 BOOTLOADER |`0483:DF11` |WinUSB |
|
||||
|`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB |
|
||||
|`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB |
|
||||
|`qmk-hid` |(keyboard name) Bootloader |`03EB:2067` |HidUsb |
|
||||
|
|
|
@ -171,6 +171,52 @@ Flashing sequence:
|
|||
3. Flash a .hex file
|
||||
4. Reset the device into application mode (may be done automatically)
|
||||
|
||||
### QMK HID
|
||||
|
||||
QMK maintains [a fork of the LUFA HID bootloader](https://github.com/qmk/lufa/tree/master/Bootloaders/HID), which uses a USB HID Endpoint for flashing in the way that the PJRC's Teensy Loader flasher and HalfKay bootloader work. Additionally, it performs a simple matrix scan for exiting the bootloader and returning to the application, as well as flashing an LED/making a ticking noise with a speaker when things are happening.
|
||||
|
||||
To ensure compatibility with the QMK HID bootloader, make sure this block is present in your `rules.mk`:
|
||||
|
||||
```make
|
||||
# Bootloader selection
|
||||
BOOTLOADER = qmk-hid
|
||||
```
|
||||
|
||||
To enable the additional features, add the following defines to your `config.h`:
|
||||
|
||||
```c
|
||||
#define QMK_ESC_OUTPUT F1 // COL pin if COL2ROW
|
||||
#define QMK_ESC_INPUT D5 // ROW pin if COL2ROW
|
||||
// Optional:
|
||||
//#define QMK_LED E6
|
||||
//#define QMK_SPEAKER C6
|
||||
```
|
||||
|
||||
Currently we do not recommend making `QMK_ESC` the same key as the one designated for [Bootmagic Lite](feature_bootmagic.md#bootmagic-lite), as holding it down will cause the MCU to loop back and forth between entering and exiting the bootloader.
|
||||
|
||||
The manufacturer and product strings are automatically pulled from `config.h`, with " Bootloader" appended to the product string.
|
||||
|
||||
To generate this bootloader, use the `bootloader` target, eg. `make planck/rev4:default:bootloader`. To generate a production-ready .hex file (combining QMK and the bootloader), use the `production` target, eg. `make planck/rev4:default:production`.
|
||||
|
||||
Compatible flashers:
|
||||
|
||||
* TBD
|
||||
* Currently, you need to either use the [Python script](https://github.com/qmk/lufa/tree/master/Bootloaders/HID/HostLoaderApp_python), or compile [`hid_bootloader_cli`](https://github.com/qmk/lufa/tree/master/Bootloaders/HID/HostLoaderApp), from the LUFA repo. Homebrew may (will) have support for this directly (via `brew install qmk/qmk/hid_bootloader_cli`).
|
||||
|
||||
Flashing sequence:
|
||||
|
||||
1. Enter the bootloader using any of the following methods:
|
||||
* Press the `RESET` keycode
|
||||
* Press the `RESET` button on the PCB if available
|
||||
* short RST to GND quickly
|
||||
2. Wait for the OS to detect the device
|
||||
3. Flash a .hex file
|
||||
4. Reset the device into application mode (may be done automatically)
|
||||
|
||||
### `make` Targets
|
||||
|
||||
* `:qmk-hid`: Checks every 5 seconds until a DFU device is available, and then flashes the firmware.
|
||||
|
||||
## STM32/APM32 DFU
|
||||
|
||||
All STM32 and APM32 MCUs, except for F103 (see the [STM32duino section](#stm32duino)) come preloaded with a factory bootloader that cannot be modified nor deleted.
|
||||
|
|
2
lib/lufa
2
lib/lufa
|
@ -1 +1 @@
|
|||
Subproject commit ce10f7642b0459e409839b23cc91498945119b4d
|
||||
Subproject commit c7c5f659031ac8bae22623a2f8fe6a7c6f81b243
|
|
@ -237,6 +237,15 @@ endef
|
|||
bootloadHID: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
$(call EXEC_BOOTLOADHID)
|
||||
|
||||
HID_BOOTLOADER_CLI ?= hid_bootloader_cli
|
||||
|
||||
define EXEC_HID_LUFA
|
||||
$(HID_BOOTLOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
|
||||
endef
|
||||
|
||||
hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
$(call EXEC_HID_LUFA)
|
||||
|
||||
# Convert hex to bin.
|
||||
bin: $(BUILD_DIR)/$(TARGET).hex
|
||||
$(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
||||
|
@ -295,19 +304,26 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
|
|||
@$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof
|
||||
$(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof
|
||||
|
||||
bootloader:
|
||||
ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
|
||||
$(error Please set BOOTLOADER = qmk-dfu first!)
|
||||
ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
|
||||
QMK_BOOTLOADER_TYPE = DFU
|
||||
else ifeq ($(strip $(BOOTLOADER)), qmk-hid)
|
||||
QMK_BOOTLOADER_TYPE = HID
|
||||
endif
|
||||
make -C lib/lufa/Bootloaders/DFU/ clean
|
||||
$(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
|
||||
|
||||
bootloader:
|
||||
ifeq ($(strip $(QMK_BOOTLOADER_TYPE)),)
|
||||
$(error Please set BOOTLOADER to "qmk-dfu" or "qmk-hid" first!)
|
||||
else
|
||||
make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ clean
|
||||
$(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Keyboard.h
|
||||
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
|
||||
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
|
||||
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
|
||||
$(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
|
||||
make -C lib/lufa/Bootloaders/DFU/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB)
|
||||
printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n"
|
||||
cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex
|
||||
make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB)
|
||||
printf "Bootloader$(QMK_BOOTLOADER_TYPE).hex copied to $(TARGET)_bootloader.hex\n"
|
||||
cp lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Bootloader$(QMK_BOOTLOADER_TYPE).hex $(TARGET)_bootloader.hex
|
||||
endif
|
||||
|
||||
production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware
|
||||
@cat $(BUILD_DIR)/$(TARGET).hex | awk '/^:00000001FF/ == 0' > $(TARGET)_production.hex
|
||||
|
@ -328,6 +344,8 @@ else ifeq ($(strip $(BOOTLOADER)), USBasp)
|
|||
$(call EXEC_USBASP)
|
||||
else ifeq ($(strip $(BOOTLOADER)), bootloadHID)
|
||||
$(call EXEC_BOOTLOADHID)
|
||||
else ifeq ($(strip $(BOOTLOADER)), qmk-hid)
|
||||
$(call EXEC_HID_LUFA)
|
||||
else
|
||||
$(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)"
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue