You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.6 KiB
87 lines
3.6 KiB
####################################################################################################
|
|
#PROJECT & LIBRARIES : defined by user and important that it comes after the VARIABLES otherwise the Set varibale will not be used.
|
|
####################################################################################################
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
set(CMAKE_SYSTEM_NAME Generic)
|
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
|
set(CMAKE_CROSSCOMPILING TRUE)
|
|
|
|
####################################################################################################
|
|
#VARIABLES : defined by user
|
|
####################################################################################################
|
|
# Set the required Startup Code
|
|
set(STARTUP_CODE ${CSL_STARTUP_DIR}/startup_stm32f042x6.s)
|
|
|
|
# Sartup can and will most propably require some extra flags
|
|
set(STARTUP_FLAGS -x assembler-with-cpp ${MAIN_FLAGS})
|
|
|
|
# Defines should be the same as the other sources but somes extras could be added if needed
|
|
set(STARTUP_DEFS ${MAIN_DEFS})
|
|
|
|
# Defines the linker to be used
|
|
set(LINKER ${CSL_STARTUP_DIR}/STM32F042K6Tx_FLASH.ld)
|
|
|
|
# Defines The MCU CORE
|
|
set(CPU_MCU "-mcpu=cortex-m0")
|
|
|
|
|
|
####################################################################################################
|
|
# MAIN COMPILING FLAGS
|
|
####################################################################################################
|
|
# For flags please check https://manned.org/arm-none-eabi-gcc/34fd6095
|
|
set(MAIN_FLAGS
|
|
${CPU_MCU}
|
|
-mthumb #Instruction set : https://stackoverflow.com/questions/10638130/what-is-the-arm-thumb-instruction-set
|
|
## -O1
|
|
-Wall #Error : If you don't know this one please chek basical compiling
|
|
-fdata-sections #Optimization : Linker can perform optimizations to improve locality of reference in the instruction space.
|
|
-fdiagnostics-color=always
|
|
-ffunction-sections #Optimization : used with -fdata-sections
|
|
$<$<CONFIG:Debug>:-O -g -gdwarf-2>)
|
|
|
|
####################################################################################################
|
|
# DEFINITIONS
|
|
####################################################################################################
|
|
set(MAIN_DEFS
|
|
-DARM_MCU #Defined by kerem to auto configure headers in main.hpp
|
|
-DUSE_FULL_LL_DRIVER
|
|
-DSTM32F042x6
|
|
-DHSE_VALUE=8000000
|
|
-DHSE_STARTUP_TIMEOUT=100
|
|
-DLSE_STARTUP_TIMEOUT=5000
|
|
-DLSE_VALUE=32768
|
|
-DHSI_VALUE=8000000
|
|
-DLSI_VALUE=40000
|
|
-DVDD_VALUE=3300
|
|
-DPREFETCH_ENABLE=1
|
|
-DINSTRUCTION_CACHE_ENABLE=0
|
|
-DDATA_CACHE_ENABLE=0)
|
|
|
|
####################################################################################################
|
|
# LINKER FLAGS
|
|
####################################################################################################
|
|
#The order is important
|
|
set(LINKER_FLAGS
|
|
${CPU_MCU}
|
|
-mthumb
|
|
-specs=nano.specs
|
|
-T${LINKER}
|
|
-lc
|
|
-lm
|
|
-lnosys
|
|
-Wl,-Map=${PROJECT_NAME}.map,--cref
|
|
-Wl,--gc-sections)
|
|
|
|
####################################################################################################
|
|
# Creation of the startup library : Use only needs to chnage the definitions made at the beginning
|
|
####################################################################################################
|
|
add_library(startup ${STARTUP_CODE})
|
|
target_compile_options(startup PRIVATE ${STARTUP_FLAGS})
|
|
target_compile_definitions(startup PRIVATE ${STARTUP_DEFS})
|
|
add_library(sub::startup ALIAS startup)
|
|
|
|
####################################################################################################
|
|
# Sartupt uCode Definition this part Is left alone on purpose !
|
|
####################################################################################################
|
|
set(STARTUP_UCODE sub::startup)
|