]> git.donarmstrong.com Git - kiibohd-controller.git/blobdiff - Lib/CMake/arm.cmake
Adding 72 MHz clock support for mk20dx256vlh7
[kiibohd-controller.git] / Lib / CMake / arm.cmake
index 3a62fe583ee6ec835b9d442fddbbc9daea4ffc48..be04de2afe4eb46d7cc979b71fc5c919d7945020 100644 (file)
 
 #| Set the Compilers (must be set first)
 include( CMakeForceCompiler )
-cmake_force_c_compiler  ( arm-none-eabi-gcc ARMCCompiler )
-cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
-set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
+message( STATUS "Compiler Selected:" )
+if ( "${COMPILER}" MATCHES "gcc" )
+       cmake_force_c_compiler  ( arm-none-eabi-gcc ARMCCompiler )
+       cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
+       set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
+       message( "gcc" )
+elseif ( "${COMPILER}" MATCHES "clang" )
+       cmake_force_c_compiler  ( clang   ARMCCompiler )
+       cmake_force_cxx_compiler( clang++ ARMCxxCompiler )
+       set( _CMAKE_TOOLCHAIN_PREFIX llvm- )
+       message( "clang" )
+else ()
+       message( AUTHOR_WARNING "COMPILER: ${COMPILER} - Unknown compiler selection" )
+endif ()
 
 
 
@@ -25,7 +36,9 @@ set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
 
 #| Chip Name (Linker)
 #|
-#| "mk20dx128"        # Teensy   3.0 and McHCK mk20dx128
+#| "mk20dx128vlf5"    # McHCK / Kiibohd-dfu
+#| "mk20dx256vlh7"    # Kiibohd-dfu
+#| "mk20dx128"        # Teensy   3.0
 #| "mk20dx256"        # Teensy   3.1
 
 message( STATUS "Chip Selected:" )
@@ -33,21 +46,35 @@ message( "${CHIP}" )
 set( MCU "${CHIP}" ) # For loading script compatibility
 
 
-#| Chip Size Database
-#| MCHCK Based
+#| Chip Size and CPU Frequency Database
+#| Processor frequency.
+#|   Normally the first thing your program should do is set the clock prescaler,
+#|   so your program will run at the correct speed.  You should also set this
+#|   variable to same clock speed.  The _delay_ms() macro uses this, and many
+#|   examples use this variable to calculate timings.  Do not add a "UL" here.
+#| MCHCK Based / Kiibohd-dfu
 if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
        set( SIZE_RAM    16384 )
        set( SIZE_FLASH 126976 )
+       set( F_CPU "48000000" )
+
+#| Kiibohd-dfu
+elseif ( "${CHIP}" MATCHES "mk20dx256vlh7" )
+       set( SIZE_RAM    65536 )
+       set( SIZE_FLASH 253952 )
+       set( F_CPU "72000000" )
 
 #| Teensy 3.0
 elseif ( "${CHIP}" MATCHES "mk20dx128" )
        set( SIZE_RAM    16384 )
        set( SIZE_FLASH 131072 )
+       set( F_CPU "48000000" )
 
 #| Teensy 3.1
 elseif ( "${CHIP}" MATCHES "mk20dx256" )
        set( SIZE_RAM    65536 )
        set( SIZE_FLASH 262144 )
+       set( F_CPU "48000000" ) # XXX Also supports 72 MHz, but may requires code changes
 
 #| Unknown ARM
 else ()
@@ -90,11 +117,12 @@ message( "${COMPILER_SRCS}" )
 
 #| USB Defines, this is how the loader programs detect which type of chip base is used
 message( STATUS "Bootloader Type:" )
-if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
+if ( "${CHIP}" MATCHES "mk20dx128vlf5" OR "${CHIP}" MATCHES "mk20dx256vlh7" )
        set( VENDOR_ID       "0x1C11" )
        set( PRODUCT_ID      "0xB04D" )
        set( BOOT_VENDOR_ID  "0x1C11" )
        set( BOOT_PRODUCT_ID "0xB007" )
+       set( BOOT_DFU_ALTNAME "Kiibohd DFU" )
        set( DFU 1 )
        message( "dfu" )
 elseif ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" )
@@ -127,6 +155,8 @@ set( WARN "-Wall -ggdb3" )
 if( BOOTLOADER )
        set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -nostdlib" )
        #set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" )
+elseif ( "${COMPILER}" MATCHES "clang" )
+       set( TUNING "-target arm-none-eabi -mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin" )
 else()
        set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" )
 endif()
@@ -138,14 +168,6 @@ endif()
 set( OPT "s" )
 
 
-#| Processor frequency.
-#|   Normally the first thing your program should do is set the clock prescaler,
-#|   so your program will run at the correct speed.  You should also set this
-#|   variable to same clock speed.  The _delay_ms() macro uses this, and many
-#|   examples use this variable to calculate timings.  Do not add a "UL" here.
-set( F_CPU "48000000" )
-
-
 #| Dependency Files
 #| Compiler flags to generate dependency files.
 set( GENDEPFLAGS "-MMD" )
@@ -174,5 +196,9 @@ set( BIN_FLAGS -O binary )
 
 
 #| Lss Flags
-set( LSS_FLAGS -h -S -z )
+if ( "${COMPILER}" MATCHES "clang" )
+       set( LSS_FLAGS -section-headers -triple=arm-none-eabi )
+else ()
+       set( LSS_FLAGS -h -S -z )
+endif ()