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

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