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.

238 lines
9.6 KiB

3 years ago
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. Prerequisites
  4. There are a few pieces of software you'll need to get started.
  5. * [Text editor](newbs_learn_more_resources.md#text-editor-resources)
  6. * You’ll need a program that can edit and save plain text files. The default editor that comes with many OS's does not save plain text files, so you'll need to make sure that whatever editor you chose does.
  7. * [Toolbox (optional)](https://github.com/qmk/qmk_toolbox)
  8. * A graphical program for Windows and macOS that allows you to both program and debug your custom keyboard
  9. ?> 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](newbs_learn_more_resources.md#command-line-resources) will teach you enough to be able to work with QMK.
  10. ## 2. Prepare Your Build Environment :id=set-up-your-environment
  11. 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.
  12. <!-- tabs:start -->
  13. ### ** Windows **
  14. QMK maintains a Bundle of MSYS2, the CLI and all necessary dependencies. It also provides a handy `QMK MSYS` terminal shortcut to boot you directly into the correct environment.
  15. #### Installation
  16. You will need to install [QMK MSYS](https://msys.qmk.fm/). The latest release is available [here](https://github.com/qmk/qmk_distro_msys/releases/latest).
  17. Alternatively, if you'd like to manually install MSYS2, the following section will walk you through the process.
  18. <details>
  19. <summary>Manual Install</summary>
  20. ?> Ignore the following steps if you use `QMK MSYS`.
  21. #### Prerequisites
  22. You will need to install MSYS2, Git and Python. Follow the installation instructions on https://www.msys2.org.
  23. Once MSYS2 is installed, close any open MSYS terminals and open a new MinGW 64-bit terminal.
  24. !> **NOTE:** The MinGW 64-bit terminal is *not* the same as the MSYS terminal that opens when installation is completed. Your prompt should say "MINGW64" in purple text, rather than "MSYS". See [this page](https://www.msys2.org/wiki/MSYS2-introduction/#subsystems) for more information on the differences.
  25. Then run the following command:
  26. pacman --needed --noconfirm --disable-download-timeout -S git mingw-w64-x86_64-toolchain mingw-w64-x86_64-python3-pip
  27. #### Installation
  28. Install the QMK CLI by running:
  29. python3 -m pip install qmk
  30. </details>
  31. ### ** macOS **
  32. QMK maintains a Homebrew tap and formula which will automatically install the CLI and all necessary dependencies.
  33. #### Prerequisites
  34. You will need to install Homebrew. Follow the instructions on https://brew.sh.
  35. #### Installation
  36. Install the QMK CLI by running:
  37. brew install qmk/qmk/qmk
  38. ### ** Linux **
  39. #### Prerequisites
  40. 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:
  41. * Debian / Ubuntu / Devuan: `sudo apt install -y git python3-pip`
  42. * Fedora / Red Hat / CentOS: `sudo yum -y install git python3-pip`
  43. * Arch / Manjaro: `sudo pacman --needed --noconfirm -S git python-pip libffi`
  44. * Void: `sudo xbps-install -y git python3-pip`
  45. * Solus: `sudo eopkg -y install git python3`
  46. * Sabayon: `sudo equo install dev-vcs/git dev-python/pip`
  47. * Gentoo: `sudo emerge dev-vcs/git dev-python/pip`
  48. #### Installation
  49. Install the QMK CLI by running:
  50. python3 -m pip install --user qmk
  51. #### Community Packages
  52. These packages are maintained by community members, so may not be up to date or completely functional. If you encounter problems, please report them to their respective maintainers.
  53. On Arch-based distros you can install the CLI from the official repositories (NOTE: at the time of writing this package marks some dependencies as optional that should not be):
  54. sudo pacman -S qmk
  55. You can also try the `qmk-git` package from AUR:
  56. yay -S qmk-git
  57. ### ** WSL **
  58. QMK maintains a WSL distro with the CLI and all necessary dependencies.
  59. #### Prerequisites
  60. You will need to install WSL. Follow the instructions [here](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
  61. #### Installation
  62. You will need to install the `QMK WSL` distro. The latest release is available at <https://github.com/qmk/qmk_distro_wsl/releases/latest>.
  63. Alternatively, if you'd like to manually install against the WSL distro of your choice, follow the `Linux` part of this guide after installing WSL.
  64. !> **NOTE:** By default, the installation process will clone the QMK repository into your WSL home directory. Manual backup of these files is recommended before performing any WSL unregister/upgrade actions. If you have cloned manually, ensure that it is located inside the WSL instance instead of the Windows filesystem (ie. not in `/mnt`), as accessing it is currently [extremely slow](https://github.com/microsoft/WSL/issues/4197).
  65. ### ** FreeBSD **
  66. #### Prerequisites
  67. 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:
  68. pkg install git python3
  69. Make sure that `$HOME/.local/bin` is added to your `$PATH` so that locally installed Python packages are available.
  70. #### Installation
  71. Install the QMK CLI by running:
  72. python3 -m pip install --user qmk
  73. <!-- tabs:end -->
  74. ## 3. Run QMK Setup :id=set-up-qmk
  75. <!-- tabs:start -->
  76. ### ** Windows **
  77. After installing QMK you can set it up with this command:
  78. qmk setup
  79. In most situations you will want to answer `y` to all of the prompts.
  80. ### ** macOS **
  81. After installing QMK you can set it up with this command:
  82. qmk setup
  83. In most situations you will want to answer `y` to all of the prompts.
  84. ### ** Linux **
  85. After installing QMK you can set it up with this command:
  86. qmk setup
  87. In most situations you will want to answer `y` to all of the prompts.
  88. ?>**Note on Debian, Ubuntu and their derivatives**:
  89. It's possible, that you will get an error saying something like: `bash: qmk: command not found`.
  90. 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.
  91. Sadly, Ubuntu reitroduced this bug and is [yet to fix it](https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1588562).
  92. Luckily, the fix is easy. Run this as your user: `echo 'PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bashrc && source $HOME/.bashrc`
  93. ### ** WSL **
  94. After installing QMK you can set it up with this command:
  95. qmk setup
  96. In most situations you will want to answer `y` to all of the prompts.
  97. ### ** FreeBSD **
  98. After installing QMK you can set it up with this command:
  99. qmk setup
  100. In most situations you will want to answer `y` to all of the prompts.
  101. ?>**Note on FreeBSD**:
  102. 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
  103. base system using `pkg`. However the installation will probably fail when run as an unprivileged user.
  104. To manually install the base dependencies, run `./util/qmk_install.sh` either as `root`, or with `sudo`.
  105. Once that completes, re-run `qmk setup` to complete the setup and checks.
  106. <!-- tabs:end -->
  107. ?> The qmk home folder can be specified at setup with `qmk setup -H <path>`, and modified afterwards using the [cli configuration](cli_configuration.md?id=single-key-example) and the variable `user.qmk_home`. For all available options run `qmk setup --help`.
  108. ?> 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.
  109. ## 4. Test Your Build Environment
  110. 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:
  111. qmk compile -kb <keyboard> -km default
  112. For example, to build a firmware for a Clueboard 66% you would use:
  113. qmk compile -kb clueboard/66/rev3 -km default
  114. When it is done you should have a lot of output that ends similar to this:
  115. ```
  116. Linking: .build/clueboard_66_rev3_default.elf [OK]
  117. Creating load file for flashing: .build/clueboard_66_rev3_default.hex [OK]
  118. Copying clueboard_66_rev3_default.hex to qmk_firmware folder [OK]
  119. Checking file size of clueboard_66_rev3_default.hex [OK]
  120. * The firmware size is fine - 26356/28672 (2316 bytes free)
  121. ```
  122. ## 5. Configure Your Build Environment (Optional)
  123. You can configure your build environment to set the defaults and make working with QMK less tedious. Let's do that now!
  124. 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`:
  125. qmk config user.keyboard=clueboard/66/rev4
  126. You can also set your default keymap name. Most people use their GitHub username here, and we recommend that you do too.
  127. qmk config user.keymap=<github_username>
  128. After this you can leave those arguments off and compile your keyboard like this:
  129. qmk compile
  130. # Creating Your Keymap
  131. You are now ready to create your own personal keymap! Move on to [Building Your First Firmware](newbs_building_firmware.md) for that.