diff options
| -rw-r--r-- | bootloader.mk | 6 | ||||
| -rw-r--r-- | data/schemas/keyboard.jsonschema | 2 | ||||
| -rw-r--r-- | docs/driver_installation_zadig.md | 1 | ||||
| -rw-r--r-- | docs/flashing.md | 46 | ||||
| m--------- | lib/lufa | 0 | ||||
| -rw-r--r-- | tmk_core/avr.mk | 34 |
6 files changed, 80 insertions, 9 deletions
diff --git a/bootloader.mk b/bootloader.mk index 4f2d69d99..abdfd20fd 100644 --- a/bootloader.mk +++ b/bootloader.mk | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | # atmel-dfu Atmel factory DFU | 26 | # atmel-dfu Atmel factory DFU |
| 27 | # lufa-dfu LUFA DFU | 27 | # lufa-dfu LUFA DFU |
| 28 | # qmk-dfu QMK DFU (LUFA + blinkenlight) | 28 | # qmk-dfu QMK DFU (LUFA + blinkenlight) |
| 29 | # qmk-hid QMK HID (LUFA + blinkenlight) | ||
| 29 | # bootloadHID HIDBootFlash compatible (ATmega32A) | 30 | # bootloadHID HIDBootFlash compatible (ATmega32A) |
| 30 | # USBasp USBaspLoader (ATmega328P) | 31 | # USBasp USBaspLoader (ATmega328P) |
| 31 | # ARM: | 32 | # ARM: |
| @@ -67,6 +68,11 @@ ifeq ($(strip $(BOOTLOADER)), qmk-dfu) | |||
| 67 | BOOTLOADER_SIZE = 8192 | 68 | BOOTLOADER_SIZE = 8192 |
| 68 | endif | 69 | endif |
| 69 | endif | 70 | endif |
| 71 | ifeq ($(strip $(BOOTLOADER)), qmk-hid) | ||
| 72 | OPT_DEFS += -DBOOTLOADER_QMK_HID | ||
| 73 | OPT_DEFS += -DBOOTLOADER_HID | ||
| 74 | BOOTLOADER_SIZE = 4096 | ||
| 75 | endif | ||
| 70 | ifeq ($(strip $(BOOTLOADER)), halfkay) | 76 | ifeq ($(strip $(BOOTLOADER)), halfkay) |
| 71 | OPT_DEFS += -DBOOTLOADER_HALFKAY | 77 | OPT_DEFS += -DBOOTLOADER_HALFKAY |
| 72 | ifeq ($(strip $(MCU)), atmega32u4) | 78 | ifeq ($(strip $(MCU)), atmega32u4) |
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 3a77b2067..6ac2c7c60 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | }, | 22 | }, |
| 23 | "bootloader": { | 23 | "bootloader": { |
| 24 | "type": "string", | 24 | "type": "string", |
| 25 | "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"] | 25 | "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"] |
| 26 | }, | 26 | }, |
| 27 | "diode_direction": { | 27 | "diode_direction": { |
| 28 | "type": "string", | 28 | "type": "string", |
diff --git a/docs/driver_installation_zadig.md b/docs/driver_installation_zadig.md index fd5d3e92f..e4db069f1 100644 --- a/docs/driver_installation_zadig.md +++ b/docs/driver_installation_zadig.md | |||
| @@ -95,3 +95,4 @@ The device name here is the name that appears in Zadig, and may not be what the | |||
| 95 | |`stm32-dfu` |STM32 BOOTLOADER |`0483:DF11` |WinUSB | | 95 | |`stm32-dfu` |STM32 BOOTLOADER |`0483:DF11` |WinUSB | |
| 96 | |`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB | | 96 | |`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB | |
| 97 | |`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB | | 97 | |`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB | |
| 98 | |`qmk-hid` |(keyboard name) Bootloader |`03EB:2067` |HidUsb | | ||
diff --git a/docs/flashing.md b/docs/flashing.md index 83c97444e..da3c64c4a 100644 --- a/docs/flashing.md +++ b/docs/flashing.md | |||
| @@ -171,6 +171,52 @@ Flashing sequence: | |||
| 171 | 3. Flash a .hex file | 171 | 3. Flash a .hex file |
| 172 | 4. Reset the device into application mode (may be done automatically) | 172 | 4. Reset the device into application mode (may be done automatically) |
| 173 | 173 | ||
| 174 | ### QMK HID | ||
| 175 | |||
| 176 | 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. | ||
| 177 | |||
| 178 | To ensure compatibility with the QMK HID bootloader, make sure this block is present in your `rules.mk`: | ||
| 179 | |||
| 180 | ```make | ||
| 181 | # Bootloader selection | ||
| 182 | BOOTLOADER = qmk-hid | ||
| 183 | ``` | ||
| 184 | |||
| 185 | To enable the additional features, add the following defines to your `config.h`: | ||
| 186 | |||
| 187 | ```c | ||
| 188 | #define QMK_ESC_OUTPUT F1 // COL pin if COL2ROW | ||
| 189 | #define QMK_ESC_INPUT D5 // ROW pin if COL2ROW | ||
| 190 | // Optional: | ||
| 191 | //#define QMK_LED E6 | ||
| 192 | //#define QMK_SPEAKER C6 | ||
| 193 | ``` | ||
| 194 | |||
| 195 | 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. | ||
| 196 | |||
| 197 | The manufacturer and product strings are automatically pulled from `config.h`, with " Bootloader" appended to the product string. | ||
| 198 | |||
| 199 | 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`. | ||
| 200 | |||
| 201 | Compatible flashers: | ||
| 202 | |||
| 203 | * TBD | ||
| 204 | * 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`). | ||
| 205 | |||
| 206 | Flashing sequence: | ||
| 207 | |||
| 208 | 1. Enter the bootloader using any of the following methods: | ||
| 209 | * Press the `RESET` keycode | ||
| 210 | * Press the `RESET` button on the PCB if available | ||
| 211 | * short RST to GND quickly | ||
| 212 | 2. Wait for the OS to detect the device | ||
| 213 | 3. Flash a .hex file | ||
| 214 | 4. Reset the device into application mode (may be done automatically) | ||
| 215 | |||
| 216 | ### `make` Targets | ||
| 217 | |||
| 218 | * `:qmk-hid`: Checks every 5 seconds until a DFU device is available, and then flashes the firmware. | ||
| 219 | |||
| 174 | ## STM32/APM32 DFU | 220 | ## STM32/APM32 DFU |
| 175 | 221 | ||
| 176 | 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. | 222 | 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. |
diff --git a/lib/lufa b/lib/lufa | |||
| Subproject ce10f7642b0459e409839b23cc91498945119b4 | Subproject c7c5f659031ac8bae22623a2f8fe6a7c6f81b24 | ||
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index 2efde2212..d942e7ade 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk | |||
| @@ -237,6 +237,15 @@ endef | |||
| 237 | bootloadHID: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware | 237 | bootloadHID: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware |
| 238 | $(call EXEC_BOOTLOADHID) | 238 | $(call EXEC_BOOTLOADHID) |
| 239 | 239 | ||
| 240 | HID_BOOTLOADER_CLI ?= hid_bootloader_cli | ||
| 241 | |||
| 242 | define EXEC_HID_LUFA | ||
| 243 | $(HID_BOOTLOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex | ||
| 244 | endef | ||
| 245 | |||
| 246 | hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware | ||
| 247 | $(call EXEC_HID_LUFA) | ||
| 248 | |||
| 240 | # Convert hex to bin. | 249 | # Convert hex to bin. |
| 241 | bin: $(BUILD_DIR)/$(TARGET).hex | 250 | bin: $(BUILD_DIR)/$(TARGET).hex |
| 242 | $(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin | 251 | $(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
| @@ -295,19 +304,26 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf | |||
| 295 | @$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof | 304 | @$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof |
| 296 | $(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof | 305 | $(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof |
| 297 | 306 | ||
| 298 | bootloader: | 307 | ifeq ($(strip $(BOOTLOADER)), qmk-dfu) |
| 299 | ifneq ($(strip $(BOOTLOADER)), qmk-dfu) | 308 | QMK_BOOTLOADER_TYPE = DFU |
| 300 | $(error Please set BOOTLOADER = qmk-dfu first!) | 309 | else ifeq ($(strip $(BOOTLOADER)), qmk-hid) |
| 310 | QMK_BOOTLOADER_TYPE = HID | ||
| 301 | endif | 311 | endif |
| 302 | make -C lib/lufa/Bootloaders/DFU/ clean | 312 | |
| 303 | $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h | 313 | bootloader: |
| 314 | ifeq ($(strip $(QMK_BOOTLOADER_TYPE)),) | ||
| 315 | $(error Please set BOOTLOADER to "qmk-dfu" or "qmk-hid" first!) | ||
| 316 | else | ||
| 317 | make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ clean | ||
| 318 | $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Keyboard.h | ||
| 304 | $(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)) | 319 | $(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)) |
| 305 | $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) | 320 | $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) |
| 306 | $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) | 321 | $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) |
| 307 | $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) | 322 | $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) |
| 308 | 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) | 323 | 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) |
| 309 | printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n" | 324 | printf "Bootloader$(QMK_BOOTLOADER_TYPE).hex copied to $(TARGET)_bootloader.hex\n" |
| 310 | cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex | 325 | cp lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Bootloader$(QMK_BOOTLOADER_TYPE).hex $(TARGET)_bootloader.hex |
| 326 | endif | ||
| 311 | 327 | ||
| 312 | production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware | 328 | production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware |
| 313 | @cat $(BUILD_DIR)/$(TARGET).hex | awk '/^:00000001FF/ == 0' > $(TARGET)_production.hex | 329 | @cat $(BUILD_DIR)/$(TARGET).hex | awk '/^:00000001FF/ == 0' > $(TARGET)_production.hex |
| @@ -328,6 +344,8 @@ else ifeq ($(strip $(BOOTLOADER)), USBasp) | |||
| 328 | $(call EXEC_USBASP) | 344 | $(call EXEC_USBASP) |
| 329 | else ifeq ($(strip $(BOOTLOADER)), bootloadHID) | 345 | else ifeq ($(strip $(BOOTLOADER)), bootloadHID) |
| 330 | $(call EXEC_BOOTLOADHID) | 346 | $(call EXEC_BOOTLOADHID) |
| 347 | else ifeq ($(strip $(BOOTLOADER)), qmk-hid) | ||
| 348 | $(call EXEC_HID_LUFA) | ||
| 331 | else | 349 | else |
| 332 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" | 350 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" |
| 333 | endif | 351 | endif |
