QMK Firmware Tutorial: Compiling & Flashing (Part 4)

QMK Firmware Tutorial: Compiling & Flashing (Part 4)

Part 4 of our journey through the basics of
QMK and we’re ready to start flashing. If you’re still struggling to get QMK set
up, then check out the other videos in the playlist. If you’ve been tweaking your layout and
have it to a point where you’re ready to try it out, then this is the episode you’ve been waiting
for. Make sure you’ve got a key that will send
the reset code so your keyboard can be flashed without you having to push the little button
on the pcb. The file that you flash needs to be compiled
before you can send it over to your keyboard. You can do the compiling and flashing separately
or in one go. I’ll show you how to do both. First, let’s assume you’re not ready to
flash your firmware to your keyboard, maybe you don’t actually have it yet, and
you’re just killing time until it arrives. Open up your MSYS2 terminal and navigate to
your qmk firmware folder. Note that you must be in this folder for things
to work as they should. The command for compiling your .hex file is
as follows. make:Make and then a space followed by the directory
name for your keyboard, then a colon followed by your keymap directory name. For the Satan GH60 and my layout it would
look like this: make satan:chokkan Which I’m really uncomfortable about typing
into a computer and even less so about saying out loud. If all goes well, you’ll find a .hex file
in the qmk_firmware directory. If it doesn’t, then you’ll need to take
a look at the error report for a hint as to how it messed up. I’d love to give tech support to everyone
that watches this video, but you’ll probably have better luck if you take a good look at
the error, which should include a line number and a message
telling you what the error was. If you want to compile the firmware and flash
your keyboard with one command, all you need to do is add one of the following
to the end of the previous command. If your keyboard is running ChibiOS on a Teensy
3 or a Teensy LC or something with an ARM processor, you need the :dfu-util command. If you’re using a Teensy 2, which many hand
wired keyboards do, then you type :teensy. If you’re using something with a Pro Micro
or one of it’s clones, you need :avrdude. If you’re not sure which option you need,
take a look in the readme for the keyboard and it should tell you. In most cases, and in the case of my Satan
GH60, :dfu is what you’ll use. Once you execute the command, you’ll need
to put your keyboard into flashing mode by pressing the button or hitting the key combination
you set up in your keymap. After that, the firmware will compile and
will be flashed to your device. It’s really a smooth process, and it’s
getting smoother all the time, but errors will crop up. Most of the time It’ll be your fault. Make sure brackets and braces are properly
closed. Watch out for typos in your keycodes. Use the find function in your text editor
to track them down. Next episode, we’ll dig into the rules and
config files and see what they do. See you then.

24 thoughts to “QMK Firmware Tutorial: Compiling & Flashing (Part 4)”

  1. Question. So I already have everything flashed, keyboard works, but I'm trying to add a KC_CAPS command on the adjust layer. Whenever I try to reset/flash the updated keymap, I just get this:

    Detected controller on USB port at /dev/ttyS2
    sh: line 14: avrdude: command not found
    make[1]: * [tmk_core/avr.mk:172: avrdude] Error 127
    Make finished with errors

    I'm running a Pro Micro on a Viterbi. If anyone could help, it'd be much appreciated.

  2. When I compile my keymap, the chibios error occurs. I solved it with this solution; https://github.com/qmk/qmk_firmware/issues/602
    Thanks for nice instructions, btw

  3. make: * No rule to make target 'kb:default'. Stop.

    edit : so apparently i forgot to paste my keymap folder :D:D:D, but another error appears :

    Making kb with keymap default

    /bin/sh: dfu-programmer: command not found
    /bin/sh: dfu-programmer: command not found
    /bin/sh: avr-gcc: command not found
    sh: avr-gcc: command not found
    sh: avr-gcc: command not found
    make[1]: * [tmk_core/rules.mk:243: gccversion] Error 127
    Make finished with errors
    make: * [Makefile:543: kb:default] Error 1

    i might have missed something while setting up the env. let me start over

  4. Hey Chokkan, do you have any tips about how to flash a pre-compiled .hex file? I feel like it's relatively simple but I just can't figure it out. Or even .bin files in the qmk_firmware directory? I've made a cool layout with an online graphical tool and trying to work out what command to run to flash the file.

  5. Hey, I'm a little late to the party, but I keep getting the avr-gcc command not found thing every time I try to make. Any insight on what I could possibly do?

  6. Detecting USB port, reset your controller now………..
    Detected controller on USB port at /dev/ttyS3
    Remapped MSYS2 USB port to COM4
    sh: line 19: /mingw64/bin/avrdude: cannot execute binary file: Exec format error
    make[1]: * [tmk_core/avr.mk:173: avrdude] Error 126
    Make finished with errors
    make: * [Makefile:544: atreus62:default:avrdude] Error 1

    Any help?

  7. Hey, Chokkan, just a thank you for this series of videos. Every time I want to tweak my Project Zen board, I come here to make sure I'm not messing anything up, haha. Much love from the rest of the RGBKB.net discord as well, as we've shared your videos countless times for new builders and experienced tweakers alike!

  8. I am having an odd issue. I try my firmware I get:

    make alt:default
    $ make alt:default:
    QMK Firmware 0.6.233

    make: * No rule to make target 'alt:defult:qmk_firmware'. Stop.


    | QMK's make format recently changed to use folder locations and colons:

    | make project_folder:keymap[:target]

    | Examples:

    | make planck/rev4:default:dfu

    | make planck:default

    But if I try: make satan:default it works just fine
    problem is that I don't have your keyboard or I would be in business. I am totally lost any help would be much appreciated

  9. To anyone else getting the "avr-gcc: command not found" error: I just ran util/msys2_install.sh again. Even though I definitely did tell it to install all the toolchains the first time, the second time it said that they were not installed. So it installed them and the error is now gone.

  10. Chokkan
    im trying to compile my files but a keymap_common ERROR keeps popping up and i cant find anything online… Can you help me ?

Leave a Reply

Your email address will not be published. Required fields are marked *