upload
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

PCB_GUIDE.md 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # Planck Firmware Guide
  2. ## Setting up the environment
  3. ### Windows
  4. 1. 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**.
  5. 2. 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.
  6. 3. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer.
  7. 4. Right-click on the 1-setup-path-win batch script, select "Run as administrator", and accept the User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up.
  8. 5. 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!
  9. ### Mac
  10. If you're using homebrew, you can use the following commands:
  11. brew tap osx-cross/avr
  12. brew install avr-libc
  13. brew install dfu-programmer
  14. Otherwise, these instructions will work:
  15. 1. Install Xcode from the App Store.
  16. 2. Install the Command Line Tools from `Xcode->Preferences->Downloads`.
  17. 3. Install [DFU-Programmer][dfu-prog].
  18. ### Linux
  19. 1. Install AVR GCC with your favorite package manager.
  20. 2. Install [DFU-Programmer][dfu-prog].
  21. Note that, since it will be directly accessing USB hardware, the
  22. `dfu-programmer` program needs to be run as root.
  23. ## Verify Your Installation
  24. 1. Clone the following repository: https://github.com/jackhumbert/qmk_firmware
  25. 2. Open a Terminal and `cd` into `qmk_firmware/keyboard/planck`
  26. 3. Run `make`. This should output a lot of information about the build process.
  27. ## Using the built-in functions
  28. Here is a list of some of the functions available from the command line:
  29. * `make clean`: clean the environment - may be required in-between builds
  30. * `make`: compile the code
  31. * `make KEYMAP=<keymap>`: compile with the extended keymap file `extended_keymaps/extended_keymap_<keymap>.c`
  32. * `make dfu`: build and flash the layout to the PCB
  33. * `make dfu-force`: build and force-flash the layout to the PCB (may be require for first flash)
  34. Generally, the instructions to flash the PCB are as follows:
  35. 1. Make changes to the appropriate keymap file
  36. 2. Save the file
  37. 3. `make clean`
  38. 4. Press the reset button on the PCB/press the key with the `RESET` keycode
  39. 5. `make <arguments> dfu` - use the necessary `KEYMAP=<keymap>` and/or `COMMON=true` arguments here.
  40. ## Troubleshooting
  41. If you see something like this
  42. 0 [main] sh 13384 sync_with_child: child 9716(0x178) died before initialization with status code 0xC0000142
  43. 440 [main] sh 13384 sync_with_child: *** child state waiting for longjmp
  44. /usr/bin/sh: fork: Resource temporarily unavailable
  45. after running 'make' on Windows than you are encountering a very popular issue with WinAVR on Windows 8.1 and 10.
  46. You can easily fix this problem by replacing msys-1.0.dll in WinAVR/utils/bin with [this one](http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip).
  47. Restart your system and everything should work fine!
  48. If you see this
  49. dfu-programmer atmega32u4 erase
  50. process_begin: CreateProcess(NULL, dfu-programmer atmega32u4 erase, ...) failed.
  51. make (e=2): The system cannot find the file specified.
  52. make: *** [dfu] Error 2
  53. when trying to 'make dfu' on Windows you need to copy the dfu-programmer.exe to qmk_firmware/keyboard/planck.
  54. ## Quantum MK Firmware
  55. ### Keymap
  56. Unlike the other keymaps, prefixing the keycodes with `KC_` is required. A full list of the keycodes is available [here](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keycode.txt). For the keycodes available only in the extended keymap, see this [header file](https://github.com/jackhumbert/qmk_firmware/blob/master/quantum/keymap_common.h).
  57. You can use modifiers with keycodes like this:
  58. LCTL(KC_C)
  59. Which will generate Ctrl+c. These are daisy-chainable, meaning you can do things like:
  60. LCTL(LALT(KC_C))
  61. That will generate Ctrl+Alt+c. The entire list of these functions is here:
  62. * `LCTL()`: Left control
  63. * `LSFT()` / `S()`: Left shift
  64. * `LALT()`: Left alt/opt
  65. * `LGUI()`: Left win/cmd
  66. * `RCTL()`: Right control
  67. * `RSFT()`: Right shift
  68. * `RALT()`: Right alt/opt
  69. * `RGUI()`: Right win/cmd
  70. `S(KC_1)`-like entries are useful in writing keymaps for the Planck.
  71. ### Other keycodes
  72. A number of other keycodes have been added that you may find useful:
  73. * `CM_<key>`: the Colemak equivalent of a key (in place of `KC_<key>`), when using Colemak in software (`CM_O` generates `KC_SCLN`)
  74. * `RESET`: jump to bootloader for flashing (same as press the reset button)
  75. * `BL_STEP`: step through the backlight brightnesses
  76. * `BL_<0-15>`: set backlight brightness to 0-15
  77. * `BL_DEC`: lower the backlight brightness
  78. * `BL_INC`: raise the backlight brightness
  79. * `BL_TOGG`: toggle the backlight on/off
  80. ### Function layers
  81. The extended keymap extends the number of function layers from 32 to the near-infinite value of 256. Rather than using `FN<num>` notation (still available, but limited to `FN0`-`FN31`), you can use the `FUNC(<num>)` notation. `F(<num>)` is a shortcut for this.
  82. The function actions are unchanged, and you can see the full list of them [here](https://github.com/jackhumbert/tmk_keyboard/blob/master/common/action_code.h). They are explained in detail [here](https://github.com/jackhumbert/tmk_keyboard/blob/master/doc/keymap.md#2-action).
  83. ### Macros
  84. Macros have been setup in the `keymaps/keymap_default.c` file so that you can use `M(<num>)` to access a macro in the `action_get_macro` section on your keymap. The switch/case structure you see here is required, and is setup for `M(0)` - you'll need to copy and paste the code to look like this (e.g. to support `M(3)`):
  85. switch(id) {
  86. case 0:
  87. return MACRODOWN(TYPE(KC_A), END);
  88. break;
  89. case 1:
  90. return MACRODOWN(TYPE(KC_B), END);
  91. break;
  92. case 2:
  93. return MACRODOWN(TYPE(KC_C), END);
  94. break;
  95. case 3:
  96. return MACRODOWN(TYPE(KC_D), END);
  97. break;
  98. }
  99. return MACRO_NONE;
  100. `MACRODOWN()` is a shortcut for `(record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)` which tells the macro to execute when the key is pressed. Without this, the macro will be executed on both the down and up stroke.
  101. [cygwin]: https://www.cygwin.com/
  102. [mingw]: http://www.mingw.org/
  103. [mhv]: https://infernoembedded.com/products/avr-tools
  104. [winavr]: http://winavr.sourceforge.net/
  105. [crosspack]: http://www.obdev.at/products/crosspack/index.html
  106. [dfu-prog]: http://dfu-programmer.sourceforge.net/