diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-05-27 18:14:21 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-05-27 18:14:21 -0400 |
commit | 7e84b0e3b3d4d5f53c774465c465a17bafb06f7a (patch) | |
tree | 2d5f1d4049bf15c80e84aeeb897172f4a6e8ac49 /docs | |
parent | 704794bae3bf96541b0362ea38b84706d5ee6958 (diff) |
move old doc to docs
Diffstat (limited to 'docs')
-rw-r--r-- | docs/BUILD_GUIDE.md | 103 | ||||
-rw-r--r-- | docs/CYGWIN_GUIDE.md | 352 | ||||
-rw-r--r-- | docs/FUSE.txt | 50 | ||||
-rw-r--r-- | docs/HAND_WIRE.md | 321 | ||||
-rw-r--r-- | docs/PCB_GUIDE.md | 151 | ||||
-rw-r--r-- | docs/POWER.txt | 62 | ||||
-rw-r--r-- | docs/TMK_README.md | 243 | ||||
-rw-r--r-- | docs/USB_NKRO.txt | 160 | ||||
-rw-r--r-- | docs/VAGRANT_GUIDE.md | 27 | ||||
-rw-r--r-- | docs/basic_how_keyboards_work.md | 96 | ||||
-rw-r--r-- | docs/build_old.md | 187 | ||||
-rw-r--r-- | docs/keycode.txt | 261 | ||||
-rw-r--r-- | docs/keymap_config_h_example.h | 8 | ||||
-rw-r--r-- | docs/keymap_makefile_example.mk | 21 | ||||
-rw-r--r-- | docs/keymap_old.md | 685 | ||||
-rw-r--r-- | docs/other_projects.md | 62 |
16 files changed, 2789 insertions, 0 deletions
diff --git a/docs/BUILD_GUIDE.md b/docs/BUILD_GUIDE.md new file mode 100644 index 0000000000..78cf00b917 --- /dev/null +++ b/docs/BUILD_GUIDE.md @@ -0,0 +1,103 @@ +# This guide has now been included in the main readme - please reference that one instead. + +## Build Environment Setup + +### Windows (Vista and later) +1. If you have ever installed WinAVR, uninstall it. +2. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**. +3. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location. +4. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/qmk/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer. +5. Double-click on the 1-setup-path-win batch script to run it. You'll need to accept a User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up. +6. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete! +7. Future build commands should be run from the standard Windows command prompt, which you can find by searching for "command prompt" from the start menu or start screen. Ignore the "MHV AVR Shell". + +### Mac +If you're using [homebrew,](http://brew.sh/) you can use the following commands: + + brew tap osx-cross/avr + brew install avr-libc + brew install dfu-programmer + +This is the recommended method. If you don't have homebrew, [install it!](http://brew.sh/) It's very much worth it for anyone who works in the command line. + +You can also try these instructions: + +1. Install Xcode from the App Store. +2. Install the Command Line Tools from `Xcode->Preferences->Downloads`. +3. Install [DFU-Programmer][dfu-prog]. + +### Linux +Install AVR GCC, AVR libc, and dfu-progammer with your favorite package manager. + +Debian/Ubuntu example: + + sudo apt-get update + sudo apt-get install gcc-avr avr-libc dfu-programmer + +### Vagrant +If you have any problems building the firmware, you can try using a tool called Vagrant. It will set up a virtual computer with a known configuration that's ready-to-go for firmware building. OLKB does NOT host the files for this virtual computer. Details on how to set up Vagrant are in the [VAGRANT_GUIDE file](VAGRANT_GUIDE.md). + +## Verify Your Installation +1. 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. +2. 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. +3. 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`. +4. 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. + +## Customizing, Building, and Deploying Your Firmware + +### The Make command + +The `make` command is how you compile the firmware into a .hex file, which can be loaded by a dfu programmer (like dfu-progammer via `make dfu`) or the [Teensy loader](https://www.pjrc.com/teensy/loader.html) (only used with Teensys). You can run `make` from the root (`/`), your keyboard folder (`/keyboards/<keyboard>/`), or your keymap folder (`/keyboards/<keyboard>/keymaps/<keymap>/`) if you have a `Makefile` there (see the example [here](/doc/keymap_makefile_example.mk)). + +By default, this will generate a `<keyboard>_<keymap>.hex` file in whichever folder you run `make` from. These files are ignored by git, so don't worry about deleting them when committing/creating pull requests. + +* The "root" (`/`) folder is the qmk_firmware folder, in which are `doc`, `keyboard`, `quantum`, etc. +* The "keyboard" folder is any keyboard project's folder, like `/keyboards/planck`. +* The "keymap" folder is any keymap's folder, like `/keyboards/planck/keymaps/default`. + +Below is a list of the useful `make` commands in QMK: + +* `make` - cleans automatically and builds your keyboard and keymap depending on which folder you're in. This defaults to the "default" layout (unless in a keymap folder), and Planck keyboard in the root folder + * `make keyboard=<keyboard>` - specifies the keyboard (only to be used in root) + * `make keymap=<keymap>` - specifies the keymap (only to be used in root and keyboard folder - not needed when in keymap folder) +* `make quick` - skips the clean step (cannot be used immediately after modifying config.h or Makefiles) +* `make dfu` - (requires dfu-programmer) builds and flashes the keymap to your keyboard once placed in reset/dfu mode (button or press `KC_RESET`). This does not work for Teensy-based keyboards like the ErgoDox EZ. + * `keyboard=` and `keymap=` are compatible with this +* `make all-keyboards` - builds all keymaps for all keyboards and outputs status of each (use in root) +* `make all-keyboards-default` - builds all default keymaps for all keyboards and outputs status of each (use in root) +* `make all-keymaps [keyboard=<keyboard>]` - builds all of the keymaps for whatever keyboard folder you're in, or specified by `<keyboard>` +* `make all-keyboards-quick`, `make all-keyboards-default-quick` and `make all-keymaps-quick [keyboard=<keyboard>]` - like the normal "make-all-*" commands, but they skip the clean steps + +Other, less useful functionality: + +* `make COLOR=false` - turns off color output +* `make SILENT=true` - turns off output besides errors/warnings +* `make VERBOSE=true` - outputs all of the avr-gcc stuff (not interesting) + +### The Makefile + +There are 3 different `make` and `Makefile` locations: + +* root (`/`) +* keyboard (`/keyboards/<keyboard>/`) +* keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`) + +The root contains the code used to automatically figure out which keymap or keymaps to compile based on your current directory and commandline arguments. It's considered stable, and shouldn't be modified. The keyboard one will contain the MCU set-up and default settings for your keyboard, and shouldn't be modified unless you are the producer of that keyboard. The keymap Makefile can be modified by users, and is optional. It is included automatically if it exists. You can see an example [here](/doc/keymap_makefile_example.mk) - the last few lines are the most important. The settings you set here will override any defaults set in the keyboard Makefile. **It is required if you want to run `make` in the keymap folder.** + +### The `config.h` file + +There are 2 `config.h` locations: + +* keyboard (`/keyboards/<keyboard>/`) +* keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`) + +The keyboard `config.h` is included only if the keymap one doesn't exist. The format to use for your custom one [is here](/doc/keymap_config_h_example.h). If you want to override a setting from the parent `config.h` file, you need to do this: + +``` +#undef MY_SETTING +#define MY_SETTING 4 +``` + +For a value of `4` for this imaginary setting. So we `undef` it first, then `define` it. + +You can then override any settings, rather than having to copy and paste the whole thing. diff --git a/docs/CYGWIN_GUIDE.md b/docs/CYGWIN_GUIDE.md new file mode 100644 index 0000000000..05d71961a4 --- /dev/null +++ b/docs/CYGWIN_GUIDE.md @@ -0,0 +1,352 @@ +#Planck Advanced (but not too advanced) `cygwin` Users Guide +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. + +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`. + +#####Do not skip steps. Do not move past a step until the previous step finishes successfully. + +Based on [avr-libc installation guide](http://www.nongnu.org/avr-libc/user-manual/install_tools.html) + +##Get the Required Packages +Download 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: +- devel/git +- devel/gcc-core +- devel/gcc-g++ +- devel/flex +- devel/bison +- devel/make +- devel/texinfo +- devel/gettext-devel +- devel/automake +- devel/autoconfig +- devel/libtool +- text/gettext +- libs/libgcc1 +- interpreters/m4 +- web/wget +- archive/unzip + +The following sources will be required: +- [gmp](https://gmplib.org/) (6.1.0) +- [mpfr](http://www.mpfr.org/) (3.1.4) +- [mpc](http://www.multiprecision.org/) (1.0.3) +- [binutils](https://www.sourceware.org/binutils/) (2.26) +- [gcc](https://gcc.gnu.org/) (5.3.0) +- [avr-libc](http://www.nongnu.org/avr-libc/) (2.0.0) + +The `dfu-programmer` will be required to flash the new firmware +- [dfu-programmer](https://dfu-programmer.github.io/) (0.7.2) + +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 +``` +$ mkdir ~/local +$ mkdir ~/local/avr +$ mkdir ~/src +$ cd ~/src +$ wget https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 +$ wget http://www.mpfr.org/mpfr-3.1.4/mpfr-3.1.4.tar.bz2 +$ wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz +$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.gz +$ wget http://mirror0.babylon.network/gcc/releases/gcc-5.3.0/gcc-5.3.0.tar.gz +$ wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-2.0.0.tar.bz2 +$ tar -xjf gmp-6.1.0.tar.bz2 +$ tar -xjf mpfr-3.1.4.tar.bz2 +$ tar -zxf mpc-1.0.3.tar.gz +$ tar -zxf binutils-2.26.tar.gz +$ tar -zxf gcc-5.3.0.tar.gz +$ tar -xjf avr-libc-2.0.0.tar.bz2 +``` + +##Setup the Build Environment +These 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. +``` +$ PREFIX=$HOME/local/avr +$ export PREFIX +$ PATH=/usr/local/bin:/usr/local/lib:/usr/local/include:/bin:/lib:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS +$ PATH=$PATH:$PREFIX/bin:$PREFIX/lib +$ export PATH +``` + +##The `gcc` Required Math Library Packages +The following packages are required to be complied and installed in order to compile `gcc`. They are not sufficiently 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. Verfiy that for each package, `make check` returns all passing and no fails. + +###Build and Install `gmp` +``` +$ cd ~/src/gmp-6.1.0 +$ ./configure --enable-static --disable-shared +$ make +$ make check +$ make install +``` + +###Build and Install `mpfr` +``` +$ cd ~/src/mpfr-3.1.4 +$ ./configure --with-gmp-build=../gmp-6.1.0 --enable-static --disable-shared +$ make +$ make check +$ make install +``` + +###Build and Install `mpc` +``` +$ cd ~/src/mpc-1.0.3 +$ ./configure --with-gmp=/usr/local --with-mpfr=/usr/local --enable-static --disable-shared +$ make +$ make check +$ make install +``` + +##OPTIONAL Part +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). + +###Build and Install `gcc` for Your Machine +``` +$ cd ~/src/gcc-5.3.0 +$ mkdir obj-local +$ cd obj-local +$ ../configure --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --enable-static --disable-shared +$ make +$ make install +``` +##End OPTIONAL Part + +###Build and Install `binutils` for Your Machine +``` +$ cd ~/src/binutils-2.26 +$ mkdir obj-local +$ cd obj-local +$ ../configure +$ make +$ make install +``` + +##Buliding `binutils`, `gcc`, and `avr-libc` for the AVR system +Now 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. + +###Build `binutils` for AVR +If you plan to build and install `avr-gdb` also, use the `gdb` install at the end of this guide as it also builds the `binutils` +``` +$ cd ~/src/binutils-2.26 +$ mkdir obj-avr +$ cd obj-avr +$ ../configure --prefix=$PREFIX --target=avr --disable-nls +$ make +$ make install +``` + +###Build `gcc` for AVR +``` +$ cd ~/src/gcc-5.3.0 +$ mkdir obj-avr +$ cd obj-avr +$ ../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 +$ make +$ make install +``` + +###Build `avr-libc` for AVR +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`. +``` +$ cd ~/src/avr-libc-2.0.0 +$ ./configure --prefix=$PREFIX --build=x86_64-unknown-cygwin --host=avr +$ make +$ make install +``` + +##Building 'dfu-programmer' for flashing the firmware via USB and installing the drivers +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. + +### Build and Install the `libusb` +The `dfu-programmer` requires `libusb` so that it can interact with the USB system. These repos must be bootstrapped in order to create an appropriate `./configure` and `Makefile` for your system. +``` +$ cd ~/src +$ git clone https://github.com/libusb/libusb.git +$ cd libusb +$ ./bootstrap.sh +$ ./configure +$ make +$ make install +``` + +### Build and Install the `dfu-programmer` +``` +$ cd ~/src +$ git clone https://github.com/dfu-programmer/dfu-programmer.git +$ cd dfu-programmer +$ ./bootstrap.sh +$ ./configure +$ make +$ make install +``` + +Verify the installation with: +``` +$ which dfu-programmer +/usr/local/bin/dfu-programmer + +$ dfu-programmer +dfu-programmer 0.7.2 +https://github.com/dfu-programmer/dfu-programmer +Type 'dfu-programmer --help' for a list of commands + 'dfu-programmer --targets' to list supported target devices +``` +If you are not getting the above result, you will not be able to flash the firmware! + +###Install the USB drivers +The 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). +``` +$ cd ~/src +$ wget http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip +$ unzip dfu-programmer-win-0.7.2.zip -d dfu-programmer-win-0.7.2 +``` + +or + +The official drivers are found in [Atmel's `FLIP` installer](http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe). Download and then install `FLIP`. Upon installation, the drivers will be found in `C:\Program Files (x86)\Atmel\Flip 3.4.7\usb`. + +Then, from an **administrator-privileged** `Windows` terminal, run the following command (adjust the path for username, etc. as necessary) and accept the prompt that pops up: +``` +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 +or +C:\> pnputil -i -a "C:\Program Files (x86)\Atmel\Flip 3.4.7\usb\atmel_usb_dfu.inf" +``` + +This should be the result: +``` +Microsoft PnP Utility + +Processing inf : atmel_usb_dfu.inf +Successfully installed the driver on a device on the system. +Driver package added successfully. +Published name : oem104.inf + + +Total attempted: 1 +Number successfully imported: 1 +``` + +Alternatively, 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. + +##Building and Flashing the Planck firmware! +If you did everything else right. This part should be a snap! Grab the latest sources from `github`, make the Plank firmware, then flash it. + +###Build Planck and Load the Firmware +``` +$ cd ~/src +$ git clone https://github.com/qmk/qmk_firmware.git +$ cd qmk_firmware/keyboards/planck +$ make +``` + +Make sure there are no errors. You should end up with this or something similar: +``` +Creating load file for Flash: planck.hex +avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature planck.elf planck.hex + +Creating load file for EEPROM: planck.eep +avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ +--change-section-lma .eeprom=0 --no-change-warnings -O ihex planck.elf planck.eep || exit 0 + +Creating Extended Listing: planck.lss +avr-objdump -h -S -z planck.elf > planck.lss + +Creating Symbol Table: planck.sym +avr-nm -n planck.elf > planck.sym + +Size after: + text data bss dec hex filename + 18602 82 155 18839 4997 planck.elf + +-------- end -------- +``` + +If 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. + +But if everything went OK, you are ready to flash! Press the reset button on the bottom of the Planck, wait two seconds, then: +``` +$ make dfu +``` +. +. +. +profit!!! + + + + + +##extra bits... + +###Installing Precompiled `dfu-programmer` Binaries (not recommended for `cygwin`) +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)). + +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`. This is because the `dfu-programmer` binary is `mingw` based, not `cygwin` based, so the `dlls` do not cooperate. I achieved acceptable pathing by moving the files to `C:\cygwin64\home\Kevin\local\avr\bin` Then, in a `WINDOWS` command prompt running (Adjusting your path for username, etc. as needed): +``` +C:\> set PATH=%PATH%;C:\cygwin64\home\Kevin\local\avr\bin +``` + +Then, rename `libusb0_x86.dll` to `libusb0.dll`. + +You can tell that you were successful by trying to execute 'dfu-programmer' from the 'cygwin' prompt: +``` +$ which dfu-programmer +/home/Kevin/local/avr/bin/dfu-programmer + +$ dfu-programmer +dfu-programmer 0.7.2 +https://github.com/dfu-programmer/dfu-programmer +Type 'dfu-programmer --help' for a list of commands + 'dfu-programmer --targets' to list supported target devices +``` + +If you are not getting the above result, you will not be able to flash the firmware! +- Try making sure your `PATH` variables are set correctly for both `Windows` and `cygwin`. +- Make sure the `dll` is named correctly. +- 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`. +- Still have problems? Try building it instead. + + +##Debugging Tools + +These tools are for debugging your firmware, etc. before flashing. Theoretically, it can save your memory from wearing out. However, these tool do not work 100% for the Planck firmware. + +### `gdb` for AVR +`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. + +``` +$ cd ~/src +$ git clone git://sourceware.org/git/binutils-gdb.git +$ cd binutils-gdb +$ mkdir obj-avr +$ cd obj-avr +$ ../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 +$ make +$ make install +``` + +### `simulavr` +`simulavr` is an AVR simulator. It runs the complied AVR elfs. `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. + +This one is a major pain in the butt because it has a lot of dependencies and it is 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`. + + +``` +$ cd ~/src +$ git clone https://github.com/Traumflug/simulavr.git +$ cd simulavr +$ ./bootstrap +$ ./configure --prefix=$PREFIX --enable-static --disable-tcl --disable-doxygen-doc +``` + 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. + +``` +$ make +$ make install +``` + + +TODO: +- git repos for all sources +- command line magic for cygwin setup +- better options for `dfu-drivers` diff --git a/docs/FUSE.txt b/docs/FUSE.txt new file mode 100644 index 0000000000..99ddd2d186 --- /dev/null +++ b/docs/FUSE.txt @@ -0,0 +1,50 @@ +Atmega32u4 Fuse/Lock Bits for Planck/Atomic/Preonic +========================= + + Low Fuse: 0x5E + High Fuse: 0x99 + Extended Fuse: 0xF3 + Lock Byte: 0xFF + + +ATMega168P Fuse/Lock Bits +========================= +This configuration is from usbasploader's Makefile. + + HFUSE 0xD6 + LFUSE 0xDF + EFUSE 0x00 + LOCK 0x3F(intact) + +#--------------------------------------------------------------------- +# ATMega168P +#--------------------------------------------------------------------- +# Fuse extended byte: +# 0x00 = 0 0 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800) +# \+/ +# +------- BOOTSZ (00 = 2k bytes) +# Fuse high byte: +# 0xd6 = 1 1 0 1 0 1 1 0 +# ^ ^ ^ ^ ^ \-+-/ +# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V) +# | | | | + --------- EESAVE (preserve EEPROM over chip erase) +# | | | +-------------- WDTON (if 0: watchdog always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire enable) +# +-------------------- RSTDISBL (reset pin is enabled) +# Fuse low byte: +# 0xdf = 1 1 0 1 1 1 1 1 +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (external >8M crystal) +# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) +# | +------------------ CKOUT (if 0: Clock output enabled) +# +-------------------- CKDIV8 (if 0: divide by 8) + + +# Lock Bits +# 0x3f = - - 1 1 1 1 1 1 +# \ / \-/ \-/ +# | | +----- LB 2..1 (No memory lock features enabled) +# | +--------- BLB0 2..1 (No restrictions for SPM or LPM accessing the Application section) +# +--------------- BLB1 2..1 (No restrictions for SPM or LPM accessing the Boot Loader section) + diff --git a/docs/HAND_WIRE.md b/docs/HAND_WIRE.md new file mode 100644 index 0000000000..17ef3116f9 --- /dev/null +++ b/docs/HAND_WIRE.md @@ -0,0 +1,321 @@ +# Quantum Hand-wiring Guide + +Parts list: +* *x* keyswitches (MX, Matias, Gateron, etc) +* *x* diodes +* Keyboard plate (metal, plastic, cardboard, etc) +* Wire (strained for wiring to the Teensy, anything for the rows/columns) +* Soldering iron set at 600ºF or 315ºC (if temperature-controlled) +* Resin-cored solder (leaded or lead-free) +* Adequate ventilation/a fan +* Tweezers (optional) +* Wire cutters/snippers + +## How the matrix works (why we need diodes) + +The microcontroller (in this case, the Teensy 2.0) will be setup up via the firmware to send a logical 1 to the columns, one at a time, and read from the rows, all at once - this process is called matrix scanning. The matrix is a bunch of open switches that, by default, don't allow any current to pass through - the firmware will read this as no keys being pressed. As soon as you press one key down, the logical 1 that was coming from the column the keyswitch is attached to gets passed through the switch and to the corresponding row - check out the following 2x2 example: + + Column 0 being scanned Column 1 being scanned + x x + col0 col1 col0 col1 + | | | | + row0 ---(key0)---(key1) row0 ---(key0)---(key1) + | | | | + row1 ---(key2)---(key3) row1 ---(key2)---(key3) + +The `x` represents that the column/row associated has a value of 1, or is HIGH. Here, we see that no keys are being pressed, so no rows get an `x`. For one keyswitch, keep in mind that one side of the contacts is connected to its row, and the other, its column. + +When we press `key0`, `col0` gets connected to `row0`, so the values that the firmware receives for that row is `0b01` (the `0b` here means that this is a bit value, meaning all of the following digits are bits - 0 or 1 - and represent the keys in that column). We'll use this notation to show when a keyswitch has been pressed, to show that the column and row are being connected: + + Column 0 being scanned Column 1 being scanned + x x + col0 col1 col0 col1 + | | | | + x row0 ---(-+-0)---(key1) row0 ---(-+-0)---(key1) + | | | | + row1 ---(key2)---(key3) row1 ---(key2)---(key3) + +We can now see that `row0` has an `x`, so has the value of 1. As a whole, the data the firmware receives when `key0` is pressed is + + col0: 0b01 + col1: 0b00 + │└row0 + └row1 + +A problem arises when you start pressing more than one key at a time. Looking at our matrix again, it should become pretty obvious: + + Column 0 being scanned Column 1 being scanned + x x + col0 col1 col0 col1 + | | | | + x row0 ---(-+-0)---(-+-1) x row0 ---(-+-0)---(-+-1) + | | | | + x row1 ---(key2)---(-+-3) x row1 ---(key2)---(-+-3) + + Remember that this ^ is still connected to row1 + +The data we get from that is: + + col0: 0b11 + col1: 0b11 + │└row0 + └row1 + +Which isn't accurate, since we only have 3 keys pressed down, not all 4. This behavior is called ghosting, and only happens in odd scenarios like this, but can be much more common on a bigger keyboard. The way we can get around this is by placing a diode after the keyswitch, but before it connects to its row. A diode only allows current to pass through one way, which will protect our other columns/rows from being activated in the previous example. We'll represent a dioded matrix like this; + + Column 0 being scanned Column 1 being scanned + x x + col0 col1 col0 col1 + │ │ | │ + (key0) (key1) (key0) (key1) + ! │ ! │ ! | ! │ + row0 ─────┴────────┘ │ row0 ─────┴────────┘ │ + │ │ | │ + (key2) (key3) (key2) (key3) + ! ! ! ! + row1 ─────┴────────┘ row1 ─────┴────────┘ + +In practical applications, the black line of the diode will be placed facing the row, and away from the keyswitch - the `!` in this case is the diode, where the gap represents the black line. A good way to remember this is to think of this symbol: `>|` + +Now when we press the three keys, invoking what would be a ghosting scenario: + + Column 0 being scanned Column 1 being scanned + x x + col0 col1 col0 col1 + │ │ │ │ + (┌─┤0) (┌─┤1) (┌─┤0) (┌─┤1) + ! │ ! │ ! │ ! │ + x row0 ─────┴────────┘ │ x row0 ─────┴────────┘ │ + │ │ │ │ + (key2) (┌─┘3) (key2) (┌─┘3) + ! ! ! ! + row1 ─────┴────────┘ x row1 ─────┴────────┘ + +Things act as they should! Which will get us the following data: + + col0: 0b01 + col1: 0b11 + │└row0 + └row1 + +The firmware can then use this correct data to detect what it should do, and eventually, what signals it needs to send to the OS. + +## The actual hand-wiring + +### Getting things in place + +When starting this, you should have all of your stabilisers and keyswitches already installed (and optionally keycaps). If you're using a Cherry-type stabiliser (plate-mounted only, obviously), you'll need to install that before your keyswitches. If you're using Costar ones, you can installed them afterwards. + +To make things easier on yourself, make sure all of the keyswitches are oriented the same way (if they can be - not all layouts support this). Despite this, it's important to remember that the contacts on the keyswitches are completely symmetrical. We'll be using the keyswitch's left side contact for wiring the rows, and the right side one for wiring the columns. + +Get your soldering iron heated-up and collect the rest of the materials from the part list at the beginning of the guide. Place your keyboard so that the bottoms of the keyswitches are accessible - it may be a good idea to place it on a cloth to protect your keyswitches/keycaps. + +Before continuing, plan out where you're going to place your Teensy. If you're working with a board that has a large (6.25u) spacebar, it may be a good idea to place it in-between switches against the plate. Otherwise, you may want to trim some of the leads on the keyswitches where you plan on putting it - this will make it a little harder to solder the wire/diodes, but give you more room to place the Teensy. + +### Preparing the diodes + +It's a little easier to solder the diodes in place if you bend them at a 90º angle immediately after the black line - this will help to make sure you put them on the right way (direction matters), and in the correct position. The diodes will look like this when bent (with longer leads): + + ┌─────┬─┐ + ───┤ │ ├─┐ + └─────┴─┘ │ + │ + +We'll be using the long lead at the bent end to connect it to the elbow (bent part) of the next diode, creating the row. + +### Soldering the diodes + +Starting at the top-left switch, place the diode (with tweezers if you have them) on the switch so that the diode itself is vertically aligned, and the black line is facing toward you. The straight end of the diode should be touching the left contact on the switch, and the bent end should be facing to the right and resting on the switch there, like this: + + │o + ┌┴┐ o + │ │ O + ├─┤ + └┬┘ + └───────────── + +Letting the diode rest, grab your solder, and touch both it and the soldering iron to the left contact at the same time - the rosin in the solder should make it easy for the solder to flow over both the diode and the keyswitch contact. The diode may move a little, and if it does, carefully position it back it place by grabbing the bent end of the diode - the other end will become hot very quickly. If you find that it's moving too much, using needle-nose pliers of some sort may help to keep the diode still when soldering. + +The smoke that the rosin releases is harmful, so be careful not to breath it or get it in your eyes/face. + +After soldering things in place, it may be helpful to blow on the joint to push the smoke away from your face, and cool the solder quicker. You should see the solder develop a matte (not shiney) surface as it solidifies. Keep in mind that it will still be very hot afterwards, and will take a couple minutes to be cool to touch. Blow on it will accelerate this process. + +When the first diode is complete, the next one will need to be soldered to both the keyswitch, and the previous diode at the new elbow. That will look something like this: + + │o │o + ┌┴┐ o ┌┴┐ o + │ │ O │ │ O + ├─┤ ├─┤ + └┬┘ └┬┘ + └────────────────┴───────────── + +After completing a row, use the wire cutters to trim the excess wire from the tops of the diodes, and from the right side on the final switch. This process will need to completed for each row you have. + +When all of the diodes are completely soldered, it's a good idea to quickly inspect each one to ensure that your solder joints are solid and sturdy - repairing things after this is possible, but more difficult. + +### Soldering the columns + +You'll have some options in the next process - it's a good idea to insulate the column wires (since the diodes aren't), but if you're careful enough, you can use exposed wires for the columns - it's not recommended, though. If you're using single-cored wire, stripping the plastic off of the whole wire and feeding it back on is probably the best option, but can be difficult depending on the size and materials. You'll want to leave parts of the wire exposed where you're going to be solder it onto the keyswitch. + +If you're using stranded wire, it's probably easiest to just use a lot of small wires to connect each keyswitch along the column. It's possible to use one and melt through the insulation, but this isn't recommended, will produce even more harmful fumes, and can ruin your soldering iron. + +Before beginning to solder, it helps to have your wire pre-bent (if using single-cored), or at least have an idea of how you're going to route the column (especially if you're making a staggered board). Where you go in particular doesn't matter too much, as we'll be basing our keymap definitions on how it was wired - just make sure every key in a particular row is in a unique column, and that they're in order from left to right. + +If you're not using any insulation, you can try to keep the column wires elevated, and solder them near the tips of the keyswitch contacts - if the wires are sturdy enough, they won't short out to the row wiring an diodes. + +### Wiring things to the Teensy + +Now that the matrix itself is complete, it's time to connect what you've done to the Teensy. You'll be needing the number of pins equal to your number of columns + your number of rows. There are some pins on the Teensy that are special, like D6 (the LED on the chip), or some of the UART, SPI, I2C, or PWM channels, but only avoid those if you're planning s |