chore: Use CMake way for linker options (#4396)

Co-authored-by: Richard Li <richard.li@ces.hk>
This commit is contained in:
Raphael Coeffic
2023-12-14 09:12:31 +10:00
committed by GitHub
co-authored by Richard Li
parent f10e5e879f
commit 42e245b1da
8 changed files with 76 additions and 43 deletions
@@ -10,6 +10,9 @@ set(ARCH ARM)
set(STM32USB_DIR ${THIRDPARTY_DIR}/STM32_USB-Host-Device_Lib_V2.2.0/Libraries)
add_definitions(-DSTM32 -DLUA_INPUTS -DVARIO)
set(LINKER_DIR ${RADIO_SRC_DIR}/boards/generic_stm32/linker)
add_link_options(-L${LINKER_DIR} -L${LINKER_DIR}/${TARGET_LINKER_DIR})
include_directories(${RADIO_SRC_DIR}/targets/common/arm/stm32)
include_directories(${STM32USB_DIR}/STM32_USB_OTG_Driver/inc)
include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Core/inc)
@@ -151,19 +151,29 @@ remove_definitions(-DUSE_WATCHDOG)
add_definitions(-DBOOT)
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm")
set(LINKER_DIR ${RADIO_SRC_DIR}/boards/generic_stm32/linker)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T${LINKER_DIR}/bootloader.ld -L${LINKER_DIR} -L${LINKER_DIR}/${TARGET_LINKER_DIR}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections")
# use smaller nano libc
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs")
add_executable(bootloader EXCLUDE_FROM_ALL ${BOOTLOADER_SRC})
add_dependencies(bootloader ${BITMAPS_TARGET})
target_link_options(bootloader PRIVATE
-lm -nostartfiles -T${LINKER_DIR}/bootloader.ld
-Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections
--specs=nano.specs
)
if (DEFINED TARGET_SDRAM_START)
# message("TARGET_SDRAM_START = ${TARGET_SDRAM_START}")
target_link_options(bootloader PRIVATE
-Wl,--defsym=__sdram_start=${TARGET_SDRAM_START}
)
endif()
if (DEFINED TARGET_SDRAM_SIZE)
# message("TARGET_SDRAM_SIZE = ${TARGET_SDRAM_SIZE}")
target_link_options(bootloader PRIVATE
-Wl,--defsym=__sdram_size=${TARGET_SDRAM_SIZE}
)
endif()
target_include_directories(bootloader
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
@@ -3,6 +3,12 @@ set(MCU cortex-m3)
set(FPU_FLAGS "")
if(NOT NATIVE_BUILD)
# Add MCU specific flags
add_link_options(
-mcpu=cortex-m3 -mfloat-abi=soft
)
# STM32 HAL/LL library
set(STM32CUBE_DIR ${THIRDPARTY_DIR}/STM32F2xx_HAL_Driver)
include_directories(${STM32CUBE_DIR}/Inc)
@@ -3,6 +3,12 @@ set(MCU cortex-m4)
set(FPU_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
if(NOT NATIVE_BUILD)
# Add MCU specific flags
add_link_options(
-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
)
# STM32 HAL/LL library
set(STM32CUBE_DIR ${THIRDPARTY_DIR}/STM32F4xx_HAL_Driver)
include_directories(${STM32CUBE_DIR}/Inc)