Last active
September 20, 2025 09:26
-
-
Save ninp0/beeb3205a0a6cd0497d1593e7a0cbe49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash --login | |
| usage() { | |
| echo "USAGE: ${0} <QMK Keyboard> <QMK Keymap Name>" | |
| echo 'Example:' | |
| echo 'qmk list-keyboards | grep q9' | |
| echo "${0} keychron/q9/ansi_encoder default" | |
| exit 1 | |
| } | |
| if (( $# == 2 )); then | |
| keyboard="${1}" | |
| keymap="${2}" | |
| firmware_bin_path=(/opt/qmk_firmware/${keyboard//\//_}_${keymap}.bin) | |
| echo 'Pulling latest from https://github.com/qmk/qmk_firmware' | |
| cd /opt/qmk_firmware; git pull; qmk git-submodule; cd - | |
| echo -e "\n\n\nCompiling Keyboard Firmware: ${keyboard}" | |
| qmk compile --keyboard "${keyboard}" --keymap $keymap | |
| if [[ $? -eq 0 ]]; then | |
| echo -e "\n\n\nAnalyzing Keyboards in DFU Mode..." | |
| dfu-util --list | grep 'Found DFU' | |
| if [[ $? -ne 0 ]]; then | |
| echo -e "\n\n\nERROR: No keyboards found." | |
| echo 'Be sure the keyboard is in BOOTLOADER mode (QK_BOOT key).' | |
| exit 1 | |
| fi | |
| echo -en "\n\n\nEnter DFU Device ID from Listing Above (e.g. DEAD:BEEF): "; read dfu | |
| # Example DFU => 04AA:df22 | |
| echo -e "\nFlashing Keyboard Firmware: ${firmware_bin_path}" | |
| dfu-util \ | |
| --alt 0 \ | |
| --device $dfu \ | |
| --dfuse-address 0x08000000:leave \ | |
| --download $firmware_bin_path | |
| fi | |
| else | |
| usage | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment