110 lines
3.4 KiB
CMake
110 lines
3.4 KiB
CMake
include_guard()
|
|
|
|
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
|
|
set(CMSIS_5 ${TOP}/lib/CMSIS_5)
|
|
|
|
# include board specific
|
|
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
|
|
|
# toolchain set up
|
|
set(CMAKE_SYSTEM_CPU cortex-m33-nodsp-nofp CACHE INTERNAL "System Processor")
|
|
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
|
|
|
set(FAMILY_MCUS RW61X CACHE INTERNAL "")
|
|
|
|
#------------------------------------
|
|
# Startup & Linker script
|
|
#------------------------------------
|
|
|
|
set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
|
|
set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
|
|
|
|
#------------------------------------
|
|
# BOARD_TARGET
|
|
#------------------------------------
|
|
function(family_add_board BOARD_TARGET)
|
|
add_library(${BOARD_TARGET} STATIC
|
|
${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_CORE}.c
|
|
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
|
|
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_reset.c
|
|
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_power.c
|
|
${SDK_DIR}/drivers/lpc_gpio/fsl_gpio.c
|
|
${SDK_DIR}/drivers/common/fsl_common_arm.c
|
|
${SDK_DIR}/drivers/flexcomm/fsl_flexcomm.c
|
|
${SDK_DIR}/drivers/flexcomm/usart/fsl_usart.c
|
|
${SDK_DIR}/drivers/flexspi/fsl_flexspi.c
|
|
)
|
|
|
|
target_include_directories(${BOARD_TARGET} PUBLIC
|
|
${CMSIS_5}/CMSIS/Core/Include
|
|
${SDK_DIR}/devices/${MCU_VARIANT}
|
|
${SDK_DIR}/devices/${MCU_VARIANT}/drivers
|
|
${SDK_DIR}/drivers
|
|
${SDK_DIR}/drivers/common
|
|
${SDK_DIR}/drivers/lpc_gpio
|
|
${SDK_DIR}/drivers/flexcomm
|
|
${SDK_DIR}/drivers/flexcomm/usart
|
|
${SDK_DIR}/drivers/flexspi
|
|
)
|
|
|
|
update_board(${BOARD_TARGET})
|
|
endfunction()
|
|
|
|
#------------------------------------
|
|
# Functions
|
|
#------------------------------------
|
|
function(family_configure_example TARGET RTOS)
|
|
family_configure_common(${TARGET} ${RTOS})
|
|
family_add_tinyusb(${TARGET} OPT_MCU_RW61X)
|
|
|
|
target_sources(${TARGET} PUBLIC
|
|
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
|
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
|
|
|
# ChipIdea HS
|
|
${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
|
|
${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
|
|
${TOP}/src/portable/ehci/ehci.c
|
|
|
|
# Startup File
|
|
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
|
)
|
|
|
|
# Add Board specific includes
|
|
target_include_directories(${TARGET} PUBLIC
|
|
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
|
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
|
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
|
)
|
|
|
|
# Linker Options
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
target_link_options(${TARGET} PUBLIC
|
|
"LINKER:--script=${LD_FILE_GNU}"
|
|
--specs=nosys.specs --specs=nano.specs
|
|
)
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
target_link_options(${TARGET} PUBLIC
|
|
"LINKER:--script=${LD_FILE_Clang}"
|
|
)
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
|
target_link_options(${TARGET} PUBLIC
|
|
"LINKER:--config=${LD_FILE_IAR}"
|
|
)
|
|
endif ()
|
|
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
|
|
endif ()
|
|
|
|
# Handle Startup File Properties (Linting/Warnings)
|
|
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
|
|
SKIP_LINTING ON
|
|
COMPILE_OPTIONS -w
|
|
)
|
|
|
|
# Flashing & Binary Generation
|
|
family_add_bin_hex(${TARGET})
|
|
family_flash_jlink(${TARGET})
|
|
endfunction()
|