aboutsummaryrefslogtreecommitdiff
path: root/readme.md
diff options
context:
space:
mode:
Diffstat (limited to 'readme.md')
-rw-r--r--readme.md102
1 files changed, 81 insertions, 21 deletions
diff --git a/readme.md b/readme.md
index b1808b6d1..f03c99bba 100644
--- a/readme.md
+++ b/readme.md
@@ -157,43 +157,103 @@ In every keymap folder, the following files are recommended:
157 157
158## The `make` command 158## The `make` command
159 159
160The `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). You can run `make` from the root (`/`), your keyboard folder (`/keyboards/<keyboard>/`), or your keymap folder (`/keyboards/<keyboard>/keymaps/<keymap>/`) if you have a `Makefile` there (see the example [here](/doc/keymap_makefile_example.mk)). 160The `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).
161 161
162By default, this will generate a `<keyboard>_<keymap>.hex` file in whichever folder you run `make` from. These files are ignored by git, so don't worry about deleting them when committing/creating pull requests. 162**NOTE:** To abort a make command press `Ctrl-c`
163 163
164Below are some definitions that will be useful: 164The following instruction refers to these folders.
165 165
166* The "root" (`/`) folder is the qmk_firmware folder, in which are `doc`, `keyboard`, `quantum`, etc. 166* The `root` (`/`) folder is the qmk_firmware folder, in which are `doc`, `keyboard`, `quantum`, etc.
167* The "keyboard" folder is any keyboard project's folder, like `/keyboards/planck`. 167* The `keyboard` folder is any keyboard project's folder, like `/keyboards/planck`.
168* The "keymap" folder is any keymap's folder, like `/keyboards/planck/keymaps/default`. 168* The `keymap` folder is any keymap's folder, like `/keyboards/planck/keymaps/default`.
169* The `subproject` folder is the subproject folder of a keyboard, like `/keyboards/ergodox/ez`
169 170
170Below is a list of the useful `make` commands in QMK: 171### Simple instructions for building and uploading a keyboard
171 172
172* `make` - builds your keyboard and keymap depending on which folder you're in. This defaults to the "default" layout (unless in a keymap folder), and Planck keyboard in the root folder 173**Most keyboards have more specific instructions in the keyboard specific readme.md file, so please check that first**
173 * `make keyboard=<keyboard>` - specifies the keyboard (only to be used in root) 174
174 * `make keymap=<keymap>` - specifies the keymap (only to be used in root and keyboard folder - not needed when in keymap folder) 175If the `keymap` folder contains a file name `Makefile`
175* `make clean` - cleans the `.build` folder, ensuring that everything is re-built 176
176* `make dfu` - (requires dfu-programmer) builds and flashes the keymap to your keyboard once placed in reset/dfu mode (button or press `KC_RESET`). This does not work for Teensy-based keyboards like the ErgoDox EZ. 1771. Change the directory to the `keymap` folder
177 * `keyboard=` and `keymap=` are compatible with this 1782. Run `make <subproject>-<programmer>`
178* `make all-keyboards` - builds all keymaps for all keyboards and outputs status of each (use in root) 179
179* `make all-keyboards-default` - builds all default keymaps for all keyboards and outputs status of each (use in root) 180Otherwise, if there's no `Makefile` in the `keymap` folder
180* `make all-keymaps [keyboard=<keyboard>]` - builds all of the keymaps for whatever keyboard folder you're in, or specified by `<keyboard>` 181
181* `make all-keyboards-*`, `make all-keyboards-default-*` and `make all-keymaps-* [keyboard=<keyboard>]` - like the normal "make-all-*" commands, but the last string aftter the `-` (for example clean) is passed to the keyboard make command. 1821. Enter the `keyboard` folder
182Other, less useful functionality: 1832. Run `make <subproject>-<keymap>-<programmer>`
184
185In the above commands, replace:
186
187* `<keymap>` with the name of your keymap
188* `<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`.
189 * 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.
190* `<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.
191 * 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.
192
193**NOTE:** Some operating systems will refuse to program unless you run the make command as root for example `sudo make dfu`
194
195### More detailed make instruction
196
197The full syntax of the `make` command is the following, but parts of the command can be left out if you run it from other directories than the `root` (as you might already have noticed by reading the simple instructions).
198
199`<keyboard>-<subproject>-<keymap>-<target>`, where:
200
201* `<keyboard>` is the name of the keyboard, for example `planck`
202 * Use `allkb` to compile all keyboards
203* `<subproject>` is the name of the subproject (revision or sub-model of the keyboard). For example, for Ergodox it can be `ez` or `infinity`, and for Planck `rev3` or `rev4`.
204 * If the keyboard doesn't have any subprojects, it can be left out
205 * To compile the default subproject, you can leave it out, or specify `defaultsp`
206 * Use `allsp` to compile all subprojects
207* `<keymap>` is the name of the keymap, for example `algernon`
208 * Use `allkm` to compile all keymaps
209* `<target>` will be explained in more detail below.
210
211**Note:** When you leave some parts of the command out, you should also remove the dash (`-`).
212
213As mentioned above, there are some shortcuts, when you are in a:
214
215* `keyboard` folder, the command will automatically fill the `<keyboard>` part. So you only need to type `<subproject>-<keymap>-<target>`
216* `subproject` folder, it will fill in both `<keyboard>` and `<subproject>`
217* `keymap` folder, then `<keyboard>` and `<keymap>` will be filled in. If you need to specify the `<subproject>` use the following syntax `<subproject>-<target>`
218 * Note in order to support this shortcut, the keymap needs its own Makefile (see the example [here](/doc/keymap_makefile_example.mk))
219* `keymap` folder of a `subproject`, then everything except the `<target>` will be filled in
220
221The `<target>` means the following
222* If no target is given, then it's the same as `all` below
223* `all` compiles the keyboard and generates a `<keyboard>_<keymap>.hex` file in whichever folder you run `make` from. These files are ignored by git, so don't worry about deleting them when committing/creating pull requests.
224* `dfu`, `teensy` or `dfu-util`, compile and upload the firmware to the keyboard. If the compilation fails, then nothing will be uploaded. The programmer to use depends on the keyboard. For most keyboards it's `dfu`, but for Infinity keyboards you should use `dfu-util`, and `teensy` for standard Teensys. To find out which command you should use for your keyboard, check the keyboard specific readme. **Note** that some operating systems needs root access for these commands to work, so in that case you need to run for example `sudo make dfu`.
225* `clean`, cleans the build output folders to make sure that everything is built from scratch. Run this before normal compilation if you have some unexplainable problems.
226
227Some other targets are supported but, but not important enough to be documented here. Check the source code of the make files for more information.
228
229You can also add extra options at the end of the make command line, after the target
183 230
184* `make COLOR=false` - turns off color output 231* `make COLOR=false` - turns off color output
185* `make SILENT=true` - turns off output besides errors/warnings 232* `make SILENT=true` - turns off output besides errors/warnings
186* `make VERBOSE=true` - outputs all of the avr-gcc stuff (not interesting) 233* `make VERBOSE=true` - outputs all of the gcc stuff (not interesting, unless you need to debug)
234
235The make command itself also has some additional options, type `make --help` for more information. The most useful is probably `-jx`, which specifies that you want to compile using more than one CPU, the `x` represents the number of CPUs that you want to use. Setting that can greatly reduce the compile times, especially if you are compiling many keyboards/keymaps. I usually set it to one less than the number of CPUs that I have, so that I have some left for doing other things while it's compiling. Note that not all operating systems and make versions supports that option.
236
237Here are some examples commands
238
239* `make allkb-allsp-allkm` builds everything (all keyboards, all subprojects, all keymaps). Running just `make` from the `root` will also run this.
240* `make` from within a `keyboard` directory, is the same as `make keyboard-allsp-allkm`, which compiles all subprojects and keymaps of the keyboard. **NOTE** that this behaviour has changed. Previously it compiled just the default keymap.
241* `make ergodox-infinity-algernon-clean` will clean the build output of the Ergodox Infinity keyboard. This example uses the full syntax and can be run from any folder with a `Makefile`
242* `make dfu COLOR=false` from within a keymap folder, builds and uploads the keymap, but without color output.
187 243
188## The `Makefile` 244## The `Makefile`
189 245
190There are 3 different `make` and `Makefile` locations: 246There are 5 different `make` and `Makefile` locations:
191 247
192* root (`/`) 248* root (`/`)
193* keyboard (`/keyboards/<keyboard>/`) 249* keyboard (`/keyboards/<keyboard>/`)
194* keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`) 250* keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`)
251* subproject (`/keyboards/<keyboard>/<subproject>`)
252* subproject keymap (`/keyboards/<keyboard>/<subproject>/keymaps/<keymap>`)
253
254The root contains the code used to automatically figure out which keymap or keymaps to compile based on your current directory and commandline arguments. It's considered stable, and shouldn't be modified. The keyboard one will contain the MCU set-up and default settings for your keyboard, and shouldn't be modified unless you are the producer of that keyboard. The keymap Makefile can be modified by users, and is optional. It is included automatically if it exists. You can see an example [here](/doc/keymap_makefile_example.mk) - the last few lines are the most important. The settings you set here will override any defaults set in the keyboard Makefile. **The file is required if you want to run `make` in the keymap folder.**
195 255
196The root contains the code used to automatically figure out which keymap or keymaps to compile based on your current directory and commandline arguments. It's considered stable, and shouldn't be modified. The keyboard one will contain the MCU set-up and default settings for your keyboard, and shouldn't be modified unless you are the producer of that keyboard. The keymap Makefile can be modified by users, and is optional. It is included automatically if it exists. You can see an example [here](/doc/keymap_makefile_example.mk) - the last few lines are the most important. The settings you set here will override any defaults set in the keyboard Makefile. **It is required if you want to run `make` in the keymap folder.** 256For keyboards and subprojects, the make files are split in two parts `Makefile` and `rules.mk`. All settings can be found in the `rules.mk` file, while the `Makefile` is just there for support and including the root `Makefile`. Keymaps contain just one `Makefile` for simplicity.
197 257
198### Makefile options 258### Makefile options
199 259