summaryrefslogtreecommitdiffstats
path: root/keyboard/infinity/mbed-infinity/README
blob: 43051c9003856097de53da8f1ac1106879977d94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
mbed fix for Infinity
=====================
Without linker script patch it doesn't place vector table in final binary.
And clock is configured to 48MHz using internal clock reference and FLL multiplication.


mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
    Fix SystemInit: clock setup for internal clock. Inifinity has no external Xtal.

mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/cmsis_nvic.c
    Fix NVIC vector address of firmware 0x1000 instead of 0x0

mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
    Fix memory map for Infinity bootloader
        Flash starts at 0x1000
        No flash config bytes sector

USBDevice/USBDevice/USBHAL_KL25Z.cpp
    Fix USB clock setup, see below.


2015/01/04  Based on mbed-sdk @2f63fa7d78a26.



Kinetis USB config
==================
Clock source: Internal reference clock wth FLL
    SIM_SOPT[USBSRC] = 1(MCGPLLCLK/MCGFLLCLK)
    SIM_SOPT[PLLSEL] = 0(MCGFLLCLK)

Clock dividor:
    SIM_CLKDIV2[USBDIV] = 0
    SIM_CLKDIV2[USBFAC] = 0

Clock enable:
    SIM_SCGC4[USBOTG] = 1



Infinity bootloader change
==========================
After @2c7542e(2015/01) Infinity bootloader doesn't disable watchdog timer and keyboard firmware has to do it itself.  mbed disables watchdog in startup sequence but unfortunately timer is timed out bofore that.

We have to do that in earlier phase of mbed startup sequence.


mbed starup sequence files:
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_M20D5.s
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c

Infinity booloader change commit:
https://github.com/kiibohd/controller/commit/2c7542e2e7f0b8a99edf563dc53164fe1a439483

discussion:
https://geekhack.org/index.php?topic=41989.msg1686616#msg1686616


WORKAROUND
----------
Call SystemInit early in Reset_Handler.

$ diff -u ../../mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.s mbed-infinity
--- ../../mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.s      2015-03-22 10:33:22.779866000 +0900
+++ mbed-infinity/startup_MK20D5.s      2015-03-22 10:32:56.483866000 +0900
@@ -147,6 +147,8 @@
  *      __etext: End of code section, i.e., begin of data sections to copy from.
  *      __data_start__/__data_end__: RAM address range that data should be
  *      copied to. Both must be aligned to 4 bytes boundary.  */
+    ldr    r0, =SystemInit
+    blx    r0

     ldr    r1, =__etext
     ldr    r2, =__data_start__
@@ -161,8 +163,6 @@

 .Lflash_to_ram_loop_end:

-    ldr    r0, =SystemInit
-    blx    r0
     ldr    r0, =_start
     bx    r0
     .pool