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 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. The Kiibohd Controller
  2. ----------------------
  3. TODO, write some insightful/informative :P
  4. Please give authors credit for modules used if you use in a distributed product :D
  5. ----------------------
  6. Dependencies
  7. ----------------------
  8. Below listed are the Arch Linux pacman names, AUR packages may be required.
  9. These depend a bit on which targets you are trying to build, but the general one:
  10. - cmake (2.8 and higher)
  11. AVR Specific (Teensy 1.0/++,2.0/++) (try to use something recent, suggested versions below)
  12. - avr-gcc (~4.8.0)
  13. - avr-binutils (~2.23.2)
  14. - avr-libc (~1.8.0)
  15. ARM Specific (Teensy 3.0/3.1) (Sourcery CodeBench Lite for ARM EABI
  16. (http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/)
  17. - arm-none-eabi
  18. OR
  19. - arm-none-eabi-gcc
  20. - arm-none-eaby-binutils
  21. (I've actually had some issues with Sourcery CodeBench on Linux, so I often just use these)
  22. ----------------------
  23. Windows Setup
  24. ----------------------
  25. Compiling on Windows does work, just it's a bunch more work.
  26. First make sure Cygwin is installed - http://www.cygwin.com/ - 32bit or 64bit is fine. Make sure the following are installed:
  27. - make
  28. - git (needed for some compilation info)
  29. - cmake
  30. - gcc-core
  31. - libusb1.0
  32. - libusb1.0-devel
  33. Also install the Windows version of CMake - http://cmake.org/cmake/resources/software.html
  34. This is in addition to the Cygwin version. This is an easier alternative to installing another C compiler.
  35. Add the following line to your .bashrc, making sure the CMake path is correct:
  36. alias wincmake="PATH='/cygdrive/c/Program Files (x86)/CMake 2.8'/bin:\"${PATH}\" cmake"
  37. Next, install the compiler(s) you want.
  38. ---------
  39. | AVR GCC |
  40. ---------
  41. You just need the Atmel AVR 8-bit Toolchain. The latest should be fine, as of writing it was 3.4.3.
  42. http://www.atmel.com/tools/atmelavrtoolchainforwindows.aspx
  43. Extract the files to a directory, say C:\avr8-gnu-toolchain. Then copy all the folders in that directory to the Cygwin directory.
  44. Mine is C:\cygwin64.
  45. (You can also just setup the paths, but this is faster/simpler. Might screw up your Cygwin though).
  46. ----------
  47. | ARM EABI |
  48. ----------
  49. Download the latest version of Mentor Graphics Sourcery CodeBench ARM EABI.
  50. http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/
  51. Use the installer and make sure you add the binaries to your path within the installer.
  52. ----------------------
  53. Selecting Architecture
  54. ----------------------
  55. This is where you choose which architecture you want to build for.
  56. The options are:
  57. - Teensy 1.0 (Not tested)
  58. - Teensy 1.0++ (Not tested)
  59. - Teensy 2.0
  60. - Teensy 2.0++
  61. - Teensy 3.0
  62. - Teensy 3.1
  63. Open up CMakeLists.txt in your favourite text editor.
  64. You are looking for:
  65. ###
  66. Compiler Family
  67. #
  68. #| Specify the compiler family to use
  69. #| Currently only supports AVR and ARM
  70. #| "avr" # Teensy 1.0
  71. #| "avr" # Teensy 2.0
  72. #| "avr" # Teensy++ 1.0
  73. #| "avr" # Teensy++ 2.0
  74. #| "arm" # Teensy 3.0
  75. #| "arm" # Teensy 3.1
  76. set( COMPILER_FAMILY "avr" )
  77. Just change the COMPILER_FAMILY variable to whatever you are trying to build for.
  78. NOTE: If you change this option, you will *may* to delete the build directory that is created in the Building sections below.
  79. ----------------------
  80. Selecting Microcontroller
  81. ----------------------
  82. Even if you selected the "avr" family of microcontroller architectures, you will still need to specify a target microcontroller (or once more ARM microcontrollers are supported).
  83. Open up avr.cmake (or arm.cmake) in your favourite text editor.
  84. You are looking for:
  85. ###
  86. # Atmel Defines and Linker Options
  87. #
  88. #| MCU Name
  89. #| You _MUST_ set this to match the board you are using
  90. #| type "make clean" after changing this, so all files will be rebuilt
  91. #|
  92. #| "at90usb162" # Teensy 1.0
  93. #| "atmega32u4" # Teensy 2.0
  94. #| "at90usb646" # Teensy++ 1.0
  95. #| "at90usb1286" # Teensy++ 2.0
  96. set( MCU "at90usb1286" )
  97. *OR*
  98. ###
  99. # ARM Defines and Linker Options
  100. #
  101. #| Chip Name (Linker)
  102. #| You _MUST_ set this to match the board you are using
  103. #| type "make clean" after changing this, so all files will be rebuilt
  104. #|
  105. #| "mk20dx128" # Teensy 3.0
  106. #| "mk20dx256" # Teensy 3.1
  107. set( CHIP "mk20dx128" )
  108. Just change the CHIP variable to the microcontroller you are trying to build for.
  109. NOTE: If you change this option, you will *need* to delete the build directory that is created in the Building sections below.
  110. ----------------------
  111. Selecting Modules
  112. ----------------------
  113. WARNING: Not all modules are compatible, and some modules may have dependencies on other modules.
  114. This is where the options start getting interesting.
  115. The Kiibohd Controller is designed around a set of 4 types of modules that correspond to different functionality:
  116. - Scan Module
  117. - Macro Module
  118. - Output Module
  119. - Debug Module
  120. The Scan Module is where the most interesting stuff happens. These modules take in "keypress data".
  121. A converter Scan Module will interpret a protocol into key press/releases.
  122. A matrix Scan Module may inherit from the matrix module to scan keypress from a matrix
  123. This module just has to give press/release codes, but does have some callback control to other modules depending on the lifecycle for press/release codes (this can be very complicated depending on the protocol).
  124. Each Scan Module has it's own default keymap/modifier map. (TODO recommend keymap changing in the Macro Module).
  125. Some scan modules have very specialized hardware requirements, each module directory should have at least a link to the needed parts and/or schematics (TODO!).
  126. The Macro Module takes care of the mapping of the key press/release code into an Output (USB) scan code.
  127. Any layering, macros, keypress intelligence/reaction is done here.
  128. The Output Module is the module dealing with output from the microcontroller. Currently USB is the only output protocol.
  129. Different USB output implementations are available, pjrc being the safest/least featureful one.
  130. Debug capabilities may depend on the module selected.
  131. The Debug Module enables various things like the Teensy LED on errors, debug terminal output.
  132. (TODO get true UART working in avr, not just arm)
  133. Open up setup.cmake in your favourite text editor.
  134. Look for:
  135. ###
  136. # Project Modules
  137. #
  138. #| Note: This is the only section you probably want to modify
  139. #| Each module is defined by it's own folder (e.g. Scan/Matrix represents the "Matrix" module)
  140. #| All of the modules must be specified, as they generate the sources list of files to compile
  141. #| Any modifications to this file will cause a complete rebuild of the project
  142. #| Please look at the {Scan,Macro,Output,Debug}/module.txt for information on the modules and how to create new ones
  143. ##| Deals with acquiring the keypress information and turning it into a key index
  144. set( ScanModule "avr-capsense" )
  145. ##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
  146. set( MacroModule "buffer" )
  147. ##| Sends the current list of usb key codes through USB HID
  148. set( OutputModule "pjrc" )
  149. ##| Debugging source to use, each module has it's own set of defines that it sets
  150. set( DebugModule "full" )
  151. Look at each module individually for it's requirements. There is chip/architecture dependency checking but some permutations of modules may not be tested/compile.
  152. There are also CMake options for temporarily selecting modules. But it's easier to just edit the file.
  153. e.g. cmake -DScanModuleOverride=<module name>
  154. ----------------------
  155. Linux Building
  156. ----------------------
  157. From this directory.
  158. mkdir build
  159. cd build
  160. cmake ..
  161. make
  162. Example output:
  163. [master]: cmake .. [...sy/avr-capsense-haata/build](hyatt@901Mas:pts/4)
  164. -- Compiler Family:
  165. avr
  166. -- MCU Selected:
  167. at90usb1286
  168. -- Detected Scan Module Source Files:
  169. Scan/avr-capsense/scan_loop.c
  170. -- Detected Macro Module Source Files:
  171. Macro/buffer/macro.c
  172. -- Detected Output Module Source Files:
  173. Output/pjrc/usb_com.c;Output/pjrc/avr/usb_keyboard_debug.c
  174. -- Detected Debug Module Source Files:
  175. Debug/full/../led/led.c;Debug/full/../print/print.c
  176. -- Configuring done
  177. -- Generating done
  178. -- Build files have been written to: /home/hyatt/Source/Teensy/avr-capsense-haata/build
  179. [master]: make [...sy/avr-capsense-haata/build](hyatt@901Mas:pts/4)
  180. Scanning dependencies of target kiibohd.elf
  181. [ 12%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.o
  182. [ 25%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/avr-capsense/scan_loop.c.o
  183. [ 37%] Building C object CMakeFiles/kiibohd.elf.dir/Macro/buffer/macro.c.o
  184. [ 50%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrc/usb_com.c.o
  185. [ 62%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrc/avr/usb_keyboard_debug.c.o
  186. [ 75%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/led/led.c.o
  187. [ 87%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/print/print.c.o
  188. Linking C executable kiibohd.elf
  189. Creating load file for Flash: kiibohd.hex
  190. Creating Extended Listing: kiibohd.lss
  191. Creating Symbol Table: kiibohd.sym
  192. [ 87%] Built target kiibohd.elf
  193. Scanning dependencies of target SizeAfter
  194. [100%] Size after generation:
  195. text data bss dec hex filename
  196. 0 6112 0 6112 17e0 kiibohd.hex
  197. 5792 320 852 6964 1b34 kiibohd.elf
  198. [100%] Built target SizeAfter
  199. ----------------------
  200. Linux Loading Firmware
  201. ----------------------
  202. The 'load' script that is created during the build can load the firmware over USB.
  203. It uses sudo, so make sure you have the priviledges.
  204. ./load
  205. ----------------------
  206. Windows Building
  207. ----------------------
  208. From this directory.
  209. mkdir build
  210. cd build
  211. wincmake -G "Unix Makefiles" ..
  212. Example output:
  213. $ cmake -G "Unix Makefiles" ..
  214. -- Compiler Family:
  215. avr
  216. -- MCU Selected:
  217. atmega32u4
  218. -- CPU Selected:
  219. megaAVR
  220. -- Detected Scan Module Source Files:
  221. Scan/SKM67001/../matrix/matrix_scan.c;Scan/SKM67001/../matrix/scan_loop.c
  222. -- Detected Macro Module Source Files:
  223. Macro/PartialMap/macro.c
  224. -- Detected Output Module Source Files:
  225. Output/pjrcUSB/output_com.c;Output/pjrcUSB/avr/usb_keyboard_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: C:/cygwin64/bin/git.exe (found version "1.7.9")
  229. -- Configuring done
  230. -- Generating done
  231. -- Build files have been written to: C:/cygwin64/home/jacob.alexander/src/capsense-beta/build
  232. jacob.alexander@JALEXANDER2-LT ~/src/capsense-beta/build
  233. $ make
  234. Scanning dependencies of target kiibohd.elf
  235. [ 10%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.obj
  236. [ 20%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/matrix/matrix_scan.c.obj
  237. [ 30%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/matrix/scan_loop.c.obj
  238. [ 40%] Building C object CMakeFiles/kiibohd.elf.dir/Macro/PartialMap/macro.c.obj
  239. [ 50%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/output_com.c.obj
  240. [ 60%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/avr/usb_keyboard_serial.c.obj
  241. [ 70%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/cli/cli.c.obj
  242. [ 80%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/led/led.c.obj
  243. [ 90%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/print/print.c.obj
  244. Linking C executable kiibohd.elf
  245. Creating load file for Flash: kiibohd.hex
  246. Creating Extended Listing: kiibohd.lss
  247. Creating Symbol Table: kiibohd.sym
  248. [ 90%] Built target kiibohd.elf
  249. Scanning dependencies of target SizeAfter
  250. [100%] Size after generation
  251. Flash Usage: data (hex)
  252. RAM Usage: data (elf)
  253. text data bss dec hex filename
  254. 0 9738 0 9738 260a kiibohd.hex
  255. 7982 1756 264 10002 2712 kiibohd.elf
  256. [100%] Built target SizeAfter
  257. ----------------------
  258. Windows Loading Firmware
  259. ----------------------
  260. TODO
  261. ----------------------
  262. Mac OS X Building
  263. ----------------------
  264. TODO
  265. ----------------------
  266. Mac OS X Loading Firmware
  267. ----------------------
  268. TODO
  269. ----------------------
  270. Virtual Serial Port - CLI
  271. ----------------------
  272. Rather than use a special program that can interpret Raw HID, this controller exposes a USB Serial CDC endpoint.
  273. This allows for you to use a generic serial terminal to debug/control the keyboard firmware (e.g. Tera Term, minicom, screen)
  274. -------
  275. | Linux |
  276. -------
  277. I generally use screen.
  278. sudo screen /dev/ttyACM0
  279. ---------
  280. | Windows |
  281. ---------
  282. TODO Probably COM1, but not exactly sure. Tera Term.
  283. ----------
  284. | Mac OS X |
  285. ----------
  286. TODO (What is the usual device name). screen if possible.