diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-12-13 21:03:11 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-12-13 21:03:11 +0100 |
commit | afbb4cc73c44b6321cae39dbe46b97155805097d (patch) | |
tree | ae19f517062b99df2d1b364db10f51d6b9fbc93f /cmake | |
download | stm32f103-playground-afbb4cc73c44b6321cae39dbe46b97155805097d.tar.gz stm32f103-playground-afbb4cc73c44b6321cae39dbe46b97155805097d.tar.bz2 stm32f103-playground-afbb4cc73c44b6321cae39dbe46b97155805097d.tar.xz stm32f103-playground-afbb4cc73c44b6321cae39dbe46b97155805097d.zip |
wip
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/stm32.ld | 36 | ||||
-rw-r--r-- | cmake/stm32.toolchain.cmake | 47 |
2 files changed, 83 insertions, 0 deletions
diff --git a/cmake/stm32.ld b/cmake/stm32.ld new file mode 100644 index 0000000..48e3d0c --- /dev/null +++ b/cmake/stm32.ld @@ -0,0 +1,36 @@ +/* + * https://github.com/barrybingo/SunMoonSim/blob/master/LinkerScript/STM32F103-MD.ld + */ + +/* Entry Point */ +ENTRY(_Reset_Handler) + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20k + MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K +} + +_data_start = ORIGIN(RAM); +_data_end = ORIGIN(RAM) + LENGTH(RAM); +_estack = ORIGIN(RAM) + LENGTH(RAM); + +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x100; /* required amount of stack */ + +SECTIONS +{ + .text : + { + KEEP(*(isr_vectors)) + *(.text.main) + KEEP(*(.text.*)) + /* + *(.text.*) + KEEP(*(.text.high)) + KEEP(*(.text.low)) + /**/ + } >FLASH +} diff --git a/cmake/stm32.toolchain.cmake b/cmake/stm32.toolchain.cmake new file mode 100644 index 0000000..b9acf62 --- /dev/null +++ b/cmake/stm32.toolchain.cmake @@ -0,0 +1,47 @@ +include(CMakeForceCompiler) + +set(TRIPLE "arm-none-eabi") + +if (TOOLCHAIN_ROOT) + message("Setting ENV: ${TOOLCHAIN_ROOT}") + set(ENV[_TOOLCHAIN_ROOT} "${TOOLCHAIN_ROOT}") +else () + message("Setting locally ENV: ${TOOLCHAIN_ROOT}") + set(TOOLCHAIN_ROOT "$ENV{_TOOLCHAIN_ROOT}") +endif () + +if (TOOLCHAIN_ROOT STREQUAL "") + set(TOOLCHAIN_ROOT /usr) + message("Using default TOOLCHAIN_ROOT: ${TOOLCHAIN_ROOT}") +else () + message("Using TOOLCHAIN_ROOT: ${TOOLCHAIN_ROOT}") +endif () + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) +set(CMAKE_CROSSCOMPILING 1) + +set(TARGET_FLAGS "-mcpu=cortex-m3 -mthumb") +set(BASE_FLAGS "-Wall -g -ffunction-sections -fdata-sections ${TARGET_FLAGS}") + +set(CMAKE_C_FLAGS "${BASE_FLAGS}" CACHE STRING "c flags") # XXX Generate TIME_T dynamically. +set(CMAKE_CXX_FLAGS "${BASE_FLAGS} -fno-exceptions -fno-rtti -felide-constructors -std=gnu++0x" CACHE STRING "c++ flags") + +#set(LINKER_FLAGS "-Os -Wl,--gc-sections ${TARGET_FLAGS} -T${TEENSY_ROOT}/mk20dx256.ld") +#set(LINKER_FLAGS "-Os -Wl,--gc-sections ${TARGET_FLAGS}") +set(LINKER_FLAGS "-O0 -Wl,--gc-sections ${TARGET_FLAGS}") +set(LINKER_FLAGS "-O0 ${TARGET_FLAGS}") +set(LINKER_LIBS "-larm_cortexM4l_math -lm") +#set(CMAKE_SHARED_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" FORCE) +#set(CMAKE_MODULE_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" FORCE) + +CMAKE_FORCE_C_COMPILER("${TOOLCHAIN_ROOT}/bin/${TRIPLE}-gcc" GNU) +CMAKE_FORCE_CXX_COMPILER("${TOOLCHAIN_ROOT}/bin/${TRIPLE}-g++" GNU) +# search for programs in the build host directories +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# add_definitions(-MMD) |