Kiibohd Controller
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

il y a 10 ans
il y a 10 ans
il y a 10 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. The Kiibohd Controller
  2. ----------------------
  3. This README is a bit long, just look at the sections you are interested in.
  4. Linux is the ideal build environment (preferably recent'ish).
  5. Building on Mac should be ok for 99% of users with Macports (haven't tried Brew).
  6. The dfu Bootloader will not build correctly with the old version of arm-none-eabi-gcc that Macports currently has (4.7.3).
  7. This is due to a bug with lto (link time optimizations) which makes the resulting binary too big to fit on the chip (must be less than 4096 Bytes).
  8. Building on Windows should also be fine for 99% of users, but takes a bunch of work to setup (because Windows is a crappy dev environment).
  9. Cygwin is currently required along with some non-Cygwin compilers and utilities (because they are not available for Cygwin).
  10. The dfu Bootloader will not build because of a Make 3.81+ bug/feature that removed support for non-Unix (Windows) filenames as dependencies of targets.
  11. If you replace the version of Make in Cygwin it should work (e.g. http://stackoverflow.com/questions/601516/cygwin-make-error-target-pattern-contains-no).
  12. However, make sure that the flash size is no larger than 4096 Bytes or the bootloader will not work.
  13. Please give authors credit for modules used if you use in a distributed product :D
  14. ----------------------
  15. Dependencies
  16. ----------------------
  17. Below listed are the Arch Linux pacman names, AUR packages may be required.
  18. These depend a bit on which targets you are trying to build, but the general one:
  19. - cmake (2.8 and higher)
  20. - git
  21. - ctags (recommended, not required)
  22. - python3
  23. - libusb1.0 (and -devel)
  24. - make
  25. AVR Specific (Teensy 1.0/++,2.0/++) (try to use something recent, suggested versions below)
  26. - avr-gcc (~4.8.0)
  27. - avr-binutils (~2.23.2)
  28. - avr-libc (~1.8.0)
  29. ARM Specific (Teensy 3.0/3.1) (Sourcery CodeBench Lite for ARM EABI
  30. (http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/)
  31. - arm-none-eabi
  32. OR
  33. - arm-none-eabi-gcc
  34. - arm-none-eaby-binutils
  35. (I've actually had some issues with Sourcery CodeBench on Linux, so I often just use these)
  36. ----------------------
  37. Windows Setup
  38. ----------------------
  39. Compiling on Windows does work, just it's a bunch more work.
  40. First make sure Cygwin is installed - http://www.cygwin.com/ - 32bit or 64bit is fine. Make sure the following are installed:
  41. - make
  42. - git (needed for some compilation info)
  43. - cmake
  44. - gcc-core
  45. - gcc-g++
  46. - libusb1.0
  47. - libusb1.0-devel
  48. - python3
  49. - ctags (recommended, not required)
  50. Please note, I use cygwin term exclusively for any command line options. Unless mentioned otherwise use it.
  51. Do NOT use CMD or Powershell.
  52. Also install the Windows version of CMake (3+ is ideal) - http://cmake.org/cmake/resources/software.html
  53. This is in addition to the Cygwin version. This is an easier alternative to installing another C compiler.
  54. Add the following line to your .bashrc, making sure the CMake path is correct:
  55. echo "alias wincmake=\"PATH='/cygdrive/c/Program Files (x86)/CMake'/bin:'${PATH}' cmake -G 'Unix Makefiles'\"" >> ~/.bashrc
  56. Install the PJRC Virtual Serial Port Driver:
  57. (http://pjrc.com/teensy/serial_install.exe)
  58. Next, install the compiler(s) you want.
  59. ---------
  60. | AVR GCC |
  61. ---------
  62. You just need the Atmel AVR 8-bit Toolchain. The latest should be fine, as of writing it was 3.4.3.
  63. http://www.atmel.com/tools/atmelavrtoolchainforwindows.aspx
  64. (Atmel AVR 8-bit Toolchain 3.4.3 - Windows)
  65. Extract the files to a directory, say C:\avr8-gnu-toolchain. Then copy all the folders in that directory to the Cygwin /usr/local directory.
  66. Mine is C:\cygwin64\usr\local.
  67. (You can also just setup the paths, but this is faster/simpler. Might screw up your Cygwin though).
  68. ----------
  69. | ARM EABI |
  70. ----------
  71. Download the latest version of Mentor Graphics Sourcery CodeBench ARM EABI.
  72. http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/
  73. Look for "Download the EABI Release".
  74. Enter your info to get the download link.
  75. Select the most recent download.
  76. Then download the "IA32 Windows Installer".
  77. Then copy all the folders/files installed (e.g. C:\Users\Haata\MentorGraphics\Sourcery_CodeBench_Lite_for_ARM_EABI\) to Cygwin /usr/local directory.
  78. Mine is C:\cygwin64\usr\local.
  79. Or, you can setup paths using the installer (you have to be more careful though).
  80. ----------------------
  81. Selecting Microcontroller
  82. ----------------------
  83. This is where you select the chip you want to compile for.
  84. The build system will automatically select the compiler needed to compile for your chip.
  85. Open up CMakeLists.txt in your favourite text editor.
  86. You are looking for:
  87. ###
  88. # Chip Selection
  89. #
  90. #| You _MUST_ set this to match the microcontroller you are trying to compile for
  91. #| You _MUST_ clean the build directory if you change this value
  92. #|
  93. set( CHIP
  94. # "at90usb162" # Teensy 1.0 (avr)
  95. # "atmega32u4" # Teensy 2.0 (avr)
  96. # "at90usb646" # Teensy++ 1.0 (avr)
  97. "at90usb1286" # Teensy++ 2.0 (avr)
  98. # "mk20dx128" # Teensy 3.0 (arm)
  99. # "mk20dx256" # Teensy 3.1 (arm)
  100. )
  101. Just uncomment the chip you want, and comment out the old one.
  102. NOTE: If you change this option, you will *need* to delete the build directory that is created in the Building sections below.
  103. ----------------------
  104. Selecting Modules
  105. ----------------------
  106. WARNING: Not all modules are compatible, and some modules may have dependencies on other modules.
  107. This is where the options start getting interesting.
  108. The Kiibohd Controller is designed around a set of 4 types of modules that correspond to different functionality:
  109. - Scan Module
  110. - Macro Module
  111. - Output Module
  112. - Debug Module
  113. The Scan Module is where the most interesting stuff happens. These modules take in "keypress data".
  114. A converter Scan Module will interpret a protocol into key press/releases.
  115. A matrix Scan Module may inherit from the matrix module to scan keypress from a matrix
  116. 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).
  117. Each Scan Module has it's own default keymap/modifier map. (TODO recommend keymap changing in the Macro Module).
  118. 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!).
  119. The Macro Module takes care of the mapping of the key press/release code into an Output (USB) scan code.
  120. Any layering, macros, keypress intelligence/reaction is done here.
  121. The Output Module is the module dealing with output from the microcontroller. Currently USB is the only output protocol.
  122. Different USB output implementations are available, pjrc being the safest/least featureful one.
  123. Debug capabilities may depend on the module selected.
  124. The Debug Module enables various things like the Teensy LED on errors, debug terminal output.
  125. (TODO get true UART working in avr, not just arm)
  126. Open up CMakeLists.txt in your favourite text editor.
  127. Look for:
  128. ###
  129. # Project Modules
  130. #
  131. #| Note: This is the only section you probably want to modify
  132. #| Each module is defined by it's own folder (e.g. Scan/Matrix represents the "Matrix" module)
  133. #| All of the modules must be specified, as they generate the sources list of files to compile
  134. #| Any modifications to this file will cause a complete rebuild of the project
  135. #| Please look at the {Scan,Macro,Output,Debug}/module.txt for information on the modules and how to create new ones
  136. ##| Deals with acquiring the keypress information and turning it into a key index
  137. set( ScanModule "avr-capsense" )
  138. ##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
  139. set( MacroModule "buffer" )
  140. ##| Sends the current list of usb key codes through USB HID
  141. set( OutputModule "pjrc" )
  142. ##| Debugging source to use, each module has it's own set of defines that it sets
  143. set( DebugModule "full" )
  144. 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.
  145. There are also CMake options for temporarily selecting modules. But it's easier to just edit the file.
  146. e.g. cmake -DScanModuleOverride=<module name>
  147. ----------------------
  148. Linux Building
  149. ----------------------
  150. From this directory.
  151. mkdir build
  152. cd build
  153. cmake ..
  154. make
  155. Example output:
  156. [master]: cmake .. [...sy/avr-capsense-haata/build](hyatt@901Mas:pts/4)
  157. -- Compiler Family:
  158. avr
  159. -- MCU Selected:
  160. at90usb1286
  161. -- Detected Scan Module Source Files:
  162. Scan/avr-capsense/scan_loop.c
  163. -- Detected Macro Module Source Files:
  164. Macro/buffer/macro.c
  165. -- Detected Output Module Source Files:
  166. Output/pjrc/usb_com.c;Output/pjrc/avr/usb_keyboard_debug.c
  167. -- Detected Debug Module Source Files:
  168. Debug/full/../led/led.c;Debug/full/../print/print.c
  169. -- Configuring done
  170. -- Generating done
  171. -- Build files have been written to: /home/hyatt/Source/Teensy/avr-capsense-haata/build
  172. [master]: make [...sy/avr-capsense-haata/build](hyatt@901Mas:pts/4)
  173. Scanning dependencies of target kiibohd.elf
  174. [ 12%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.o
  175. [ 25%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/avr-capsense/scan_loop.c.o
  176. [ 37%] Building C object CMakeFiles/kiibohd.elf.dir/Macro/buffer/macro.c.o
  177. [ 50%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrc/usb_com.c.o
  178. [ 62%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrc/avr/usb_keyboard_debug.c.o
  179. [ 75%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/led/led.c.o
  180. [ 87%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/print/print.c.o
  181. Linking C executable kiibohd.elf
  182. Creating load file for Flash: kiibohd.hex
  183. Creating Extended Listing: kiibohd.lss
  184. Creating Symbol Table: kiibohd.sym
  185. [ 87%] Built target kiibohd.elf
  186. Scanning dependencies of target SizeAfter
  187. [100%] Size after generation:
  188. text data bss dec hex filename
  189. 0 6112 0 6112 17e0 kiibohd.hex
  190. 5792 320 852 6964 1b34 kiibohd.elf
  191. [100%] Built target SizeAfter
  192. ----------------------
  193. Linux Loading Firmware
  194. ----------------------
  195. First place the keyboard into re-flash mode.
  196. This can be done either by pressing the re-flash button on the PCB/Teensy.
  197. Or by entering the Kiibohd Virtual Serial Port and using the 'reload' command.
  198. The 'load' script that is created during the build can load the firmware over USB.
  199. Either run it with sudo, or install the 98-kiibohd.rules to /etc/udev/rules.d
  200. and run: udevadm control --reload-rules
  201. To load the newly built firmware:
  202. ./load
  203. ----------------------
  204. Linux Building Bootloader
  205. ----------------------
  206. *NOTE* Does not apply to Teensy based builds.
  207. From this directory.
  208. cd Bootloader
  209. mkdir build
  210. cd build
  211. cmake ..
  212. make
  213. Example output:
  214. TODO
  215. ----------------------
  216. Linux Loading Bootloader
  217. ----------------------
  218. *NOTE* Does not apply to Teensy based builds.
  219. It's recommended to use an SWD-type flasher like a Bus Pirate.
  220. TODO
  221. (Guidelines here https://github.com/mchck/mchck/wiki/Getting-Started)
  222. ----------------------
  223. Windows Building
  224. ----------------------
  225. From this directory.
  226. mkdir build
  227. cd build
  228. wincmake ..
  229. make
  230. Example output:
  231. $ cmake -G "Unix Makefiles" ..
  232. -- Compiler Family:
  233. avr
  234. -- MCU Selected:
  235. atmega32u4
  236. -- CPU Selected:
  237. megaAVR
  238. -- Detected Scan Module Source Files:
  239. Scan/SKM67001/../matrix/matrix_scan.c;Scan/SKM67001/../matrix/scan_loop.c
  240. -- Detected Macro Module Source Files:
  241. Macro/PartialMap/macro.c
  242. -- Detected Output Module Source Files:
  243. Output/pjrcUSB/output_com.c;Output/pjrcUSB/avr/usb_keyboard_serial.c
  244. -- Detected Debug Module Source Files:
  245. Debug/full/../cli/cli.c;Debug/full/../led/led.c;Debug/full/../print/print.c
  246. -- Found Git: C:/cygwin64/bin/git.exe (found version "1.7.9")
  247. -- Configuring done
  248. -- Generating done
  249. -- Build files have been written to: C:/cygwin64/home/jacob.alexander/src/capsense-beta/build
  250. jacob.alexander@JALEXANDER2-LT ~/src/capsense-beta/build
  251. $ make
  252. Scanning dependencies of target kiibohd.elf
  253. [ 10%] Building C object CMakeFiles/kiibohd.elf.dir/main.c.obj
  254. [ 20%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/matrix/matrix_scan.c.obj
  255. [ 30%] Building C object CMakeFiles/kiibohd.elf.dir/Scan/matrix/scan_loop.c.obj
  256. [ 40%] Building C object CMakeFiles/kiibohd.elf.dir/Macro/PartialMap/macro.c.obj
  257. [ 50%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/output_com.c.obj
  258. [ 60%] Building C object CMakeFiles/kiibohd.elf.dir/Output/pjrcUSB/avr/usb_keyboard_serial.c.obj
  259. [ 70%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/cli/cli.c.obj
  260. [ 80%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/led/led.c.obj
  261. [ 90%] Building C object CMakeFiles/kiibohd.elf.dir/Debug/print/print.c.obj
  262. Linking C executable kiibohd.elf
  263. Creating load file for Flash: kiibohd.hex
  264. Creating Extended Listing: kiibohd.lss
  265. Creating Symbol Table: kiibohd.sym
  266. [ 90%] Built target kiibohd.elf
  267. Scanning dependencies of target SizeAfter
  268. [100%] Size after generation
  269. Flash Usage: data (hex)
  270. RAM Usage: data (elf)
  271. text data bss dec hex filename
  272. 0 9738 0 9738 260a kiibohd.hex
  273. 7982 1756 264 10002 2712 kiibohd.elf
  274. [100%] Built target SizeAfter
  275. ----------------------
  276. Windows Loading Firmware
  277. ----------------------
  278. First place the keyboard into re-flash mode.
  279. This can be done either by pressing the re-flash button on the PCB/Teensy.
  280. Or by entering the Kiibohd Virtual Serial Interface and using the 'reload' command.
  281. The 'load' script that is created during the build can load the firmware over USB.
  282. To load the newly built firmware:
  283. ./load
  284. Be patient the couple of times, Windows is slow at installing drivers...
  285. ----------------------
  286. Mac OS X Building
  287. ----------------------
  288. From this directory.
  289. mkdir build
  290. cd build
  291. cmake ..
  292. make
  293. Example output:
  294. TODO
  295. ----------------------
  296. Mac OS X Loading Firmware
  297. ----------------------
  298. First place the keyboard into re-flash mode.
  299. This can be done either by pressing the re-flash button on the PCB/Teensy.
  300. Or by entering the Kiibohd Virtual Serial Port and using the 'reload' command.
  301. The 'load' script that is created during the build can load the firmware over USB.
  302. To load the newly built firmware:
  303. ./load
  304. ----------------------
  305. Virtual Serial Port - CLI
  306. ----------------------
  307. Rather than use a special program that can interpret Raw HID, this controller exposes a USB Serial CDC endpoint.
  308. This allows for you to use a generic serial terminal to debug/control the keyboard firmware (e.g. Tera Term, minicom, screen)
  309. -------
  310. | Linux |
  311. -------
  312. I generally use screen.
  313. You will need sudo/root priviledges if you haven't installed the 98-kiibohd.rules file to /etc/udev/rules.d
  314. screen /dev/ttyACM0
  315. (Might be ACM1, ACM2, etc.)
  316. ---------
  317. | Windows |
  318. ---------
  319. Make sure the Teensy Virtual Serial Port driver is installed.
  320. If possible use screen (as part of Cygwin).
  321. Check which COM port the virtual serial port has been assigned to:
  322. Device Manager->Ports (COM & LPT)->Teensy USB Serial
  323. In brackets it will say which COM port (e.g. COM3)
  324. putty works well when using DTR/DSR or RTS/CTS flow control.
  325. Connection type: Serial
  326. Serial line: <Your COM port, e.g. COM3>
  327. Speed: (doesn't matter, it's auto-negotiated)
  328. Under Category->Connections->Serial
  329. Flow control: DTR/DSR
  330. If stuff is hard to read (you have a dumb colour scheme):
  331. Category->Window->Colours->Use system colur
  332. That seems to make text at least readable (I use a custom colour scheme that makes each colour easy to see -HaaTa).
  333. Unfortunately, screen for Cygwin seems to be broken for serial ports, but you can try it...
  334. screen /dev/ttyS2
  335. (Might be a different file, ttyS0, ttyACM0, ttyUSB0, etc.)
  336. Gnu screen doesn't seem to echo all the characters (it works though).
  337. I believe it's a problem with stty, but I don't know how to fix it...
  338. ----------
  339. | Mac OS X |
  340. ----------
  341. I recommend screen (can be installed via Macports).
  342. screen /dev/tty.<usb something>