]> git.donarmstrong.com Git - qmk_firmware.git/blob - QMK-Overview.md
Document the MAGIC keys
[qmk_firmware.git] / QMK-Overview.md
1 # QMK Overview
2
3 This page attempts to explain the basic information you need to know to work with the QMK project. It assumes that you are familiar with navigating a UNIX shell, but does not assume you are familiar with C or with compiling using make.
4
5 # Basic QMK structure
6
7 QMK is a fork of @tmk's [tmk_keyboard](https://github.com/tmk/tmk_keyboard) project. The original TMK code, with modifications, can be found in the `tmk` folder. The QMK additions to the project may be found in the `quantum` folder. Keyboard projects may be found in the `handwired` and `keyboard` folders.
8
9 ## Keyboard project structure
10
11 Within the `handwired` and `keyboard` folders is a directory for each keyboard project, for example `qmk_firmware/keyboards/clueboard`. Within you'll find the following structure:
12
13 * `keymaps/`: Different keymaps that can be built
14 * `rules.mk`: The file that sets the default "make" options. Do not edit this file directly, instead use a keymap specific `Makefile`.
15 * `config.h`: The file that sets the default compile time options. Do not edit this file directly, instead use a keymap specific `config.h`.
16
17 ### Keymap structure
18
19 In every keymap folder, the following files may be found. Only `keymap.c` is required, if the rest of the files are not found the default options will be chosen.
20
21 * `config.h`: the options to configure your keymap
22 * `keymap.c`: all of your keymap code, required
23 * `Makefile`: the features of QMK that are enabled, required to run `make` in your keymap folder
24 * `readme.md`: a description of your keymap, how others might use it, and explanations of features
25 * Other files: Some people choose to include an image depicting the layout, and other files that help people to use or understand a particular keymap.
26
27 # The `make` command
28
29 The `make` command is how you compile the firmware into a .hex file, which can be loaded by a dfu programmer (like dfu-progammer via `make dfu`) or the [Teensy loader](https://www.pjrc.com/teensy/loader.html) (only used with Teensys). It it recommended that you always run make from within the `root` folder.
30
31 **NOTE:** To abort a make command press `Ctrl-c`
32
33 For more details on the QMK build process see [Make Instructions](Make-Instructions).
34
35 ### Simple instructions for building and uploading a keyboard
36
37 **Most keyboards have more specific instructions in the keyboard specific readme.md file, so please check that first**
38
39 1. Enter the `root` folder
40 2. Run `make <keyboard>-<subproject>-<keymap>-<programmer>`
41
42 In the above commands, replace:
43
44 * `<keyboard>` with the name of your keyboard
45 * `<keymap>` with the name of your keymap
46 * `<subproject>` with the name of the subproject (revision or sub-model of your keyboard). For example, for Ergodox it can be `ez` or `infinity`, and for Planck `rev3` or `rev4`.
47   * If the keyboard doesn't have a subproject, or if you are happy with the default (defined in `rules.mk` file of the `keyboard` folder), you can leave it out. But remember to also remove the dash (`-`) from the command.
48 * `<programmer>` The programmer to use. Most keyboards use `dfu`, but some use `teensy`. Infinity keyboards use `dfu-util`. Check the readme file in the keyboard folder to find out which programmer to use.
49   * If you  don't add `-<programmer` to the command line, the firmware will be still be compiled into a hex file, but the upload will be skipped.
50
51 **NOTE:** Some operating systems will refuse to program unless you run the make command as root for example `sudo make clueboard-default-dfu`
52
53 ## Make Examples
54
55 * Build all Clueboard keymaps: `make clueboard`
56 * Build the default Planck keymap: `make planck-rev4-default`
57 * Build and flash your ergodox-ez: `make ergodox-ez-default-teensy`
58
59 # The `config.h` file
60
61 There are 2 `config.h` locations:
62
63 * keyboard (`/keyboards/<keyboard>/`)
64 * keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`)
65
66 The keyboard `config.h` is included only if the keymap one doesn't exist. The format to use for your custom one [is here](/doc/keymap_config_h_example.h). If you want to override a setting from the parent `config.h` file, you need to do this:
67
68 ```c
69 #undef MY_SETTING
70 #define MY_SETTING 4
71 ```
72
73 For a value of `4` for this imaginary setting. So we `undef` it first, then `define` it.
74
75 You can then override any settings, rather than having to copy and paste the whole thing.