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.

README.markdown 22KB

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