diff options
| author | yoyoerx <kevin.wepasnick@gmail.com> | 2016-03-09 12:16:03 -0500 |
|---|---|---|
| committer | yoyoerx <kevin.wepasnick@gmail.com> | 2016-03-09 12:16:03 -0500 |
| commit | 6bfb9d17cfd8185e664bd4b6af1517d7b066549d (patch) | |
| tree | a5e220872f64874c114a1a9ae0f847801cd11e24 | |
| parent | 7d3ebd7b40b96f576fe4608b33f47329c334925b (diff) | |
| download | qmk_firmware-6bfb9d17cfd8185e664bd4b6af1517d7b066549d.tar.gz qmk_firmware-6bfb9d17cfd8185e664bd4b6af1517d7b066549d.zip | |
Cygwin Based Users Guide v0.4 -corrections/dfu build
| -rwxr-xr-x | keyboard/planck/CYGWIN_GUIDE.md | 146 |
1 files changed, 128 insertions, 18 deletions
diff --git a/keyboard/planck/CYGWIN_GUIDE.md b/keyboard/planck/CYGWIN_GUIDE.md index 2fa4452f1..a7ac17a7f 100755 --- a/keyboard/planck/CYGWIN_GUIDE.md +++ b/keyboard/planck/CYGWIN_GUIDE.md | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | If 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. | 2 | If 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 | 3 | ||
| 4 | 4 | ||
| 5 | This 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`. | 5 | This guide was written step by step as I went through the process on a `Windows 10` `x86_64` and a `Windows 7` `amd k10` based system. This should be generally applicable to to any `Windows` environment with `cygwin`. |
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | #####Do not skip steps. Do not move past a step until the previous step finishes successfully. | 8 | #####Do not skip steps. Do not move past a step until the previous step finishes successfully. |
| @@ -18,14 +18,16 @@ Download the `cygwin` setup ([x86_64](https://cygwin.com/setup-x86_64.exe)) and | |||
| 18 | - devel/gcc-g++ | 18 | - devel/gcc-g++ |
| 19 | - devel/flex | 19 | - devel/flex |
| 20 | - devel/git | 20 | - devel/git |
| 21 | - libs/libglib2.0_0 | 21 | - devel/bison |
| 22 | - devel/make | ||
| 22 | - libs/libgcc1 | 23 | - libs/libgcc1 |
| 23 | - interpreters/m4 | 24 | - interpreters/m4 |
| 24 | - web/wget | 25 | - web/wget |
| 26 | - archive/unzip | ||
| 25 | 27 | ||
| 26 | The following sources will be required: | 28 | The following sources will be required: |
| 27 | - [gmp](https://gmplib.org/) (6.1.0) | 29 | - [gmp](https://gmplib.org/) (6.1.0) |
| 28 | - [mpfr](http://www.mpfr.org/) (3.1.3) | 30 | - [mpfr](http://www.mpfr.org/) (3.1.4) |
| 29 | - [mpc](http://www.multiprecision.org/) (1.0.3) | 31 | - [mpc](http://www.multiprecision.org/) (1.0.3) |
| 30 | - [binutils](https://www.sourceware.org/binutils/) (2.26) | 32 | - [binutils](https://www.sourceware.org/binutils/) (2.26) |
| 31 | - [gcc](https://gcc.gnu.org/) (5.3.0) | 33 | - [gcc](https://gcc.gnu.org/) (5.3.0) |
| @@ -38,17 +40,18 @@ The `dfu-programmer` will be required to flash the new firmware | |||
| 38 | The 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 | 40 | The 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 | 41 | ||
| 40 | ``` | 42 | ``` |
| 43 | $ mkdir ~/local | ||
| 41 | $ mkdir ~/local/avr | 44 | $ mkdir ~/local/avr |
| 42 | $ mkdir ~/src | 45 | $ mkdir ~/src |
| 43 | $ cd ~/src | 46 | $ cd ~/src |
| 44 | $ wget https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 | 47 | $ 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 | 48 | $ wget http://www.mpfr.org/mpfr-3.1.4/mpfr-3.1.4.tar.bz2 |
| 46 | $ wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz | 49 | $ 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 | 50 | $ 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 | 51 | $ 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 | 52 | $ 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 | 53 | $ tar -xjf gmp-6.1.0.tar.bz2 |
| 51 | $ tar -xjf mpfr-3.1.3.tar.bz2 | 54 | $ tar -xjf mpfr-3.1.4.tar.bz2 |
| 52 | $ tar -zxf mpc-1.0.3.tar.gz | 55 | $ tar -zxf mpc-1.0.3.tar.gz |
| 53 | $ tar -zxf binutils-2.26.tar.gz | 56 | $ tar -zxf binutils-2.26.tar.gz |
| 54 | $ tar -zxf gcc-5.3.0.tar.gz | 57 | $ tar -zxf gcc-5.3.0.tar.gz |
| @@ -79,7 +82,7 @@ $ make install | |||
| 79 | 82 | ||
| 80 | ###Build and Install `mpfr` | 83 | ###Build and Install `mpfr` |
| 81 | ``` | 84 | ``` |
| 82 | $ cd ~/src/mpfr-3.1.3 | 85 | $ cd ~/src/mpfr-3.1.4 |
| 83 | $ ./configure --with-gmp-build=../gmp-6.1.0 --enable-static --disable-shared | 86 | $ ./configure --with-gmp-build=../gmp-6.1.0 --enable-static --disable-shared |
| 84 | $ make | 87 | $ make |
| 85 | $ make check | 88 | $ make check |
| @@ -96,7 +99,8 @@ $ make install | |||
| 96 | ``` | 99 | ``` |
| 97 | 100 | ||
| 98 | ##OPTIONAL Part | 101 | ##OPTIONAL Part |
| 99 | You 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. | 102 | You 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). |
| 103 | |||
| 100 | ###Build and Install `gcc` on your Machine | 104 | ###Build and Install `gcc` on your Machine |
| 101 | ``` | 105 | ``` |
| 102 | $ cd ~/src/gcc-5.3.0 | 106 | $ cd ~/src/gcc-5.3.0 |
| @@ -141,7 +145,7 @@ $ make | |||
| 141 | $ make install | 145 | $ make install |
| 142 | ``` | 146 | ``` |
| 143 | 147 | ||
| 144 | For 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`. | 148 | For 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 | 149 | ||
| 146 | ###Build `avr-libc` for AVR | 150 | ###Build `avr-libc` for AVR |
| 147 | ``` | 151 | ``` |
| @@ -151,13 +155,34 @@ $ make | |||
| 151 | $ make install | 155 | $ make install |
| 152 | ``` | 156 | ``` |
| 153 | 157 | ||
| 154 | ##Install `dfu-programmer` | 158 | ### Build and Install the `dfu-programmer` |
| 155 | To 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). | 159 | We can either build our own, or use the precomplied binaries. The precompiled binaries don't play well with `cygwin` so it is better to build them ourselves. The procedure for the precompiled binaries is included at the end of this guide. |
| 156 | Copy 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: | 160 | |
| 161 | The `dfu-programmer` requires `libusb`. So let's go ahead and build that first. | ||
| 162 | |||
| 157 | ``` | 163 | ``` |
| 158 | C:\> set PATH=%PATH%;C:\cygwin64\home\Kevin\local\avr\bin | 164 | $ cd ~/src |
| 165 | $ git clone https://github.com/libusb/libusb.git | ||
| 166 | $ cd libusb | ||
| 167 | $ ./bootstrap.sh | ||
| 168 | $ ./configure --prefix=$PREFIX | ||
| 169 | $ make | ||
| 170 | $ make install | ||
| 159 | ``` | 171 | ``` |
| 160 | Adjust 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: | 172 | |
| 173 | Next, we can build the `dfu-programmer`. This should be quick. | ||
| 174 | ``` | ||
| 175 | $ cd ~/src | ||
| 176 | $ git clone https://github.com/dfu-programmer/dfu-programmer.git | ||
| 177 | $ cd dfu-programmer | ||
| 178 | $ ./bootstrap.sh | ||
| 179 | $ ./configure --prefix=$PREFIX | ||
| 180 | $ make | ||
| 181 | $ make install | ||
| 182 | ``` | ||
| 183 | |||
| 184 | Verify the installation with: | ||
| 185 | |||
| 161 | ``` | 186 | ``` |
| 162 | $ which dfu-programmer | 187 | $ which dfu-programmer |
| 163 | /home/Kevin/local/avr/bin/dfu-programmer | 188 | /home/Kevin/local/avr/bin/dfu-programmer |
| @@ -169,14 +194,22 @@ Type 'dfu-programmer --help' for a list of commands | |||
| 169 | 'dfu-programmer --targets' to list supported target devices | 194 | 'dfu-programmer --targets' to list supported target devices |
| 170 | ``` | 195 | ``` |
| 171 | If you are not getting the above result, you will not be able to flash the firmware! | 196 | If 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 | 197 | ||
| 175 | ####Install the USB drivers | 198 | ###Install the USB drivers |
| 176 | These 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: | 199 | The official Atmel drivers are included in the windows binary version of [`dfu-programmer` 0.7.2](http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip) and allow the `dfu-programmer` to program the firmware. |
| 200 | |||
| 177 | ``` | 201 | ``` |
| 178 | C:\> pnputil -i -a C:\cygwin64\home\Kevin\dfu-prog-usb-1.2.2\atmel_usb_dfu.inf | 202 | $ cd ~/src |
| 203 | $ wget http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip | ||
| 204 | $ unzip dfu-programmer-win-0.7.2.zip -d dfu-programmer-win-0.7.2 | ||
| 205 | |||
| 179 | ``` | 206 | ``` |
| 207 | |||
| 208 | Then, from an **administrator-privileged** `Windows` terminal, run the following command (adjust the path for username as necessary) and accept the prompt that pops up: | ||
| 209 | ``` | ||
| 210 | C:\> pnputil -i -a C:\cygwin64\home\Kevin\src\dfu-programmer-win-0.7.2\dfu-prog-usb-1.2.2\atmel_usb_dfu.inf | ||
| 211 | ``` | ||
| 212 | |||
| 180 | This should be the result: | 213 | This should be the result: |
| 181 | ``` | 214 | ``` |
| 182 | Microsoft PnP Utility | 215 | Microsoft PnP Utility |
| @@ -190,6 +223,8 @@ Published name : oem104.inf | |||
| 190 | Total attempted: 1 | 223 | Total attempted: 1 |
| 191 | Number successfully imported: 1 | 224 | Number successfully imported: 1 |
| 192 | ``` | 225 | ``` |
| 226 | Alternativly, the `Windows` driver can be installed when prompted by `Windows` when the keyboard is attached. Do not let `Windows` search for a driver; specify the path to search for a driver and point it to the `atmel_usb_dfu.inf` file. | ||
| 227 | |||
| 193 | 228 | ||
| 194 | ##Building and Flashing the Planck firmware! | 229 | ##Building and Flashing the Planck firmware! |
| 195 | 230 | ||
| @@ -235,3 +270,78 @@ $ make dfu | |||
| 235 | . | 270 | . |
| 236 | . | 271 | . |
| 237 | profit!!! | 272 | profit!!! |
| 273 | |||
| 274 | |||
| 275 | |||
| 276 | |||
| 277 | |||
| 278 | ##extra bits... | ||
| 279 | |||
| 280 | |||
| 281 | |||
| 282 | ###Installing Precompiled `dfu-programmer` Binaries (Not recommended) | ||
| 283 | To install the `dfu-programmer` from the binaries, we must get if from [the `dfu-programmer` website](https://dfu-programmer.github.io/) ([0.7.2](http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip)). | ||
| 284 | Copy this file into your `cygwin` home\src directory. (For me, it is `C:\cygwin64\home\Kevin\src`), 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-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: | ||
| 285 | ``` | ||
| 286 | C:\> set PATH=%PATH%;C:\cygwin64\home\Kevin\local\avr\bin | ||
| 287 | ``` | ||
| 288 | Adjust your path (for username) as needed. | ||
| 289 | Then, rename `libusb0_x86.dll` to `libusb0.dll`. | ||
| 290 | You can tell that you were successful by trying to execute 'dfu-programmer' from the 'cygwin' prompt: | ||
| 291 | ``` | ||
| 292 | $ which dfu-programmer | ||
| 293 | /home/Kevin/local/avr/bin/dfu-programmer | ||
| 294 | |||
| 295 | $ dfu-programmer | ||
| 296 | dfu-programmer 0.7.2 | ||
| 297 | https://github.com/dfu-programmer/dfu-programmer | ||
| 298 | Type 'dfu-programmer --help' for a list of commands | ||
| 299 | 'dfu-programmer --targets' to list supported target devices | ||
| 300 | ``` | ||
| 301 | If you are not getting the above result, you will not be able to flash the firmware! | ||
| 302 | - Try making sure your `PATH` variables are set correctly for both `Windows` and `cygwin`. | ||
| 303 | - Make sure the `dll` is named correctly. | ||
| 304 | - Do not extract it with `cygwin`'s `unzip` as it does not set the executable permission. If you did it anyway, do `chmod +x dfu-programmer.exe`. | ||
| 305 | |||
| 306 | |||
| 307 | ##Debugging Tools | ||
| 308 | |||
| 309 | These tools are for debugging your firmware, etc. before flashing. Theoretically, it can save your flash memory from wearing out. However, these tool do not work 100% for the Planck firmware. | ||
| 310 | |||
| 311 | ### `gdb` for AVR | ||
| 312 | `gdb` has a simulator for AVR but it does not support all instructions (like WDT), so it immediately crashes when running the Planck firmware (because `lufa.c` disables the WDT in the first few lines of execution). But it can still be useful in debugging example code and test cases, if you know how to use it. | ||
| 313 | |||
| 314 | ``` | ||
| 315 | $ cd ~/src | ||
| 316 | $ git clone git://sourceware.org/git/binutils-gdb.git | ||
| 317 | $ cd binutils-gdb | ||
| 318 | $ ./bootstrap | ||
| 319 | $ mkdir obj-avr | ||
| 320 | $ cd obj-avr | ||
| 321 | $ ../configure --prefix=$PREFIX --target=avr --build=x86_64-unknown-cygwin --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --disable-nls --enable-static | ||
| 322 | $ make | ||
| 323 | $ make install | ||
| 324 | ``` | ||
| 325 | |||
| 326 | |||
| 327 | ### `simulavr` | ||
| 328 | `simulavr` is an AVR simulator. It runs the complied AVR elf's. `simulavr` does not support the `atmega32u4` device... it does `atmega32` but that is not good enough for the firmware (no PORTE and other things), so you cannot run the Planck firmware. I use it to simulate ideas I have for features in separate test projects. | ||
| 329 | |||
| 330 | This one is a major pain in the butt because it has a lot of dependencies and it is almost always buggy. I will do my best to explain it but... it was hard to figure out. A few things need to be changed in the 'Makefile' to make it work in `cygwin`. | ||
| 331 | |||
| 332 | |||
| 333 | ``` | ||
| 334 | $ cd ~/src | ||
| 335 | $ git clone https://github.com/Traumflug/simulavr.git | ||
| 336 | $ cd simulavr | ||
| 337 | $ ./bootstrap | ||
| 338 | $ ./configure --prefix=$PREFIX --enable-static --disable-tcl --disable-doxygen-doc | ||
| 339 | ``` | ||
| 340 | Edit `src/Makefile.am` now so that `-no-undefined` is included (I did this by removing the SYS_MINGW conditional surrounding `libsim_la_LDFLAGS += -no-undefined` and `libsimulavr_la_LDFLAGS += -no-undefined \ libsimulavr_la_LIBADD += $(TCL_LIB)`. Also, `$(EXEEXT)` is added after `kbdgentables` in two places. | ||
| 341 | |||
| 342 | ``` | ||
| 343 | $ make | ||
| 344 | $ make install | ||
| 345 | ``` | ||
| 346 | |||
| 347 | |||
