mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-21 07:21:00 +00:00
add IAR support for G0 with cmake
This commit is contained in:
parent
e7090c7514
commit
fcf7791454
examples/device/net_lwip_webserver
hw/bsp
src
tools/cmake
@ -77,12 +77,16 @@ target_sources(${PROJECT} PUBLIC
|
||||
)
|
||||
|
||||
# due to warnings from other net source, we need to prevent error from some of the warnings options
|
||||
target_compile_options(${PROJECT} PUBLIC
|
||||
-Wno-error=null-dereference
|
||||
-Wno-error=conversion
|
||||
-Wno-error=sign-conversion
|
||||
-Wno-error=sign-compare
|
||||
)
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${PROJECT} PUBLIC
|
||||
-Wno-error=null-dereference
|
||||
-Wno-error=conversion
|
||||
-Wno-error=sign-conversion
|
||||
-Wno-error=sign-compare
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
|
||||
endif ()
|
||||
|
||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||
# in hw/bsp/FAMILY/family.cmake for details.
|
||||
|
@ -97,6 +97,87 @@ function(family_initialize_project PROJECT DIR)
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Main target configure
|
||||
#------------------------------------
|
||||
|
||||
# Add common configuration to example
|
||||
function(family_configure_common TARGET)
|
||||
# run size after build
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GCC")
|
||||
# Generate map file
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
# link map
|
||||
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# configure an executable target to link to tinyusb in device mode, and add the board implementation
|
||||
function(family_configure_device_example TARGET)
|
||||
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
|
||||
endfunction()
|
||||
|
||||
|
||||
# configure an executable target to link to tinyusb in host mode, and add the board implementation
|
||||
function(family_configure_host_example TARGET)
|
||||
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add tinyusb to example
|
||||
function(family_add_tinyusb TARGET OPT_MCU)
|
||||
# tinyusb target is built for each example since it depends on example's tusb_config.h
|
||||
set(TINYUSB_TARGET_PREFIX ${TARGET}-)
|
||||
add_library(${TARGET}-tinyusb_config INTERFACE)
|
||||
|
||||
target_include_directories(${TARGET}-tinyusb_config INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
|
||||
CFG_TUSB_MCU=${OPT_MCU}
|
||||
)
|
||||
|
||||
# tinyusb's CMakeList.txt
|
||||
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add freeRTOS support to example
|
||||
function(family_add_freertos TARGET)
|
||||
# freeros config
|
||||
if (NOT TARGET freertos_config)
|
||||
add_library(freertos_config INTERFACE)
|
||||
target_include_directories(freertos_config INTERFACE
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${FAMILY}/FreeRTOSConfig
|
||||
)
|
||||
endif()
|
||||
|
||||
# freertos kernel should be generic as freertos_config however, CMAKE complains with missing variable
|
||||
# such as CMAKE_C_COMPILE_OBJECT
|
||||
if (NOT TARGET freertos_kernel)
|
||||
add_subdirectory(${TOP}/lib/FreeRTOS-Kernel ${CMAKE_BINARY_DIR}/lib/freertos_kernel)
|
||||
endif ()
|
||||
|
||||
# Add FreeRTOS option to tinyusb_config
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
|
||||
CFG_TUSB_OS=OPT_OS_FREERTOS
|
||||
)
|
||||
# link tinyusb with freeRTOS kernel
|
||||
target_link_libraries(${TARGET}-tinyusb PUBLIC
|
||||
freertos_kernel
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC
|
||||
freertos_kernel
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_add_default_example_warnings TARGET)
|
||||
target_compile_options(${TARGET} PUBLIC
|
||||
-Wall
|
||||
@ -144,85 +225,6 @@ function(family_add_default_example_warnings TARGET)
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Main target configure
|
||||
#------------------------------------
|
||||
|
||||
# Add common configuration to example
|
||||
function(family_configure_common TARGET)
|
||||
# run size after build
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
# Generate map file
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
# link map
|
||||
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
# configure an executable target to link to tinyusb in device mode, and add the board implementation
|
||||
function(family_configure_device_example TARGET)
|
||||
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
|
||||
endfunction()
|
||||
|
||||
|
||||
# configure an executable target to link to tinyusb in host mode, and add the board implementation
|
||||
function(family_configure_host_example TARGET)
|
||||
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add tinyusb to example
|
||||
function(family_add_tinyusb TARGET OPT_MCU)
|
||||
# tinyusb target is built for each example since it depends on example's tusb_config.h
|
||||
set(TINYUSB_TARGET_PREFIX ${TARGET}-)
|
||||
add_library(${TARGET}-tinyusb_config INTERFACE)
|
||||
|
||||
target_include_directories(${TARGET}-tinyusb_config INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
|
||||
CFG_TUSB_MCU=${OPT_MCU}
|
||||
)
|
||||
|
||||
# tinyusb's CMakeList.txt
|
||||
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add freeRTOS support to example
|
||||
function(family_add_freertos TARGET)
|
||||
# freeros config
|
||||
if (NOT TARGET freertos_config)
|
||||
add_library(freertos_config INTERFACE)
|
||||
target_include_directories(freertos_config SYSTEM INTERFACE
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${FAMILY}/FreeRTOSConfig
|
||||
)
|
||||
endif()
|
||||
|
||||
# freertos kernel should be generic as freertos_config however, CMAKE complains with missing variable
|
||||
# such as CMAKE_C_COMPILE_OBJECT
|
||||
if (NOT TARGET freertos_kernel)
|
||||
add_subdirectory(${TOP}/lib/FreeRTOS-Kernel ${CMAKE_BINARY_DIR}/lib/freertos_kernel)
|
||||
endif ()
|
||||
|
||||
# Add FreeRTOS option to tinyusb_config
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
|
||||
CFG_TUSB_OS=OPT_OS_FREERTOS
|
||||
)
|
||||
# link tinyusb with freeRTOS kernel
|
||||
target_link_libraries(${TARGET}-tinyusb PUBLIC
|
||||
freertos_kernel
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC
|
||||
freertos_kernel
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add bin/hex output
|
||||
function(family_add_bin_hex TARGET)
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
|
@ -53,7 +53,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (NOT DEFINED LD_FILE_${TOOLCHAIN})
|
||||
set(LD_FILE_gcc ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
|
||||
set(LD_FILE_GCC ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
|
||||
endif ()
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
@ -61,7 +61,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
|
||||
)
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_gcc}"
|
||||
"LINKER:--script=${LD_FILE_GCC}"
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
--specs=nano.specs
|
||||
|
@ -4,7 +4,7 @@ set(JLINK_DEVICE LPC18S37)
|
||||
set(PYOCD_TARGET LPC18S37)
|
||||
set(NXPLINK_DEVICE LPC18S37:LPCXPRESSO18S37)
|
||||
|
||||
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/lpc1837.ld)
|
||||
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/lpc1837.ld)
|
||||
|
||||
function(update_board TARGET)
|
||||
# nothing to do
|
||||
|
@ -4,7 +4,7 @@ set(JLINK_DEVICE LPC1857)
|
||||
set(PYOCD_TARGET LPC1857)
|
||||
set(NXPLINK_DEVICE LPC1857:MCB1857)
|
||||
|
||||
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/lpc1857.ld)
|
||||
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/lpc1857.ld)
|
||||
|
||||
function(update_board TARGET)
|
||||
# nothing to do
|
||||
|
@ -48,7 +48,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_gcc}"
|
||||
"LINKER:--script=${LD_FILE_GCC}"
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
--specs=nano.specs
|
||||
|
@ -5,7 +5,7 @@ set(JLINK_DEVICE LPC55S69)
|
||||
set(PYOCD_TARGET LPC55S69)
|
||||
set(NXPLINK_DEVICE LPC55S69:LPCXpresso55S69)
|
||||
|
||||
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/LPC55S69_cm33_core0_uf2.ld)
|
||||
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/LPC55S69_cm33_core0_uf2.ld)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -65,7 +65,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (NOT DEFINED LD_FILE_${TOOLCHAIN})
|
||||
set(LD_FILE_gcc ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
|
||||
set(LD_FILE_GCC ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
|
||||
endif ()
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
@ -74,7 +74,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
)
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
# linker file
|
||||
"LINKER:--script=${LD_FILE_gcc}"
|
||||
"LINKER:--script=${LD_FILE_GCC}"
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
--specs=nano.specs
|
||||
|
@ -1,5 +1,5 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
set(LD_FILE_gcc ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
|
||||
set(LD_FILE_GCC ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -1,5 +1,5 @@
|
||||
set(MCU_VARIANT nrf5340_application)
|
||||
set(LD_FILE_gcc ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
|
||||
set(LD_FILE_GCC ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -55,7 +55,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (NOT DEFINED LD_FILE_${TOOLCHAIN})
|
||||
set(LD_FILE_gcc ${NRFX_DIR}/mdk/${MCU_VARIANT}_xxaa.ld)
|
||||
set(LD_FILE_GCC ${NRFX_DIR}/mdk/${MCU_VARIANT}_xxaa.ld)
|
||||
endif ()
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
@ -64,7 +64,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
)
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
# linker file
|
||||
"LINKER:--script=${LD_FILE_gcc}"
|
||||
"LINKER:--script=${LD_FILE_GCC}"
|
||||
-L${NRFX_DIR}/mdk
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
|
@ -1,11 +1,11 @@
|
||||
#set(MCU_VARIANT MIMXRT1011)
|
||||
set(JLINK_DEVICE STM32G0B1RE)
|
||||
|
||||
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/STM32G0B1RETx_FLASH.ld)
|
||||
set(LD_FILE_iar ${ST_CMSIS}/Source/Templates/iar/linker/stm32g0b1xx_flash.icf)
|
||||
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/STM32G0B1RETx_FLASH.ld)
|
||||
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/stm32g0b1xx_flash.icf)
|
||||
|
||||
set(STARTUP_FILE_gcc ${ST_CMSIS}/Source/Templates/gcc/startup_stm32g0b1xx.s)
|
||||
set(STARTUP_FILE_iar ${ST_CMSIS}/Source/Templates/iar/startup_stm32g0b1xx.s)
|
||||
set(STARTUP_FILE_GCC ${ST_CMSIS}/Source/Templates/gcc/startup_stm32g0b1xx.s)
|
||||
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_stm32g0b1xx.s)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -28,50 +28,49 @@ include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
set(BOARD_TARGET board_${BOARD})
|
||||
if (NOT TARGET ${BOARD_TARGET})
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_cortex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr_ex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMSIS_5}/CMSIS/Core/Include
|
||||
${ST_CMSIS}/Include
|
||||
${ST_HAL_DRIVER}/Inc
|
||||
)
|
||||
target_compile_options(${BOARD_TARGET} PUBLIC
|
||||
)
|
||||
target_compile_definitions(${BOARD_TARGET} PUBLIC
|
||||
)
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
target_sources(${BOARD_TARGET} PUBLIC
|
||||
${STARTUP_FILE_${TOOLCHAIN}}
|
||||
)
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_gcc}"
|
||||
-nostartfiles
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
--specs=nano.specs
|
||||
function(add_board_target TARGET)
|
||||
if (NOT TARGET ${TARGET})
|
||||
add_library(${TARGET} STATIC
|
||||
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_cortex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr_ex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
else ()
|
||||
# TODO support IAR
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_iar}"
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMSIS_5}/CMSIS/Core/Include
|
||||
${ST_CMSIS}/Include
|
||||
${ST_HAL_DRIVER}/Inc
|
||||
)
|
||||
target_compile_options(${TARGET} PUBLIC
|
||||
)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
)
|
||||
|
||||
update_board(${TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GCC")
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GCC}"
|
||||
-nostartfiles
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
--specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
# TODO support IAR
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
endif () # BOARD_TARGET
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
@ -80,6 +79,9 @@ endif () # BOARD_TARGET
|
||||
function(family_configure_example TARGET)
|
||||
family_configure_common(${TARGET})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
@ -100,7 +102,7 @@ function(family_configure_example TARGET)
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_STM32G0)
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(${TARGET} PUBLIC ${BOARD_TARGET} ${TARGET}-tinyusb)
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
|
||||
|
||||
# Flashing
|
||||
family_flash_stlink(${TARGET})
|
||||
|
@ -1,11 +1,11 @@
|
||||
set(MCU_VARIANT stm32g474xx)
|
||||
set(JLINK_DEVICE stm32g474re)
|
||||
|
||||
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/STM32G474RETx_FLASH.ld)
|
||||
set(LD_FILE_iar ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
|
||||
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/STM32G474RETx_FLASH.ld)
|
||||
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
|
||||
|
||||
set(STARTUP_FILE_gcc ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_iar ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_GCC ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -1,11 +1,11 @@
|
||||
set(MCU_VARIANT stm32g474xx)
|
||||
set(JLINK_DEVICE stm32g474re)
|
||||
|
||||
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/STM32G474RETx_FLASH.ld)
|
||||
set(LD_FILE_iar ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
|
||||
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/STM32G474RETx_FLASH.ld)
|
||||
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
|
||||
|
||||
set(STARTUP_FILE_gcc ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_iar ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_GCC ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
|
@ -59,7 +59,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_gcc}"
|
||||
"LINKER:--script=${LD_FILE_GCC}"
|
||||
-nostartfiles
|
||||
# nanolib
|
||||
--specs=nosys.specs
|
||||
@ -68,7 +68,7 @@ if (NOT TARGET ${BOARD_TARGET})
|
||||
else ()
|
||||
# TODO support IAR
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_iar}"
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endif () # BOARD_TARGET
|
||||
|
@ -65,6 +65,8 @@ function(add_tinyusb TARGET)
|
||||
-Wreturn-type
|
||||
-Wredundant-decls
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
@ -1,11 +1,17 @@
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
-mthumb
|
||||
-mcpu=cortex-m0plus
|
||||
-mfloat-abi=soft
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT GCC_ARM_CM0 CACHE INTERNAL "")
|
||||
else ()
|
||||
# TODO support IAR
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "iar")
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
--cpu cortex-m0
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT IAR_ARM_CM0 CACHE INTERNAL "")
|
||||
|
||||
endif ()
|
||||
|
@ -1,8 +1,8 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
|
||||
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
|
||||
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
|
||||
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
|
||||
|
||||
set(CMAKE_SIZE "arm-none-eabi-size" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJCOPY "arm-none-eabi-objcopy" CACHE FILEPATH "")
|
||||
@ -29,13 +29,13 @@ list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
set(TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
-Wl,--print-memory-usage
|
||||
-Wl,--gc-sections
|
||||
-Wl,--cref
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_WARNING_FLAGS
|
||||
set(TOOLCHAIN_WARNING_FLAGS
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
@ -62,3 +62,11 @@ list(APPEND TOOLCHAIN_WARNING_FLAGS
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
|
||||
|
||||
# try_compile is cmake test compiling its own example,
|
||||
# pass -nostdlib to skip stdlib linking
|
||||
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||
if (IS_IN_TRY_COMPILE)
|
||||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
|
||||
endif ()
|
||||
|
34
tools/cmake/toolchain/arm_iar.cmake
Normal file
34
tools/cmake/toolchain/arm_iar.cmake
Normal file
@ -0,0 +1,34 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER "iccarm")
|
||||
set(CMAKE_CXX_COMPILER "iccarm")
|
||||
set(CMAKE_ASM_COMPILER "iasmarm")
|
||||
|
||||
set(CMAKE_SIZE "size" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJCOPY "ielftool" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJDUMP "iefdumparm" CACHE FILEPATH "")
|
||||
|
||||
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
|
||||
|
||||
# Look for includes and libraries only in the target system prefix.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# pass TOOLCHAIN_CPU to
|
||||
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
|
||||
|
||||
# enable all possible warnings for building examples
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_WARNING_FLAGS
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
|
@ -1,9 +1,10 @@
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
# join the toolchain flags into a single string
|
||||
list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
|
||||
|
||||
foreach (LANG IN ITEMS C CXX ASM)
|
||||
# join the toolchain flags into a single string
|
||||
list(APPEND TOOLCHAIN_${LANG}_FLAGS ${TOOLCHAIN_COMMON_FLAGS})
|
||||
list(JOIN TOOLCHAIN_${LANG}_FLAGS " " TOOLCHAIN_${LANG}_FLAGS)
|
||||
set(CMAKE_${LANG}_FLAGS_INIT "${TOOLCHAIN_${LANG}_FLAGS}")
|
||||
set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS})
|
||||
|
||||
#cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT)
|
||||
|
||||
@ -14,11 +15,3 @@ endforeach ()
|
||||
|
||||
# Linker
|
||||
list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
|
||||
|
||||
# try_compile is cmake test compiling its own example,
|
||||
# pass -nostdlib to skip stdlib linking
|
||||
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||
if (IS_IN_TRY_COMPILE)
|
||||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
|
||||
endif ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user