Kiibohd Controller
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. The Kiibohd Controller
  2. ======================
  3. This README is a bit long, just look at the sections you are interested in.
  4. You only need to install avr-gcc if you want to build for the Teensy 2.0/2.0++.
  5. Everything else needs an arm-none-eabi-gcc compiler (e.g. Infinity keyboard,
  6. Teensy 3.0/3.1, McHCK).
  7. Linux is the ideal build environment (preferably recent'ish). In the near
  8. future I'll make available an Arch Linux VM for building/manufacturing tests.
  9. Building on Mac should be ok for 99% of users with Macports (haven't tried
  10. Brew). The dfu Bootloader will not build correctly with the old version of
  11. arm-none-eabi-gcc that Macports currently has (4.7.3). This is due to a bug
  12. with lto (link time optimizations) which makes the resulting binary too big to
  13. fit on the chip (must be less than 4096 Bytes).
  14. Building on Windows should also be fine for 99% of users, but takes a bunch of
  15. work to setup (because Windows is a crappy dev environment). Cygwin is
  16. currently required along with some non-Cygwin compilers and utilities (because
  17. they are not available for Cygwin). The dfu Bootloader will not build because
  18. of a Make 3.81+ bug/feature that removed support for non-Unix (Windows)
  19. filenames as dependencies of targets. If you [replace the version of Make in
  20. Cygwin](http://stackoverflow.com/questions/601516/cygwin-make-error-target-pattern-contains-no)
  21. it should work. However, make sure that the flash size is no larger than 4096
  22. Bytes or the bootloader will not work. Things will likely break if there are
  23. **SPACES IN YOUR PATHS**. I install cygwin to `C:\cygwin64`. If you are brave
  24. and have programming knowledge, I will accept patches to fix any issues
  25. regarding spaces in paths.
  26. Please give authors credit for modules used if you use in a distributed
  27. product :D
  28. General Dependencies
  29. --------------------
  30. Below listed are the Arch Linux pacman names, AUR packages may be required.
  31. These depend a bit on which targets you are trying to build, but the general
  32. one:
  33. - cmake (2.8 and higher)
  34. - git
  35. - ctags (recommended, not required)
  36. - python3
  37. - libusb1.0 (and -devel)
  38. - make
  39. AVR Specific (Teensy 1.0/++,2.0/++) (try to use something recent, suggested
  40. versions below)
  41. - avr-gcc (~4.8.0)
  42. - avr-binutils (~2.23.2)
  43. - avr-libc (~1.8.0)
  44. ARM Specific (Teensy 3.0/3.1, Infinity Keyboard, McHCK)
  45. - Arch Linux / Mac Ports
  46. - arm-none-eabi-gcc
  47. - arm-none-eaby-binutils
  48. - Windows (https://launchpad.net/gcc-arm-embedded/+download)
  49. - gcc-arm-none-eabi (win32.zip)
  50. Windows Setup
  51. -------------
  52. Compiling on Windows does work, just it's a bunch more work.
  53. First make sure Cygwin is installed - http://www.cygwin.com/ - 32bit or 64bit
  54. is fine. Make sure the following are installed:
  55. - make
  56. - git (needed for some compilation info)
  57. - cmake
  58. - gcc-core
  59. - gcc-g++
  60. - libusb1.0
  61. - libusb1.0-devel
  62. - python3
  63. - ctags (recommended, not required)
  64. Please note, I use cygwin term exclusively for any command line options.
  65. Unless mentioned otherwise, use it. Do NOT use CMD or Powershell.
  66. Also install the [Windows version of CMake](http://cmake.org/cmake/resources/software.html)
  67. (3+ is ideal) - Select "Do not add CMake to system PATH". This is in addition
  68. to the Cygwin version. This is an easier alternative to installing another C
  69. compiler. Add the following line to your .bashrc, making sure the CMake path
  70. is correct:
  71. echo "alias wincmake=\"PATH='/cygdrive/c/Program Files (x86)/CMake'/bin:'${PATH}' cmake -G 'Unix Makefiles'\"" >> ~/.bashrc
  72. Install the [PJRC Virtual Serial Port Driver](http://pjrc.com/teensy/serial_install.exe).
  73. Next, install the compiler(s) you want.
  74. ### AVR GCC
  75. You just need the
  76. [Atmel AVR 8-bit Toolchain](http://www.atmel.com/tools/atmelavrtoolchainforwindows.aspx).
  77. The latest should be fine, as of writing it was 3.4.3.
  78. Extract the files to a directory, say `C:\avr8-gnu-toolchain`. Then copy all
  79. the folders in that directory to the Cygwin `/usr/local` directory. Mine is
  80. `C:\cygwin64\usr\local`. (You can also just setup the paths, but this is
  81. faster/simpler. Might screw up your Cygwin though).
  82. ### ARM EABI
  83. Download the latest
  84. [GNU Tools for Embedded Processors
  85. gcc-arm-none-eabi](https://launchpad.net/gcc-arm-embedded/+download).
  86. Download `gcc-arm-none-eabi*win32.zip`.
  87. Then extract all the folders/files in the zip to the Cygwin `/usr/local`
  88. directory. Mine is `C:\cygwin64\usr\local`. Or, you can setup paths using
  89. the installer (you have to be more careful, avoid spaces in paths).
  90. CMake Info
  91. ----------
  92. One of the big benefits of using CMake is the ability to build multiple
  93. configurations (for different microcontrollers) at the same time. The
  94. following sections explain in detail what each CMakeLists.txt configuration
  95. option does and what you can change it to. However, it is possible to
  96. configure each of these options using the `-D` command line flag.
  97. For example, to build the Infinity Keyboard default configuration:
  98. ```bash
  99. $ mkdir build_infinity
  100. $ cd build_infinity
  101. $ cmake -DCHIP=mk20dx128vlf5 -DScanModule=MD1 -DMacroModule=PartialMap \
  102. -DOutputModule=pjrcUSB -DDebugModule=full -DBaseMap=defaultMap \
  103. -DDefaultMap="md1Overlay stdFuncMap" -DPartialMaps="hhkbpro2" \
  104. ..
  105. $ make
  106. ```
  107. CMake defaults to the values specified in CMakeLists.txt if not overridden via
  108. the command line.
  109. > NOTE: On Windows, you will have to use "wincmake" instead of "cmake".
  110. Selecting Microcontroller
  111. -------------------------
  112. This is where you select the chip you want to compile for. The build system
  113. will automatically select the compiler needed to compile for your chip.
  114. Open up CMakeLists.txt in your favourite text editor. You are looking for:
  115. ```cmake
  116. ###
  117. # Chip Selection
  118. #
  119. #| You _MUST_ set this to match the microcontroller you are trying to compile for
  120. #| You _MUST_ clean the build directory if you change this value
  121. #|
  122. set( CHIP
  123. # "at90usb162" # Teensy 1.0 (avr)
  124. # "atmega32u4" # Teensy 2.0 (avr)
  125. # "at90usb646" # Teensy++ 1.0 (avr)
  126. # "at90usb1286" # Teensy++ 2.0 (avr)
  127. # "mk20dx128" # Teensy 3.0 (arm)
  128. "mk20dx128vlf5" # McHCK mk20dx128vlf5
  129. # "mk20dx256" # Teensy 3.1 (arm)
  130. CACHE STRING "Microcontroller Chip" )
  131. ```
  132. Just uncomment the chip you want, and comment out the old one.
  133. > NOTE: If you change this option, you will *need* to delete the build
  134. > directory that is created in the Building sections below.
  135. Selecting Modules
  136. -----------------
  137. > WARNING: Not all modules are compatible, and some modules may have
  138. > dependencies on other modules.
  139. This is where the options start getting interesting. The Kiibohd Controller
  140. is designed around a set of 4 types of modules that correspond to different
  141. functionality:
  142. - Scan Module
  143. - Macro Module
  144. - Output Module
  145. - Debug Module
  146. The Scan Module is where the most interesting stuff happens. These modules
  147. take in "keypress data". A converter Scan Module will interpret a protocol
  148. into key press/releases. A matrix Scan Module may inherit from the matrix
  149. module to scan keypress from a matrix This module just has to give
  150. press/release codes, but does have some callback control to other modules
  151. depending on the lifecycle for press/release codes (this can be very
  152. complicated depending on the protocol). Each Scan Module has it's own default
  153. keymap/modifier map. (TODO recommend keymap changing in the Macro Module).
  154. Some scan modules have very specialized hardware requirements, each module
  155. directory should have at least a link to the needed parts and/or schematics
  156. (TODO!).
  157. The Macro Module takes care of the mapping of the key press/release code into
  158. an Output (USB) scan code. Any layering, macros, keypress
  159. intelligence/reaction is done here.
  160. The Output Module is the module dealing with output from the microcontroller.
  161. Currently USB is the only output protocol. Different USB output
  162. implementations are available, pjrc being the safest/least featureful one.
  163. Debug capabilities may depend on the module selected.
  164. The Debug Module enables various things like the Teensy LED on errors, debug
  165. terminal output. (TODO get true UART working in avr, not just arm)
  166. Open up CMakeLists.txt in your favourite text editor. Look for:
  167. ```cmake
  168. ###
  169. # Project Modules
  170. #
  171. #| Note: This is the only section you probably want to modify
  172. #| Each module is defined by it's own folder (e.g. Scan/Matrix represents the "Matrix" module)
  173. #| All of the modules must be specified, as they generate the sources list of files to compile
  174. #| Any modifications to this file will cause a complete rebuild of the project
  175. #| Please look at the {Scan,Macro,Output,Debug} for information on the modules and how to create new ones
  176. ##| Deals with acquiring the keypress information and turning it into a key index
  177. set( ScanModule "MD1"
  178. CACHE STRING "Scan Module" )
  179. ##| Provides the mapping functions for DefaultMap and handles any macro processing before sending to the OutputModule
  180. set( MacroModule "PartialMap"
  181. CACHE STRING "Macro Module" )
  182. ##| Sends the current list of usb key codes through USB HID
  183. set( OutputModule "pjrcUSB"
  184. CACHE STRING "Output Module" )
  185. ##| Debugging source to use, each module has it's own set of defines that it sets
  186. set( DebugModule "full"
  187. CACHE STRING "Debug Module" )
  188. ```
  189. Look at each module individually for it's requirements. There is
  190. chip/architecture dependency checking but some permutations of modules may not
  191. be tested/compile.
  192. There are also CMake options for temporarily selecting modules. But it's
  193. easier to just edit the file. e.g. `cmake -DScanModuleOverride=<module name>`.
  194. Linux Building
  195. --------------
  196. From this directory.
  197. ```bash
  198. $ mkdir build
  199. $ cd build
  200. $ cmake ..
  201. $ make
  202. ```
  203. Example output:
  204. ```
  205. $ cmake ..
  206. -- Compiler Family:
  207. arm
  208. -- Chip Selected:
  209. mk20dx128vlf5
  210. -- Chip Family:
  211. mk20dx
  212. -- CPU Selected:
  213. cortex-m4
  214. -- Compiler Source Files:
  215. Lib/mk20dx.c;Lib/delay.c
  216. -- Bootloader Type:
  217. dfu
  218. -- Detected Scan Module Source Files:
  219. Scan/MD1/scan_loop.c;Scan/MD1/../MatrixARM/matrix_scan.c
  220. -- Detected Macro Module Source Files:
  221. Macro/PartialMap/macro.c
  222. -- Detected Output Module Source Files:
  223. Output/pjrcUSB/output_com.c;Output/pjrcUSB/arm/usb_desc.c;Output/pjrcUSB/arm/usb_dev.c;
  224. Output/pjrcUSB/arm/usb_keyboard.c;Output/pjrcUSB/arm/usb_mem.c;Output/pjrcUSB/arm/usb_serial.c
  225. -- Detected Debug Module Source Files:
  226. Debug/full/../cli/cli.c;Debug/full/../led/led.c;Debug/full/../print/print.c
  227. -- Found Git: /usr/bin/git (found version "2.2.1")
  228. -- Found Ctags: /usr/bin/ctags (found version "5.8")
  229. -- Checking for latest kll version:
  230. Current branch master is up to date.
  231. -- Detected Layout Files:
  232. /home/hyatt/Source/controller/Macro/PartialMap/capabilities.kll
  233. /home/hyatt/Source/controller/Output/pjrcUSB/capabilities.kll
  234. /home/hyatt/Source/controller/Scan/MD1/defaultMap.kll
  235. /home/hyatt/Source/controller/kll/layouts/md1Overlay.kll
  236. /home/hyatt/Source/controller/kll/layouts/stdFuncMap.kll
  237. /home/hyatt/Source/controller/kll/layouts/hhkbpro2.kll
  238. -- Configuring done
  239. -- Generating done
  240. -- Build files have been written to: /home/hyatt/Source/controller/build
  241. [master]: make [~/Source/controller/build](hyatt@x230mas:pts/6)
  242. [ 5%] Generating KLL Layout
  243. Scanning dependencies of target kiibohd.elf
  244. [ 11%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.o
  245. [ 17%] Building C object CMakeFiles/kiibohd.elf.dir/Lib/mk20dx.c.o
  246. [ 23%] Building C object CMakeFiles/kiibohd.elf.dir/Lib/delay.c.o
  247. [ 29%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/MD1/scan_loop.c.o
  248. [ 35%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/MatrixARM/matrix_scan.c.o
  249. [ 41%] Building C object CMakeFiles/kiibohd.elf.dir/Macro/PartialMap/macro.c.o
  250. [ 47%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/output_com.c.o
  251. [ 52%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_desc.c.o
  252. [ 58%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_dev.c.o
  253. [ 64%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_keyboard.c.o
  254. [ 70%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_mem.c.o
  255. [ 76%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_serial.c.o
  256. [ 82%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/cli/cli.c.o
  257. [ 88%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/led/led.c.o
  258. [ 94%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/print/print.c.o
  259. Linking C executable kiibohd.elf
  260. [ 94%] Built target kiibohd.elf
  261. Scanning dependencies of target SizeAfter
  262. [100%] Chip usage for mk20dx128vlf5
  263. SRAM: 32% 5384/16384 bytes
  264. Flash: 18% 23384/126976 bytes
  265. [100%] Built target SizeAfter
  266. ```
  267. Linux Loading Firmware
  268. ----------------------
  269. First place the keyboard into re-flash mode. This can be done either by
  270. pressing the re-flash button on the PCB/Teensy. Or by entering the Kiibohd
  271. Virtual Serial Port and using the 'reload' command.
  272. The `load` script that is created during the build can load the firmware over
  273. USB. Either run it with sudo, or install the `98-kiibohd.rules` to
  274. `/etc/udev/rules.d` and run: `udevadm control --reload-rules`.
  275. To load the newly built firmware: `./load`.
  276. Linux Building Bootloader
  277. -------------------------
  278. > NOTE: Does not apply to Teensy based builds.
  279. From this directory.
  280. ```bash
  281. $ cd Bootloader
  282. $ mkdir build
  283. $ cd build
  284. $ cmake ..
  285. $ make
  286. ```
  287. Example output:
  288. ```bash
  289. $ cmake ..
  290. -- Compiler Family:
  291. arm
  292. -- Chip Selected:
  293. mk20dx128vlf5
  294. -- Chip Family:
  295. mk20dx
  296. -- CPU Selected:
  297. cortex-m4
  298. -- Compiler Source Files:
  299. Lib/mk20dx.c;Lib/delay.c
  300. -- Bootloader Type:
  301. dfu
  302. -- Bootloader Source Files:
  303. main.c;dfu.c;dfu.desc.c;flash.c;kinetis.c;usb.c
  304. -- Found Git: /usr/bin/git (found version "2.2.1")
  305. -- Found Ctags: /usr/bin/ctags (found version "5.8")
  306. -- Configuring done
  307. -- Generating done
  308. -- Build files have been written to: /home/hyatt/Source/controller/Bootloader/build
  309. [master]: make [~/Source/controller/Bootloader/build](hyatt@x230mas:pts/6)
  310. Scanning dependencies of target kiibohd_bootloader.elf
  311. [ 11%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/main.c.o
  312. [ 22%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/dfu.c.o
  313. [ 33%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/dfu.desc.c.o
  314. [ 44%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/flash.c.o
  315. [ 55%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/kinetis.c.o
  316. [ 66%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/usb.c.o
  317. [ 77%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/home/hyatt/Source/controller/Lib/mk20dx.c.o
  318. [ 88%] Building C object CMakeFiles/kiibohd_bootloader.elf.dir/home/hyatt/Source/controller/Lib/delay.c.o
  319. Linking C executable kiibohd_bootloader.elf
  320. [ 88%] Built target kiibohd_bootloader.elf
  321. Scanning dependencies of target SizeAfter
  322. [100%] Chip usage for mk20dx128vlf5
  323. SRAM: 19% 3176/16384 bytes
  324. Flash: 2% 3736/126976 bytes
  325. [100%] Built target SizeAfter
  326. ```
  327. Linux Loading Bootloader
  328. ------------------------
  329. > NOTE: Does not apply to Teensy based builds.
  330. It's recommended to use an SWD-type flasher like a Bus Pirate. There is a
  331. convenience script for loading the firmware once the system is setup.
  332. ```bash
  333. $ cd Bootloader/Scripts
  334. $ ./swdLoad.bash
  335. ```
  336. The above script requires Ruby, Ruby serial port module, git, and a
  337. `/dev/buspirate` udev rule.
  338. Additional Notes:
  339. * https://github.com/mchck/mchck/wiki/Getting-Started (See Bus-Pirate section)
  340. * https://wiki.archlinux.org/index.php/Bus_pirate
  341. Windows Building
  342. ----------------
  343. From this directory.
  344. ```bash
  345. $ mkdir build
  346. $ cd build
  347. $ wincmake ..
  348. $ make
  349. ```
  350. Example output:
  351. ```bash
  352. $ wincmake ..
  353. -- Compiler Family:
  354. arm
  355. -- Chip Selected:
  356. mk20dx128vlf5
  357. -- Chip Family:
  358. mk20dx
  359. -- CPU Selected:
  360. cortex-m4
  361. -- Compiler Source Files:
  362. Lib/mk20dx.c;Lib/delay.c
  363. -- Bootloader Type:
  364. dfu
  365. -- Detected Scan Module Source Files:
  366. Scan/MD1/scan_loop.c;Scan/MD1/../MatrixARM/matrix_scan.c
  367. -- Detected Macro Module Source Files:
  368. Macro/PartialMap/macro.c
  369. -- Detected Output Module Source Files:
  370. Output/pjrcUSB/output_com.c;Output/pjrcUSB/arm/usb_desc.c;Output/pjrcUSB/arm/usb_dev.c;Output/pjrcUSB/arm/usb_keyboard.c;Output/pjrcUSB/arm/usb_mem.c;Output/pjrcUSB/arm/usb_serial.c
  371. -- Detected Debug Module Source Files:
  372. Debug/full/../cli/cli.c;Debug/full/../led/led.c;Debug/full/../print/print.c
  373. -- Found Git: C:/cygwin64/bin/git.exe (found version "2.1.1")
  374. -- Found Ctags: C:/cygwin64/bin/ctags.exe (found version "5.8")
  375. -- Checking for latest kll version:
  376. Current branch master is up to date.
  377. -- Detected Layout Files:
  378. C:/cygwin64/home/Jacob/controller/Macro/PartialMap/capabilities.kll
  379. C:/cygwin64/home/Jacob/controller/Output/pjrcUSB/capabilities.kll
  380. C:/cygwin64/home/Jacob/controller/Scan/MD1/defaultMap.kll
  381. C:/cygwin64/home/Jacob/controller/kll/layouts/md1Overlay.kll
  382. C:/cygwin64/home/Jacob/controller/kll/layouts/stdFuncMap.kll
  383. C:/cygwin64/home/Jacob/controller/kll/layouts/hhkbpro2.kll
  384. -- Configuring done
  385. -- Generating done
  386. -- Build files have been written to: C:/cygwin64/home/Jacob/controller/build
  387. $ make
  388. [ 5%] Generating KLL Layout
  389. Scanning dependencies of target kiibohd.elf
  390. [ 11%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.obj
  391. [ 17%] Building C object CMakeFiles/kiibohd.elf.dir/Lib/mk20dx.c.obj
  392. [ 23%] Building C object CMakeFiles/kiibohd.elf.dir/Lib/delay.c.obj
  393. [ 29%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/MD1/scan_loop.c.obj
  394. [ 35%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/MatrixARM/matrix_scan.c.obj
  395. [ 41%] Building C object CMakeFiles/kiibohd.elf.dir/Macro/PartialMap/macro.c.obj
  396. [ 47%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/output_com.c.obj
  397. [ 52%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_desc.c.obj
  398. [ 58%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_dev.c.obj
  399. [ 64%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_keyboard.c.obj
  400. [ 70%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_mem.c.obj
  401. [ 76%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/arm/usb_serial.c.obj
  402. [ 82%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/cli/cli.c.obj
  403. [ 88%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/led/led.c.obj
  404. [ 94%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/print/print.c.obj
  405. Linking C executable kiibohd.elf
  406. [ 94%] Built target kiibohd.elf
  407. Scanning dependencies of target SizeAfter
  408. [100%] Chip usage for mk20dx128vlf5
  409. SRAM: 32% 5384/16384 bytes
  410. Flash: 18% 23296/126976 bytes
  411. [100%] Built target SizeAfter
  412. ```
  413. ### NOTES:
  414. If you get the following error, you have not setup wincmake correctly:
  415. ```bash
  416. $ make
  417. [ 5%] Generating KLL Layout
  418. Scanning dependencies of target kiibohd.elf
  419. [ 11%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.o
  420. ../main.c:28:19: fatal error: macro.h: No such file or directory
  421. #include <macro.h>
  422. ^
  423. compilation terminated.
  424. CMakeFiles/kiibohd.elf.dir/build.make:67: recipe for target 'CMakeFiles/kiibohd.elf.dir/main.c.o' failed
  425. make[2]: *** [CMakeFiles/kiibohd.elf.dir/main.c.o] Error 1
  426. CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/kiibohd.elf.dir/all' failed
  427. make[1]: *** [CMakeFiles/kiibohd.elf.dir/all] Error 2
  428. Makefile:75: recipe for target 'all' failed
  429. make: *** [all] Error 2
  430. ```
  431. If you have already added the line to your `~/.bashrc` try restarting your
  432. cygwin shell.
  433. Windows Loading Firmware
  434. ------------------------
  435. First place the keyboard into re-flash mode. This can be done either by
  436. pressing the re-flash button on the PCB/Teensy. Or by entering the Kiibohd
  437. Virtual Serial Interface and using the `reload` command.
  438. The `load` script that is created during the build can load the firmware over
  439. USB.
  440. To load the newly built firmware: `./load`
  441. Be patient the couple of times, Windows is slow at installing drivers...
  442. Mac OS X Building
  443. -----------------
  444. From this directory.
  445. ```bash
  446. $ mkdir build
  447. $ cd build
  448. $ cmake ..
  449. $ make
  450. ```
  451. Example output:
  452. > TODO
  453. Mac OS X Loading Firmware
  454. -------------------------
  455. First place the keyboard into re-flash mode. This can be done either by
  456. pressing the re-flash button on the PCB/Teensy. Or by entering the Kiibohd
  457. Virtual Serial Port and using the `reload` command.
  458. The `load` script that is created during the build can load the firmware over
  459. USB.
  460. To load the newly built firmware: `./load`.
  461. Virtual Serial Port - CLI
  462. -------------------------
  463. Rather than use a special program that can interpret Raw HID, this controller exposes a USB Serial CDC endpoint.
  464. This allows for you to use a generic serial terminal to debug/control the keyboard firmware (e.g. Tera Term, minicom, screen)
  465. ### Linux
  466. I generally use screen. You will need sudo/root priviledges if you haven't
  467. installed the `98-kiibohd.rules` file to `/etc/udev/rules.d`.
  468. ```
  469. $ screen /dev/ttyACM0
  470. # (Might be ACM1, ACM2, etc.)
  471. ```
  472. ### Windows
  473. Make sure the Teensy Virtual Serial Port driver is installed. If possible use
  474. screen (as part of Cygwin). Check which COM port the virtual serial port has
  475. been assigned to: `Device Manager->Ports (COM & LPT)->Teensy USB Serial`. In
  476. brackets it will say which COM port (e.g. COM3)
  477. putty works well when using DTR/DSR or RTS/CTS flow control.
  478. | Setting | Value |
  479. | --------------- | ------------------------------------- |
  480. | Connection type | Serial |
  481. | Serial line | Your COM port, e.g. COM3 |
  482. | Speed | doesn't matter, it's auto-negotiated |
  483. Under `Category->Connections->Serial`: `Flow control: DTR/DSR`.
  484. If stuff is hard to read (you have a dumb colour scheme):
  485. `Category->Window->Colours->Use system color`. That seems to make text at
  486. least readable
  487. > I use a custom colour scheme that makes each colour easy to see.
  488. > -HaaTa.
  489. Unfortunately, screen for Cygwin seems to be broken for serial ports, but you
  490. can try it...
  491. ```bash
  492. $ screen /dev/ttyS2
  493. # Might be a different file, ttyS0, ttyACM0, ttyUSB0, etc.
  494. ```
  495. Gnu screen doesn't seem to echo all the characters (it works though).
  496. I believe it's a problem with stty, but I don't know how to fix it...
  497. ### Mac OS X
  498. I recommend screen (can be installed via Macports).
  499. ```bash
  500. $ screen /dev/tty.<usb something>
  501. ```