aboutsummaryrefslogtreecommitdiff
path: root/docs/newbs_building_firmware.md
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-04-10 12:13:40 +0100
committerAkshay <[email protected]>2022-04-10 12:13:40 +0100
commitdc90387ce7d8ba7b607d9c48540bf6d8b560f14d (patch)
tree4ccb8fa5886b66fa9d480edef74236c27f035e16 /docs/newbs_building_firmware.md
Diffstat (limited to 'docs/newbs_building_firmware.md')
-rw-r--r--docs/newbs_building_firmware.md78
1 files changed, 78 insertions, 0 deletions
diff --git a/docs/newbs_building_firmware.md b/docs/newbs_building_firmware.md
new file mode 100644
index 000000000..ed51a9aea
--- /dev/null
+++ b/docs/newbs_building_firmware.md
@@ -0,0 +1,78 @@
1# Building Your First Firmware
2
3Now that you have setup your build environment you are ready to start building custom firmware. For this section of the guide we will bounce between 3 programs- your file manager, your text editor, and your terminal window. Keep all 3 open until you are done and happy with your keyboard firmware.
4
5## Configure Your Build Environment Defaults (Optional)
6
7You can configure your build environment to set the defaults and make working with QMK less tedious. Let's do that now!
8
9Most people new to QMK only have 1 keyboard. You can set this keyboard as your default with the `qmk config` command. For example, to set your default keyboard to `clueboard/66/rev4`:
10
11 qmk config user.keyboard=clueboard/66/rev4
12
13?> The keyboard option is the path relative to the keyboard directory, the above example would be found in `qmk_firmware/keyboards/clueboard/66/rev4`. If you're unsure you can view a full list of supported keyboards with `qmk list-keyboards`.
14
15You can also set your default keymap name. Most people use their GitHub username like the keymap name from the previous steps:
16
17 qmk config user.keymap=<github_username>
18
19## Create a New Keymap
20
21To create your own keymap you'll want to create a copy of the `default` keymap. If you configured your build environment in the last step you can do that easily with the QMK CLI:
22
23 qmk new-keymap
24
25If you did not configure your environment, or you have multiple keyboards, you can specify a keyboard name:
26
27 qmk new-keymap -kb <keyboard_name>
28
29Look at the output from that command, you should see something like this:
30
31 Ψ <github_username> keymap directory created in: /home/me/qmk_firmware/keyboards/clueboard/66/rev3/keymaps/<github_username>
32
33This is the location of your new `keymap.c` file.
34
35## Open `keymap.c` In Your Favorite Text Editor
36
37Open your `keymap.c` file in your text editor. Inside this file you'll find the structure that controls how your keyboard behaves. At the top of `keymap.c` there may be some defines and enums that make the keymap easier to read. Farther down you'll find a line that looks like this:
38
39 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
40
41This line indicates where the list of Layers begins. Below that you'll find lines containing `LAYOUT`, and these lines indicate the start of a layer. Below that line is the list of keys that comprise a particular layer.
42
43!> When editing your keymap file be careful not to add or remove any commas. If you do you will prevent your firmware from compiling and it may not be easy to figure out where the extra, or missing, comma is.
44
45## Customize The Layout To Your Liking
46
47How to complete this step is entirely up to you. Make the one change that's been bugging you, or completely rework everything. You can remove layers if you don't need all of them, or add layers up to a total of 32. There are a lot of features in QMK, explore the sidebar to the left under "Using QMK" to see the full list. To get you started here are a few of the easier to use features:
48
49* [Basic Keycodes](keycodes_basic.md)
50* [Quantum Keycodes](quantum_keycodes.md)
51* [Grave/Escape](feature_grave_esc.md)
52* [Mouse keys](feature_mouse_keys.md)
53
54?> While you get a feel for how keymaps work, keep each change small. Bigger changes make it harder to debug any problems that arise.
55
56## Build Your Firmware :id=build-your-firmware
57
58When your changes to the keymap are complete you will need to build the firmware. To do so go back to your terminal window and run the compile command:
59
60 qmk compile
61
62If you did not configure defaults for your environment, or you have multiple keyboards, you can specify a keyboard and/or keymap:
63
64 qmk compile -kb <keyboard> -km <keymap>
65
66While this compiles you will have a lot of output going to the screen informing you of what files are being compiled. It should end with output that looks similar to this:
67
68```
69Linking: .build/planck_rev5_default.elf [OK]
70Creating load file for flashing: .build/planck_rev5_default.hex [OK]
71Copying planck_rev5_default.hex to qmk_firmware folder [OK]
72Checking file size of planck_rev5_default.hex [OK]
73 * The firmware size is fine - 27312/28672 (95%, 1360 bytes free)
74```
75
76## Flash Your Firmware
77
78Move on to [Flashing Firmware](newbs_flashing.md) to learn how to write your new firmware to your keyboard.