Commit 7108b71f authored by Erik Strand's avatar Erik Strand
Browse files

Factor out asf library code

parent b352b384
......@@ -25,50 +25,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
add_library(asf OBJECT
samd51/startup/startup_samd51.c
samd51/startup/system_samd51.c
)
target_include_directories(asf PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/samd51
${CMAKE_CURRENT_SOURCE_DIR}/samd51/CMSIS/Include
${CMAKE_CURRENT_SOURCE_DIR}/samd51/include
${CMAKE_CURRENT_SOURCE_DIR}/samd51/startup
)
target_link_libraries(asf m)
target_link_options(asf PUBLIC
-mthumb
-mabi=aapcs-linux
-mlong-calls
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp
-DSAMD51
-T${CMAKE_CURRENT_SOURCE_DIR}/samd51/startup/samd51j19a_flash.ld
-L${CMAKE_CURRENT_SOURCE_DIR}/samd51/startup
#-Wl,--start-group
#-Wl,--end-group
#-Wl,-Map="main.map"
--specs=nano.specs
-Wl,--gc-sections
)
target_compile_options(asf PUBLIC
-D${MCU_DEFINE}
-x c
-DDEBUG
-Os
-ffunction-sections
#-g3
-Wall
-std=gnu99
-mthumb # use T32 instruction set instead of A32 (don't know if this matters)
-mabi=aapcs-linux
-mlong-calls # changes how functions are called
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp # this flag specifies whether to use software or hardware float operations
-DSAMD51
)
add_subdirectory(samd51)
add_executable(hello_world
main.c
......
#---------------------------------------------------------------------------------------------------
# This file creates an asf library.
# By default, cmake would make a static library and package the object files into an archive. This
# doesn't work since the linker then throws away the startup code, since it's not called by
# anything. (It actually calls main.) So instead we use an object library, which tells cmake to
# leave the contents as bare object files and directly compile them into any target that needs them.
add_library(asf OBJECT
startup/startup_samd51.c
startup/system_samd51.c
)
target_include_directories(asf PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS/Include
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(asf m)
target_link_options(asf PUBLIC
-mthumb
-mabi=aapcs-linux
-mlong-calls
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp
-DSAMD51
-T${CMAKE_CURRENT_SOURCE_DIR}/startup/samd51j19a_flash.ld
-L${CMAKE_CURRENT_SOURCE_DIR}/startup
#-Wl,--start-group
#-Wl,--end-group
#-Wl,-Map="main.map"
--specs=nano.specs
-Wl,--gc-sections
)
target_compile_options(asf PUBLIC
-D${MCU_DEFINE}
-x c
-DDEBUG
-Os
-ffunction-sections
#-g3
-Wall
-std=gnu99
-mthumb # use T32 instruction set instead of A32 (don't know if this matters)
-mabi=aapcs-linux
-mlong-calls # changes how functions are called
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp # this flag specifies whether to use software or hardware float operations
-DSAMD51
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment