Added lots of comments.
Added comments about the file, specs, compile and build options.
This commit is contained in:
parent
0f71a0cfd0
commit
aed74f5710
|
@ -2,17 +2,23 @@
|
|||
# STM32 toolchain file
|
||||
# ###############################
|
||||
|
||||
# ----------------------------------------
|
||||
# File: stm32-toolchain.cmake
|
||||
# Description: Cmake file for the stm32 controllers. It has two differnt
|
||||
# types of kinds things it can output. It can output or build release binaries
|
||||
# or it output debug builds.
|
||||
# ----------------------------------------
|
||||
|
||||
|
||||
##################################################
|
||||
# Configurable Section
|
||||
##################################################
|
||||
|
||||
|
||||
|
||||
# Specify the cross-compiler
|
||||
set(CROSS_TOOLCHAIN arm-none-eabi-)
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
set(CMAKE_CROSSCOMPILING 1)
|
||||
set(DEBUG_BINARY 1)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
|
||||
|
@ -31,6 +37,8 @@ set(MCU_DIR inc/${MCU}/)
|
|||
#set(MCU_SPEC cortex-m3)
|
||||
#set(MCU_SPEC cortex-m4)
|
||||
set(MCU_SPEC cortex-m0plus) # Might need to change?
|
||||
|
||||
set(FLOAT_SPEC "") # Use when you have no FPU.
|
||||
# set(FLOAT_SPEC "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
|
||||
|
||||
# The Startup(ASM) files
|
||||
|
@ -120,7 +128,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto " CACHE INTERNAL "C++ Compiler options fo
|
|||
set(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "ASM Compiler options for release build type")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto " CACHE INTERNAL "Linker options for release build type")
|
||||
|
||||
if(CMAKE_CROSSCOMPILING STREQUAL "1")
|
||||
if(DEBUG_BINARY STREQUAL "1") # -- START: Debug Binary
|
||||
# Control specific options if crosscompiling
|
||||
|
||||
message(STATUS "[INFO] Cross compiling for ${MCU}")
|
||||
|
@ -135,6 +143,12 @@ if(CMAKE_CROSSCOMPILING STREQUAL "1")
|
|||
#-------------------
|
||||
# General Flags for cross
|
||||
#-------------------
|
||||
# "thumb":: Compressed instructions, 16bits. Using only ARM is an option
|
||||
# as well.
|
||||
# "-mcpu":: The selected and in use CPU.
|
||||
# "-mthumb":: Enable the thumb(16bit) instructions.
|
||||
# "-mthumb-interwork":: Support calling between ARM and Thumb instructions
|
||||
# "-mabi":: Generate code for the given application binary interface.
|
||||
string(APPEND OBJECT_GEN_FLAGS " \
|
||||
-mcpu=${MCU_SPEC} \
|
||||
-mthumb \
|
||||
|
@ -142,6 +156,8 @@ if(CMAKE_CROSSCOMPILING STREQUAL "1")
|
|||
-mabi=aapcs \
|
||||
${FLOAT_SPEC} \
|
||||
")
|
||||
# "aapcs":: Procedure Call Standard for Arm Architecture
|
||||
|
||||
|
||||
#-------------------
|
||||
# CFLAGS for cross
|
||||
|
@ -178,49 +194,20 @@ if(CMAKE_CROSSCOMPILING STREQUAL "1")
|
|||
message(FATAL_ERROR "[ERRR] Could not find linker script ${LINKER_SCRIPT}")
|
||||
endif()
|
||||
|
||||
# semihosting:: is a mechanism that enables code running on an ARM target
|
||||
# to communicate and use the Input/Output facilities on a host computer
|
||||
# that is running a debugger.
|
||||
if("${SEMIHOSTING}" STREQUAL "1")
|
||||
#"rdimon":: remote dispatch interface monitor
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS "--specs=rdimon.specs -lc -lrdimon ")
|
||||
else()
|
||||
#"nosys":: systems call are stubbed out.
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs ")
|
||||
endif()
|
||||
|
||||
else()
|
||||
# Flags and options to set while compiling natively
|
||||
message(STATUS "[INFO] Compiling natively")
|
||||
|
||||
#-------------------
|
||||
# General Flags for native
|
||||
#-------------------
|
||||
string(APPEND OBJECT_GEN_FLAGS " \
|
||||
--coverage \
|
||||
")
|
||||
|
||||
#-------------------
|
||||
# CFLAGS for native
|
||||
#-------------------
|
||||
string(APPEND CMAKE_C_FLAGS " \
|
||||
${OBJECT_GEN_FLAGS} \
|
||||
")
|
||||
|
||||
#-------------------
|
||||
# ASMFLAGS for native
|
||||
#-------------------
|
||||
string(APPEND CMAKE_ASM_FLAGS " \
|
||||
${OBJECT_GEN_FLAGS} \
|
||||
")
|
||||
|
||||
#-------------------
|
||||
# LFLAGS for native
|
||||
#-------------------
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " \
|
||||
${OBJECT_GEN_FLAGS} \
|
||||
")
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# Actual build which will go onto the board
|
||||
if(TARGET_GROUP STREQUAL production)
|
||||
# AKA production build.
|
||||
|
||||
######################################################################
|
||||
# @Target: ${PROJECT_NAME}.elf
|
||||
|
@ -281,7 +268,7 @@ if(TARGET_GROUP STREQUAL production)
|
|||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Given TARGET_GROUP unknown")
|
||||
endif()
|
||||
endif() # -- END: DEBUG/RELEASE Binary
|
||||
|
||||
# Unset all cache
|
||||
unset(SEMIHOSTING)
|
||||
|
|
Loading…
Reference in New Issue