aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-05-29 11:56:54 -0400
committerGitHub <noreply@github.com>2017-05-29 11:56:53 -0400
commitcecf783e145c4ca8e7737e8a1909bce946bc5a0f (patch)
treee7d5c7340f143510fbe57714d92505e5df565a9d
parent988941cc0a0e8a4bfa0b696aba9a57c0a105eb64 (diff)
parent78aebe0631c6987ce1721428ff8fbbb0a1e8fbd7 (diff)
downloadqmk_firmware-cecf783e145c4ca8e7737e8a1909bce946bc5a0f.tar.gz
qmk_firmware-cecf783e145c4ca8e7737e8a1909bce946bc5a0f.zip
Merge pull request #1337 from fredizzimo/wsl_setup
Add script for setting up Windows Subsystem for Linux
-rw-r--r--.gitignore1
-rw-r--r--docs/Build-Environment-Setup.md37
-rw-r--r--util/activate_wsl.sh17
-rw-r--r--util/drivers.txt46
-rw-r--r--util/wsl_install.sh159
5 files changed, 245 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 6029afce4..0b48b80e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@ quantum/version.h
22.idea/ 22.idea/
23CMakeLists.txt 23CMakeLists.txt
24.DS_STORE 24.DS_STORE
25/util/wsl_downloaded
25 26
26# Eclipse/PyCharm/Other IDE Settings 27# Eclipse/PyCharm/Other IDE Settings
27.cproject 28.cproject
diff --git a/docs/Build-Environment-Setup.md b/docs/Build-Environment-Setup.md
index 35e02924b..d4cec91c7 100644
--- a/docs/Build-Environment-Setup.md
+++ b/docs/Build-Environment-Setup.md
@@ -1,25 +1,32 @@
1### Windows 10 1### Windows 10
2 2
3Due to some issues with the "Windows (Vista and later)" instructions below, we now recommend following these instructions if you use Windows, which will allow you to use the Windows Subsystem for Linux to compile the firmware. If you are not using Windows 10 with the Anniversary Update installed (which came out in July 2016), you will need to use one of the other methods, such as Docker, Vagrant, or the instructions for Vista and later. 3#### Creators Update
4If you have Windows 10 with Creators Update or later, you can build and flash the firmware directly. Before the Creators Update, only building was possible. If you don't have it yet or if are unsure, follow [these instructions](https://support.microsoft.com/en-us/instantanswers/d4efb316-79f0-1aa1-9ef3-dcada78f3fa0/get-the-windows-10-creators-update).
4 5
5If you use this method, you will need to use a standalone tool to flash the firmware to the keyboard after you compile it. We recommend the official [QMK Firmware Flasher](https://github.com/qmk/qmk_firmware_flasher/releases). This is because the Windows 10 Subsystem for Linux lacks [libUSB support](https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13355724-unable-to-access-usb-devices-from-bash), so it can't access the keyboard's microcontroller. Please add your vote for Microsoft to fix this issue using the link! 6#### Windows Subsystem for Linux
7In addition to the Creators Update, you need Windows 10 Subystem for Linux, so install it following [these instructions](http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/). If you already have the Windows 10 Subsystem for Linux from the Anniversary update it's recommended that you [upgrade](https://betanews.com/2017/04/14/upgrade-windows-subsystem-for-linux/) it to 16.04LTS, because some keyboards don't compile with the toolchains included in 14.04LTS. Note that you need to know what your are doing if you chose the `sudo do-release-upgrade` method.
6 8
7Here are the steps 9#### Git
10If you already have cloned the repository on your Windows file system you can ignore this section.
8 11
91. Install the Windows 10 subsystem for Linux, following [these instructions](http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/). 12You will need to clone the repository to your Windows file system using the normal Git for Windows and **not** the WSL Git. So if you haven't installed Git before, [download](https://git-scm.com/download/win) and install it. Then [set it up](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup), it's important that you setup the e-mail and user name, especially if you are planning to contribute.
102. If you have cloned the repository using git before August 20, 2016, clean up the line endings from wherever you currently access git:
11 1. Make sure that you have no changes you haven't committed by running `git status`. ANY UNCOMMITTED CHANGES WILL BE PERMANENTLY LOST.
12 2. Run `git rm --cached -r .`
13 3. Run `git reset --hard`
143. Open "Bash On Ubuntu On Windows" from the start menu
154. With the bash window open, navigate to your copy of the [qmk_firmware repository](https://github.com/qmk/qmk_firmware) using the `cd` command. The harddisks can be accessed from `/mnt/<driveletter>`. For example, your main hard drive (C:) can be accessed by executing the command `cd /mnt/c`. If your username is John and the qmk_firmware folder is in your Downloads folder, you can move to it with the command `cd /mnt/c/Users/John/Downloads/qmk_firmware`. You can use the Tab key as you go to help you autocomplete the folder names.
165. Run `sudo util/install_dependencies.sh`. **This will run `apt-get upgrade`.**
176. After a while the installation will finish, and you are good to go
18 13
19**Note** From time to time, the dependencies might change, so just run `install_dependencies.sh` again if things are not working. 14Once Git is installed, open the Git bash command and change the directory to where you want to clone QMK, note that you have to use forward slashes, and that your c drive is accessed like this `/c/path/to/where/you/want/to/go`. Then run `git clone --recurse-submodules https://github.com/qmk/qmk_firmware`, this will create a new folder `qmk_firmware` as a subfolder of the current one.
20 15
21**Warning:** If you edit Makefiles or shell scripts, make sure you are using an editor that saves the files with Unix line endings. Otherwise the compilation might not work. 16#### Toolchain setup
17The Toolchain setup is done through the Windows Subsystem for Linux, and the process is fully automated. If you want to do everything manually, there are no other instructions than the scripts themselves, but you can always open issues and ask for more information.
22 18
191. Open "Bash On Ubuntu On Windows" from the start menu.
202. Go to the directory where you cloned `qmk_firmware`. Note that the paths start with `/mnt/` in the WSL, so you have to write for example `cd /mnt/c/path/to/qmk_firmware`.
213. Run `util/wsl_install.sh` and follow the on-screen instructions.
224. Close the Bash command window, and re-open it.
235. You are ready to compile and flash the firmware!
24
25#### Some important things to keep in mind
26* You can run `util/wsl_install.sh` again to get all the newest updates.
27* Your QMK repository need to be on a Windows file system path, since WSL can't run executables outside it.
28* The WSL Git is **not** compatible with the Windows Git, so use the Windows Git Bash or a windows Git GUI for all Git operations
29* You can edit files either inside WSL or normally using Windows, but note that if you edit makefiles or shell scripts, make sure you are using an editor that saves the files with Unix line endings. Otherwise the compilation might not work.
23 30
24### Windows (Vista and later) 31### Windows (Vista and later)
251. If you have ever installed WinAVR, uninstall it. 321. If you have ever installed WinAVR, uninstall it.
@@ -109,4 +116,4 @@ If you have any problems building the firmware, you can try using a tool called
1091. If you haven't already, obtain this repository ([https://github.com/qmk/qmk_firmware](https://github.com/qmk/qmk_firmware)). You can either download it as a zip file and extract it, or clone it using the command line tool git or the Github Desktop application. 1161. If you haven't already, obtain this repository ([https://github.com/qmk/qmk_firmware](https://github.com/qmk/qmk_firmware)). You can either download it as a zip file and extract it, or clone it using the command line tool git or the Github Desktop application.
1102. Open up a terminal or command prompt and navigate to the `qmk_firmware` folder using the `cd` command. The command prompt will typically open to your home directory. If, for example, you cloned the repository to your Documents folder, then you would type `cd Documents/qmk_firmware`. If you extracted the file from a zip, then it may be named `qmk_firmware-master` instead. 1172. Open up a terminal or command prompt and navigate to the `qmk_firmware` folder using the `cd` command. The command prompt will typically open to your home directory. If, for example, you cloned the repository to your Documents folder, then you would type `cd Documents/qmk_firmware`. If you extracted the file from a zip, then it may be named `qmk_firmware-master` instead.
1113. To confirm that you're in the correct location, you can display the contents of your current folder using the `dir` command on Windows, or the `ls` command on Linux or Mac. You should see several files, including `readme.md` and a `quantum` folder. From here, you need to navigate to the appropriate folder under `keyboards/`. For example, if you're building for a Planck, run `cd keyboards/planck`. 1183. To confirm that you're in the correct location, you can display the contents of your current folder using the `dir` command on Windows, or the `ls` command on Linux or Mac. You should see several files, including `readme.md` and a `quantum` folder. From here, you need to navigate to the appropriate folder under `keyboards/`. For example, if you're building for a Planck, run `cd keyboards/planck`.
1124. Once you're in the correct keyboard-specific folder, run the `make` command. This should output a lot of information about the build process. More information about the `make` command can be found below. \ No newline at end of file 1194. Once you're in the correct keyboard-specific folder, run the `make` command. This should output a lot of information about the build process. More information about the `make` command can be found below.
diff --git a/util/activate_wsl.sh b/util/activate_wsl.sh
new file mode 100644
index 000000000..e2312b56d
--- /dev/null
+++ b/util/activate_wsl.sh
@@ -0,0 +1,17 @@
1#!/bin/bash
2
3function export_variables {
4 local util_dir=~/qmk_utils
5 local download_dir=$util_dir/wsl_downloaded
6
7 export DFU_PROGRAMMER=$download_dir/dfu-programmer/dfu-programmer.exe
8 export DFU_UTIL=$download_dir/dfu-util-0.9-win64/dfu-util.exe
9 export TEENSY_LOADER_CLI=$download_dir/teensy_loader_cli.exe
10 export BATCHISP=batchisp.exe
11}
12
13export_variables
14
15
16
17
diff --git a/util/drivers.txt b/util/drivers.txt
new file mode 100644
index 000000000..d21a748f0
--- /dev/null
+++ b/util/drivers.txt
@@ -0,0 +1,46 @@
1# The format is
2# driver,desc,vid,pid,guid
3# Use a comma as a separator without spaces
4# Driver can be one of winusb,libusb,libusbk
5# Use Windows Powershell and type [guid]::NewGuid() to generate guids
6winusb,Kiibohd DFU Bootloader,1C11,B007,aa5a3f86-b81e-4416-89ad-0c1ea1ed63af
7libusb,ATxmega16C4,03EB,2FD8,23266ee7-5423-4cc4-993b-034571c43a90
8libusb,ATxmega32C4,03EB,2FD9,d4b62886-2ac8-4534-aa24-eae0a2c3ce43
9libusb,ATxmega64C3,03EB,2FD6,08467ca7-9b5a-41d2-8d8a-4a26d0b5285b
10libusb,ATxmega128C3,03EB,2FD7,1ca69799-6d95-46cf-be69-5b3d0eb915e6
11libusb,ATxmega256C3,03EB,2FDA,216ddc8b-6c67-4cc0-b934-482829a483a0
12libusb,ATxmega384C3,03EB,2FDB,0e4e3347-6025-4d49-ba80-2375ea690c28
13libusb,ATxmega64A1U,03EB,2FE8,2553d8fa-7de1-44a6-bdbf-57be8bb37e28
14libusb,ATxmega128A1U,03EB,2FED,6d9fd0ff-755d-4e29-bd29-df0a9a7544b9
15libusb,ATxmega64A4U,03EB,2FDD,bcf5e7c3-44a1-4fd1-971f-9ef9843f6291
16libusb,ATxmega128A4U,03EB,2FDE,3f976bb6-36ca-44cc-a728-844bc1d0d168
17libusb,ATxmega64B3,03EB,2FDF,de280c81-c12a-4ca7-bf34-566151786418
18libusb,ATxmega128B3,03EB,2FE0,2ad1ffeb-eb83-4e78-b34a-d5633771991f
19libusb,ATxmega64B1,03EB,2FE1,002874a6-7fc7-413b-9ac4-2b52c5a230bd
20libusb,ATxmega128B1,03EB,2FEA,60ea9d08-2ae6-4434-b743-ce6f73537136
21libusb,ATxmega256A3BU,03EB,2FE2,5949bd0a-8bd4-417b-b1c5-7d249836bf0d
22libusb,ATxmega16A4U,03EB,2FE3,cc3172b0-e86a-4758-914e-951bca6ca7f5
23libusb,ATxmega32A4U,03EB,2FE4,f44c515f-7d17-4612-a532-ee620afb22b2
24libusb,ATxmega64A4U,03EB,2FE5,c1af4f1c-045f-40c9-893a-3ad4adb2e67d
25libusb,ATxmega128A3U,03EB,2FE6,26f275f0-d6b2-46d8-8334-e4de66996c74
26libusb,ATxmega192A3U,03EB,2FE7,b7b50d98-0429-4235-8f08-5466e4f83ed4
27libusb,UC3,03EB,2FDC,972d9af7-d71b-44c7-a895-9340b362f545
28libusb,ATUC3,03EB,2FE9,d5855d0a-f82e-4df5-9c14-2b0b1dcb65bd
29libusb,AT32UC3C,03EB,2FEB,1eeb52aa-fd24-47fd-8a76-056446d1a54f
30libusb,ATxmega256A3U,03EB,2FEC,198fa8ea-3157-4863-b9a8-a3f6fe027367
31libusb,ATmega8U2,03EB,2FEE,14018055-46f4-4c62-aa03-e8fafeedaf72
32libusb,ATmega16U2,03EB,2FEF,007274da-b75f-492e-a288-8fc0aff8339f
33libusb,ATmega32U2,03EB,2FF0,ddc2c572-cb6e-4f61-a6cc-1a5de941f063
34libusb,AT32UC3A3,03EB,2FF1,8b614283-36c0-46a2-890d-65f61b5b6201
35libusb,ATmega32U6,03EB,2FF2,a207dd90-2814-4418-b5b7-4b708fdf1bfd
36libusb,ATmega16U4,03EB,2FF3,3180d426-bf93-4578-a693-2efbc337da8e
37libusb,ATmega32U4,03EB,2FF4,5f9726fd-f9de-487a-9fbd-8b3524a7a56a
38libusb,AT32UC3B,03EB,2FF6,ef90068a-277a-44db-805a-9b83a6beb29a
39libusb,AT90USB82,03EB,2FF7,062fa2ab-f9d8-4a0d-83c1-df0521cfd0f6
40libusb,AT32UC3A,03EB,2FF8,24080a67-3874-4fb8-8808-fb4cc297c466
41libusb,AT90USB64,03EB,2FF9,c6a708ad-e97d-43cd-b04a-3180d737a71b
42libusb,AT90USB162,03EB,2FFA,de67bff5-6e39-4e9c-8dfe-de7fce113716
43libusb,AT90USB128,03EB,2FFB,fd217df3-59d0-440a-a8f3-4c0c8c84daa3
44libusb,AT89C5130,03EB,2FFD,31b69a56-9ac0-4fab-a3ae-cd7bb7021ec5
45libusb,AT8XC5122,03EB,2FFE,395a6118-8568-41b2-913a-d16912722342
46libusb,AT89C5132,03EB,2FFF,266ca4bc-5e59-4a7b-82dc-6e8732373d40 \ No newline at end of file
diff --git a/util/wsl_install.sh b/util/wsl_install.sh
new file mode 100644
index 000000000..8999da8a4
--- /dev/null
+++ b/util/wsl_install.sh
@@ -0,0 +1,159 @@
1#!/bin/bash
2
3download_dir=wsl_downloaded
4
5function install_utils {
6 rm -f -r $download_dir
7 mkdir $download_dir
8
9 pushd $download_dir
10
11 echo "Installing dfu-programmer"
12 wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
13 unzip -d dfu-programmer dfu-programmer-win-0.7.2.zip
14
15 echo "Installing dfu-util"
16 wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
17 unzip dfu-util-0.9-win64.zip
18
19 echo "Installing teensy_loader_cli"
20 wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
21 unzip teensy_loader_cli_windows.zip
22
23 echo "Installing Atmel Flip"
24 wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
25 mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe
26
27 echo "Downloading the QMK driver installer"
28 wget -qO- https://api.github.com/repos/qmk/qmk_driver_installer/releases | grep browser_download_url | head -n 1 | cut -d '"' -f 4 | wget -i -
29
30 rm -f *.zip
31
32 popd > /dev/null
33}
34
35function install_drivers {
36 pushd $download_dir
37 cmd.exe /C qmk_driver_installer.exe $1 $2 ../drivers.txt
38 popd > /dev/null
39}
40
41dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
42
43if [[ $dir != /mnt/* ]];
44then
45 echo
46 echo "You need to clone the qmk_firmware repository outside the linux filesystem."
47 echo "Otherwise the windows executables can't be run."
48 exit 1
49fi
50
51pushd "$dir"
52
53while true; do
54 echo
55 echo "Do you want to install all toolchain dependencies needed for compiling QMK?"
56 echo "This will run install_dependencies.sh, which calls apt-get upgrade."
57 echo "If you don't want that, you can install the dependencies manually."
58 read -p "(Y/N) " res
59 case $res in
60 [Yy]* ) sudo ./install_dependencies.sh; break;;
61 [Nn]* ) break;;
62 * ) echo "Invalid answer";;
63 esac
64done
65
66echo "Installing dependencies needed for the installation (unzip, wget)"
67echo "This will ask for the sudo password"
68sudo apt-get install unzip wget
69
70
71if [ ! -d "$download_dir" ]; then
72 install_utils
73else
74 while true; do
75 echo
76 read -p "The utils seem to already be downloaded, do you want to re-download them and update to the newest version (Y/N) " res
77 case $res in
78 [Yy]* ) install_utils; break;;
79 [Nn]* ) break;;
80 * ) echo "Invalid answer";;
81 esac
82 done
83fi
84
85while true; do
86 echo
87 read -p "Flip need to be installed if you want to use that for programming, do you want to install it now? (Y/N) " res
88 case $res in
89 [Yy]* ) cmd.exe /c $download_dir\\FlipInstaller.exe; break;;
90 [Nn]* ) break;;
91 * ) echo "Invalid answer";;
92 esac
93done
94
95
96while true; do
97 echo
98 echo "Which USB drivers do you want to install?"
99 echo "(A)all - All supported drivers will be installed"
100 echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode) will be installed"
101 echo "(F)force - Like all, but will also override existing drivers for connected keyboards"
102 echo "(N)one - No drivers will be installed, flashing your keyboard will most likely not work"
103 read -p "(A/C/F/N)? " res
104 case $res in
105 [Aa]* ) install_drivers --all; break;;
106 [Cc]* ) install_drivers; break;;
107 [Ff]* ) install_drivers --all --force; break;;
108 [Nn]* ) break;;
109 * ) echo "Invalid answer";;
110 esac
111done
112
113echo
114echo "Creating a softlink to the utils directory as ~/qmk_utils."
115echo "This is needed so that the the make system can find all utils it need."
116read -p "Press any key to continue (ctrl-c to abort)"
117ln -sfn "$dir" ~/qmk_utils
118
119if grep "^source ~/qmk_utils/activate_wsl.sh$" ~/.bashrc
120then
121 echo
122 echo "The line source ~/qmk_utils/activate_wsl.sh is already added to your /.bashrc"
123 echo "Not adding it twice"
124else
125 while true; do
126 echo
127 echo "Do you want to add 'source ~/qmk_utils/activate_wsl.sh' to the end of you .bashrc file?"
128 echo "Without this make won't find the needed utils, so if you don't want to do it automatically,"
129 echo "then you have to do it manually."
130 read -p "(Y/N)? " res
131 case $res in
132 [Yy]* ) echo "source ~/qmk_utils/activate_wsl.sh" >> ~/.bashrc; break;;
133 [Nn]* ) break;;
134 * ) echo "Invalid answer";;
135 esac
136 done
137fi
138
139while true; do
140 echo
141 echo "Do you want to add a symlink to the QMK repository in your home directory for convenience?"
142 echo "This will create a folder 'qmk_firmware' in your home directory."
143 echo "In the future you can use this folder instead of the full path on your windows file system"
144 read -p "(Y/N)? " res
145 case $res in
146 [Yy]* ) ln -sfn "$dir/.." ~/qmk_firmware; break;;
147 [Nn]* ) break;;
148 * ) echo "Invalid answer";;
149 esac
150done
151
152echo
153echo "******************************************************************************"
154echo "Installation completed!"
155echo "You need to open a new batch command prompt for all the utils to work properly"
156echo "******************************************************************************"
157
158popd > /dev/null
159