]> git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/chibios/README.md
Move STM32 bootloader address config to separate .h file.
[tmk_keyboard.git] / tmk_core / protocol / chibios / README.md
1 ## TMK running on top of ChibiOS
2
3 ### Notes
4
5 - To use, unpack or symlink [ChibiOS] {currently 3.0.2} to `tmk_core/tool/chibios/chibios`.
6 - For gcc options, inspect `tmk_core/tool/chibios/chibios.mk`. For instance, I enabled `-Wno-missing-field-initializers`, because TMK common bits generated a lot of warnings on that.
7 Also pay attention to `-O0` (enabled for debugging); for deployment use `-O2`.
8 - USB string descriptors are messy. I did not find a way to cleanly generate the right structures from actual strings, so the definitions in individual keyboards' `config.h` are ugly as heck.
9 - There are some random constants left so far, e.g. 5ms sleep between calling `keyboard_task`, or 1.5sec wait for USB init, in `main.c`. There should be no such in `usb_main.c` (the main USB stack). Everything is based on timers/interrupts/kernel scheduling (well except `keyboard_task`), so no periodically called things (again, except `keyboard_task`, which is just how TMK is designed).
10 - It is easy to add some code for testing (e.g. blink LED, do stuff on button press, etc...) - just create another thread in `main.c`, it will run independently of the keyboard business.
11 - Jumping to bootloader works, but it is not entirely pleasant, since it is very much MCU dependent. The code is now geared towards STM32 chips and their built-in bootloaders. So, one needs to dig out the right address to jump to, and either pass it to the compiler in the `Makefile`, or better, define it in `<your_kb>/bootloader_defs.h`. Also, a patch to upstream ChibiOS is needed (supplied), because it `ResetHandler` needs adjusting.
12 - Sleep LED works, but at the moment only on/off, i.e. no breathing.
13 - The USB stack works pretty completely; however there are bits of other TMK stuff that are not done yet:
14
15 ### Immediate todo
16
17 - host-wakeup packet sending during suspend
18 - power saving for suspend?
19 - PWM for sleep led
20
21 ### Not tested, but possibly working
22
23 - backlight
24
25 ### Missing / not working (TMK vs ChibiOS bits)
26
27 - eeprom / bootmagic (will be chip dependent; eeprom needs to be emulated in flash, which means less writes; wear-levelling?) There is a semi-official ST "driver" for eeprom, with wear-levelling, but I think it consumes a lot of RAM (like 2 pages, i.e. 1kB or so).
28
29 ### Tried with
30
31 - ChibiOS 3.0.1, 3.0.2 and ST F072RB DISCOVERY board.
32 - Need to test on other STM32 chips (F3, F4) to make it as much chip-independent as possible.
33
34 ## STM32-based keyboard design considerations
35
36 - STM32F0x2 chips can do crystal-less USB, but they still need a 3.3V voltage regulator.
37 - The BOOT0 pin should be tied to GND.
38 - For a hardware way of accessing the in-built DFU bootloader, in addition to the reset button, put another button between the BOOT0 pin and 3V3.
39 - For breathing the caps lock LED during the suspended state ("sleep LED"), it is desirable to have that LED on a hardware PWM pin (there's usually plenty of those, look for TIMERs in the datasheet). However this is not strictly necessary, because instead of direct output of a timer to a pin (better of course), it is easy to define timer callbacks in ChibiOS that turn on/off an arbitrary pin.
40
41 ## ChibiOS-supported MCUs (as of 3.0.2)
42
43 - Pretty much all STM32 chips.
44 - There is also support for AVR8, but the USB stack is not implemented for them yet, and also the kernel itself takes about 1k of RAM. I think people managed to get ChibiOS running on atmega32[8p/u4] though.
45 - There is some support for K20x and KL2x Freescale chips (i.e. Teensy 3.0, mchck, FRDM-KL25Z, FRDM-K20D50M), but again, no official USB stack yet. This is being worked on, see the `kinetis` branch of [my ChibiOS fork](https://github.com/flabbergast/ChibiOS). It supports also Teensy LC, 3.1 and FRDM-KL26Z.
46 - I've seen community support for Nordic NRF51822 (the chip in Adafruit's Bluefruit bluetooth-low-energy boards), but not sure about the extent.
47
48
49
50 [ChibiOS]: http://chibios.org
Imprint / Impressum