aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-03-07 10:16:35 -0500
committerJack Humbert <jack.humb@gmail.com>2016-03-07 10:16:35 -0500
commit10f45a63b6c3b42025e9163c6be83ab8b86d0385 (patch)
treed3e218555c357388022fb7b4837f550850c9e36a
parent4e4250063ed3f9fcaa3448715d28f7a815f7cc7e (diff)
parent2f6f45aa3ee6cdeaa8e3904926a662d7a0a681c5 (diff)
downloadqmk_firmware-10f45a63b6c3b42025e9163c6be83ab8b86d0385.tar.gz
qmk_firmware-10f45a63b6c3b42025e9163c6be83ab8b86d0385.zip
Merge pull request #177 from yoyoerx/windocs
Documentation for Cygwin in Windows
-rwxr-xr-xkeyboard/planck/CYGWIN_GUIDE.md237
1 files changed, 237 insertions, 0 deletions
diff --git a/keyboard/planck/CYGWIN_GUIDE.md b/keyboard/planck/CYGWIN_GUIDE.md
new file mode 100755
index 000000000..2fa4452f1
--- /dev/null
+++ b/keyboard/planck/CYGWIN_GUIDE.md
@@ -0,0 +1,237 @@
1#Planck Advanced (but not too advanced) `cygwin` Users Guide
2If you are a user of the [cygwin environment](https://cygwin.com) in Windows and want the freedom to use the latest tools available, then this is the guide for you. If compiling your own copy of the latest and greatest Gnu C Compiler makes you super happy, then this is the guide for you. If the command line make you smile, then this is the guide for you.
3
4
5This guide was written step by step as I went through the process on a `Windows 10` `x86_64` based system. This should be generally applicable to to any `Windows` environment with `cygwin`.
6
7
8#####Do not skip steps. Do not move past a step until the previous step finishes successfully.
9
10
11
12Based on [avr-libc installation guide](http://www.nongnu.org/avr-libc/user-manual/install_tools.html)
13
14
15##Get the Required Packages
16Download the `cygwin` setup ([x86_64](https://cygwin.com/setup-x86_64.exe)) and install the default system plus the following if they are not already selected:
17- devel/gcc-core
18- devel/gcc-g++
19- devel/flex
20- devel/git
21- libs/libglib2.0_0
22- libs/libgcc1
23- interpreters/m4
24- web/wget
25
26The following sources will be required:
27- [gmp](https://gmplib.org/) (6.1.0)
28- [mpfr](http://www.mpfr.org/) (3.1.3)
29- [mpc](http://www.multiprecision.org/) (1.0.3)
30- [binutils](https://www.sourceware.org/binutils/) (2.26)
31- [gcc](https://gcc.gnu.org/) (5.3.0)
32- [avr-libc](http://www.nongnu.org/avr-libc/) (2.0.0)
33
34The `dfu-programmer` will be required to flash the new firmware
35- [dfu-programmer](https://dfu-programmer.github.io/) (0.7.2)
36
37
38The set of commands below will create a directory (`~/local/avr`) for the sources you compile to be installed on the machine and a directory (`~/src`) for these source files to be stored. The commands then download the sources of the needed packages and unpack them. Note: the expand commands are different depending on if the packages are offered as a `bz2` or `gz` archive
39
40```
41$ mkdir ~/local/avr
42$ mkdir ~/src
43$ cd ~/src
44$ wget https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2
45$ wget http://www.mpfr.org/mpfr-current/mpfr-3.1.3.tar.bz2
46$ wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
47$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.gz
48$ wget http://mirror0.babylon.network/gcc/releases/gcc-5.3.0/gcc-5.3.0.tar.gz
49$ wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-2.0.0.tar.bz2
50$ tar -xjf gmp-6.1.0.tar.bz2
51$ tar -xjf mpfr-3.1.3.tar.bz2
52$ tar -zxf mpc-1.0.3.tar.gz
53$ tar -zxf binutils-2.26.tar.gz
54$ tar -zxf gcc-5.3.0.tar.gz
55$ tar -xjf avr-libc-2.0.0.tar.bz2
56```
57
58##Setup the Build Environment
59These commands will set up the install directory and the `PATH` variable, which will allow you to access your installed packages. Note: if you close the `cygwin` terminal window, you will need to rerun these commands, they are not permanent.
60```
61$ PREFIX=$HOME/local/avr
62$ export PREFIX
63$ PATH=/usr/local/bin:/usr/local/lib:/usr/local/include:/bin:/lib:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS
64$ PATH=$PATH:$PREFIX/bin
65$ export PATH
66```
67
68##The `gcc` Required Math Library Packages
69The following packages are required to be complied and installed in order to compile `gcc`. They are not available through the `cygwin` package system, so we have to make them ourselves. They must be complied in this order because each one depends on the previous.
70
71###Build and Install `gmp`
72```
73$ cd ~/src/gmp-6.1.0
74$ ./configure --enable-static --disable-shared
75$ make
76$ make check
77$ make install
78```
79
80###Build and Install `mpfr`
81```
82$ cd ~/src/mpfr-3.1.3
83$ ./configure --with-gmp-build=../gmp-6.1.0 --enable-static --disable-shared
84$ make
85$ make check
86$ make install
87```
88
89###Build and Install `mpc`
90```
91$ cd ~/src/mpc-1.0.3
92$ ./configure --with-gmp=/usr/local --with-mpfr=/usr/local --enable-static --disable-shared
93$ make
94$ make check
95$ make install
96```
97
98##OPTIONAL Part
99You can build and install a brand new `gcc` or you can use the one supplied by `cygwin`. This will take about 4-5 hours to compile (It is a "native build", so it does the entire build **3 times**. This takes a long while). I would skip it.
100###Build and Install `gcc` on your Machine
101```
102$ cd ~/src/gcc-5.3.0
103$ mkdir obj-local
104$ cd obj-local
105$ ../configure --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --enable-static --disable-shared
106$ make
107$ make install
108```
109
110###Build and Install `binutils` on your Machine
111```
112$ cd ~/src/binutils-2.26
113$ mkdir obj-local
114$ cd obj-local
115$ ../configure
116$ make
117$ make install
118```
119##End OPTIONAL Part
120
121##Buliding `binutils`, `gcc`, and `avr-libc` for the AVR system
122Now we can make the critical stuff for compiling our firmware: `binutils`, `gcc`, and `avr-libc` for the AVR architecture. These allow us to build and manipulate the firmware for the keyboard.
123
124###Build `binutils` for AVR
125```
126$ cd ~/src/binutils-2.26
127$ mkdir obj-avr
128$ cd obj-avr
129$ ../configure --prefix=$PREFIX --target=avr --disable-nls
130$ make
131$ make install
132```
133
134###Build `gcc` for AVR
135```
136$ cd ~/src/gcc-5.3.0
137$ mkdir obj-avr
138$ cd obj-avr
139$ ../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --enable-static --disable-shared --disable-nls --disable-libssp --with-dwarf2
140$ make
141$ make install
142```
143
144For building the `avr-libc`, we have to specify the host build system. in my case it is `x86_64-unknown-cygwin`. You can look for build system type in the `gcc` configure notes for the proper `--build` specification to pass when you configure `avr-libc`.
145
146###Build `avr-libc` for AVR
147```
148$ cd ~/src/avr-libc-2.0.0
149$ ./configure --prefix=$PREFIX --build=x86_64-unknown-cygwin --host=avr
150$ make
151$ make install
152```
153
154##Install `dfu-programmer`
155To install the `dfu-programmer`, we must get if from [their website](https://dfu-programmer.github.io/) (no fancy command line tricks here, but [this](http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip) might work).
156Copy this file into your `cygwin` home directory. (For me, it is `C:\cygwin64\home\Kevin`), extract the files, move `dfu-programmer.exe` to `~/local/avr/bin`. Most obnoxiously, the `libusb0_x86.dll` and `libusb0.sys` need to be moved from `dfu/dfu-prog-usb-1.2.2/x86/` to a directory in the `Windows` `PATH` and the `cygwin` `PATH`. I achieved this by moving the files with Windows Explorer (you know, click and drag...) to `C:\cygwin64\home\Kevin\local\avr\bin` Then, in a `WINDOWS` command prompt running:
157```
158C:\> set PATH=%PATH%;C:\cygwin64\home\Kevin\local\avr\bin
159```
160Adjust your path (for username) as needed. Also, `libusb0_x86.dll` needs to be renamed to `libusb0.dll`. Why must this be so hard? You can tell that you were successful this way:
161```
162$ which dfu-programmer
163/home/Kevin/local/avr/bin/dfu-programmer
164
165$ dfu-programmer
166dfu-programmer 0.7.2
167https://github.com/dfu-programmer/dfu-programmer
168Type 'dfu-programmer --help' for a list of commands
169 'dfu-programmer --targets' to list supported target devices
170```
171If you are not getting the above result, you will not be able to flash the firmware!
172- Try making sure your `PATH` variables are set correctly for both `Windows` and `cygwin`.
173- Do not extract it with `cygwin`'s `unzip` as it does not set the executable permissions correctly. If you did it anyway, do `chmod 755 dfu-programmer.exe`
174
175####Install the USB drivers
176These drivers are included in the `dfu-programmer` 0.7.2 (but you can get newer ones [here](http://iweb.dl.sourceforge.net/project/libusb-win32/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip)) and allow the `dfu-programmer` to program the firmware. From an **administrator-privileged** `Windows` terminal, run the following command (adjust the path as necessary) and accept the prompt that pops up:
177```
178C:\> pnputil -i -a C:\cygwin64\home\Kevin\dfu-prog-usb-1.2.2\atmel_usb_dfu.inf
179```
180This should be the result:
181```
182Microsoft PnP Utility
183
184Processing inf : atmel_usb_dfu.inf
185Successfully installed the driver on a device on the system.
186Driver package added successfully.
187Published name : oem104.inf
188
189
190Total attempted: 1
191Number successfully imported: 1
192```
193
194##Building and Flashing the Planck firmware!
195
196If you did everything else right. This part should be a snap! Grab the latest sources from `github`, make the Plank firmware, then flash it.
197
198###Build Planck and Load the Firmware
199```
200$ cd ~/src
201$ git clone https://github.com/jackhumbert/qmk_firmware.git
202$ cd qmk_firmware/keyboard/planck
203$ make
204```
205Make sure there are no errors. You should end up with this or something similar:
206
207```
208Creating load file for Flash: planck.hex
209avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature planck.elf planck.hex
210
211Creating load file for EEPROM: planck.eep
212avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
213--change-section-lma .eeprom=0 --no-change-warnings -O ihex planck.elf planck.eep || exit 0
214
215Creating Extended Listing: planck.lss
216avr-objdump -h -S -z planck.elf > planck.lss
217
218Creating Symbol Table: planck.sym
219avr-nm -n planck.elf > planck.sym
220
221Size after:
222 text data bss dec hex filename
223 18602 82 155 18839 4997 planck.elf
224
225-------- end --------
226```
227
228If you do not get the above, you **did not** build the firmware, and you will have nothing to flash. If you have the fresh clone from github, it was probably something gone wrong in this install process, go check and see what didn't work and threw errors or what steps you might have missed.
229
230But if everything went OK, you are ready to flash! Press the reset button on the bottom of the Planck, wait two seconds, then:
231```
232$ make dfu
233```
234.
235.
236.
237profit!!!