You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
7.5 KiB

4 years ago
4 years ago
  1. # Setting Up Your QMK Environment
  2. Before you can build keymaps, you need to install some software and set up your build environment. This only has to be done once no matter how many keyboards you plan to compile firmware for.
  3. ## 1. Download Software
  4. There are a few pieces of software you'll need to get started.
  5. ### Text Editor
  6. You'll need a program that can edit and save **plain text** files. If you're on Windows you can make do with Notepad, and on Linux you can use gedit. Both of these are simple but functional text editors. On macOS, be careful with the default TextEdit app: it will not save plain text files unless you explicitly select _Make Plain Text_ from the _Format_ menu.
  7. You can also download and install a dedicated text editor like [Sublime Text](https://www.sublimetext.com/) or [VS Code](https://code.visualstudio.com/). This is probably the best way to go regardless of platform, as these programs are specifically made for editing code.
  8. ?> Not sure which text editor to use? Laurence Bradford wrote [a great introduction](https://learntocodewith.me/programming/basics/text-editors/) to the subject.
  9. ### QMK Toolbox
  10. QMK Toolbox is an optional graphical program for Windows and macOS that allows you to both program and debug your custom keyboard. You will likely find it invaluable for easily flashing your keyboard and viewing debug messages that it prints.
  11. [Download the latest release here.](https://github.com/qmk/qmk_toolbox/releases/latest)
  12. * For Windows: `qmk_toolbox.exe` (portable) or `qmk_toolbox_install.exe` (installer)
  13. * For macOS: `QMK.Toolbox.app.zip` (portable) or `QMK.Toolbox.pkg` (installer)
  14. ### A Unix-like Environment
  15. Linux and macOS come with unix shells you can execute already. You will only need to setup your build environment.
  16. On Windows you will need to install MSYS2 or WSL and use those environments. Instructions for setting up MSYS2 are provided below.
  17. ## 2. Prepare Your Build Environment :id=set-up-your-environment
  18. We've tried to make QMK as easy to set up as possible. You only have to prepare your Linux or Unix environment, then let QMK install the rest.
  19. ?> If you haven't worked with the Linux/Unix command line before, there are a few basic concepts and commands you should learn. These resources will teach you enough to be able to work with QMK:<br>
  20. [Must Know Linux Commands](https://www.guru99.com/must-know-linux-commands.html)<br>
  21. [Some Basic Unix Commands](https://www.tjhsst.edu/~dhyatt/superap/unixcmd.html)
  22. ### Windows
  23. You will need to install MSYS2, Git, and the QMK CLI.
  24. * Follow the installation instructions on the [MSYS2 homepage](http://www.msys2.org).
  25. * Close any open MSYS2 terminals and open a new MSYS2 MinGW 64-bit terminal. NOTE: This is **not** the same as the MSYS terminal that opens when installation is completed.
  26. After opening a new MSYS2 MinGW 64-bit terminal, make sure `pacman` is up to date with:
  27. pacman -Syu
  28. You may be asked to close and reopen the window. Do this and keep running the above command until it says `there is nothing to do`. Then run the following:
  29. pacman -S git mingw-w64-x86_64-toolchain mingw-w64-x86_64-python3-pip
  30. python3 -m pip install qmk
  31. ### macOS
  32. You will need to install Homebrew. Follow the instructions on the [Homebrew homepage](https://brew.sh).
  33. After Homebrew is installed run this command:
  34. brew install qmk/qmk/qmk
  35. ### Linux
  36. You will need to install Git and Python. It's very likely that you already have both, but if not, one of the following commands should install them:
  37. * Debian / Ubuntu / Devuan: `sudo apt install git python3 python3-pip`
  38. * Fedora / Red Hat / CentOS: `sudo yum install git python3 python3-pip`
  39. * Arch / Manjaro: `sudo pacman -S git python python-pip python-setuptools libffi`
  40. Install the global CLI to bootstrap your system:
  41. `python3 -m pip install --user qmk` (on Arch-based distros you can also try the `qmk` package from AUR (**note**: it's maintained by a community member): `yay -S qmk`)
  42. ### FreeBSD
  43. You will need to install Git and Python. It's possible that you already have both, but if not, run the following commands to install them:
  44. pkg install git python3
  45. Make sure that `$HOME/.local/bin` is added to your `$PATH` so that locally install Python packages are available.
  46. Once installed, you can install QMK CLI:
  47. python3 -m pip install --user qmk
  48. ## 3. Run QMK Setup :id=set-up-qmk
  49. After installing QMK you can set it up with this command:
  50. qmk setup
  51. In most situations you will want to answer Yes to all of the prompts.
  52. ?>**Note on Debian, Ubuntu and their derivatives**:
  53. It's possible, that you will get an error saying something like: `bash: qmk: command not found`.
  54. This is due to a [bug](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=839155) Debian introduced with their Bash 4.4 release, which removed `$HOME/.local/bin` from the PATH. This bug was later fixed on Debian and Ubuntu.
  55. Sadly, Ubuntu reitroduced this bug and is [yet to fix it](https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1588562).
  56. Luckily, the fix is easy. Run this as your user: `echo "PATH=$HOME/.local/bin:$PATH" >> $HOME/.bashrc && source $HOME/.bashrc`
  57. ?>**Note on FreeBSD**:
  58. It is suggested to run `qmk setup` as a non-`root` user to start with, but this will likely identify packages that need to be installed to your
  59. base system using `pkg`. However the installation will probably fail when run as an unprivileged user.
  60. To manually install the base dependencies, run `./util/qmk_install.sh` either as `root`, or with `sudo`.
  61. Once that completes, re-run `qmk setup` to complete the setup and checks.
  62. ?> If you already know [how to use GitHub](getting_started_github.md), we recommend that you create your own fork and use `qmk setup <github_username>/qmk_firmware` to clone your personal fork. If you don't know what that means you can safely ignore this message.
  63. ## 4. Test Your Build Environment
  64. Now that your QMK build environment is set up, you can build a firmware for your keyboard. Start by trying to build the keyboard's default keymap. You should be able to do that with a command in this format:
  65. qmk compile -kb <keyboard> -km default
  66. For example, to build a firmware for a Clueboard 66% you would use:
  67. qmk compile -kb clueboard/66/rev3 -km default
  68. When it is done you should have a lot of output that ends similar to this:
  69. ```
  70. Linking: .build/clueboard_66_rev3_default.elf [OK]
  71. Creating load file for flashing: .build/clueboard_66_rev3_default.hex [OK]
  72. Copying clueboard_66_rev3_default.hex to qmk_firmware folder [OK]
  73. Checking file size of clueboard_66_rev3_default.hex [OK]
  74. * The firmware size is fine - 26356/28672 (2316 bytes free)
  75. ```
  76. ## 5. Configure Your Build Environment (Optional)
  77. You can configure your build environment to set the defaults and make working with QMK less tedious. Let's do that now!
  78. Most 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`:
  79. qmk config user.keyboard=clueboard/66/rev4
  80. You can also set your default keymap name. Most people use their GitHub username here, and we recommend that you do too.
  81. qmk config user.keymap=<github_username>
  82. After this you can leave those arguments off and compile your keyboard like this:
  83. qmk compile
  84. # Creating Your Keymap
  85. You are now ready to create your own personal keymap! Move on to [Building Your First Firmware](newbs_building_firmware.md) for that.