mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-16 06:40:11 +00:00
example run well with cmake for imxrt
This commit is contained in:
parent
2ac289685a
commit
0afe1b3684
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||
|
||||
@ -27,37 +27,6 @@ target_include_directories(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
if(FAMILY STREQUAL "rp2040")
|
||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||
# in hw/bsp/FAMILY/family.cmake for details.
|
||||
family_configure_device_example(${PROJECT})
|
||||
else ()
|
||||
# TOP is absolute path to root directory of TinyUSB git repo
|
||||
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..")
|
||||
get_filename_component(TOP "${TOP}" REALPATH)
|
||||
|
||||
# re-include family.cmake
|
||||
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${TOP}/src/device/usbd.c
|
||||
${TOP}/src/device/usbd_control.c
|
||||
${TOP}/src/class/audio/audio_device.c
|
||||
${TOP}/src/class/cdc/cdc_device.c
|
||||
${TOP}/src/class/dfu/dfu_device.c
|
||||
${TOP}/src/class/dfu/dfu_rt_device.c
|
||||
${TOP}/src/class/hid/hid_device.c
|
||||
${TOP}/src/class/midi/midi_device.c
|
||||
${TOP}/src/class/msc/msc_device.c
|
||||
${TOP}/src/class/net/ecm_rndis_device.c
|
||||
${TOP}/src/class/net/ncm_device.c
|
||||
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||
${TOP}/src/class/vendor/vendor_device.c
|
||||
${TOP}/src/class/video/video_device.c
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${TOP}/hw
|
||||
${TOP}/src
|
||||
)
|
||||
endif ()
|
||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||
# in hw/bsp/FAMILY/family.cmake for details.
|
||||
family_configure_device_example(${PROJECT})
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||
|
||||
|
@ -1,28 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||
|
||||
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
||||
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
project(${PROJECT})
|
||||
project(${PROJECT} C CXX ASM)
|
||||
|
||||
# Checks this example is valid for the family and initializes the project
|
||||
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Espressif has its own cmake build system
|
||||
if(FAMILY STREQUAL "espressif")
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT})
|
||||
|
||||
# Example source
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk_dual.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk_dual.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
|
||||
)
|
||||
|
||||
# Example include
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||
# in hw/bsp/FAMILY/family.cmake for details.
|
||||
|
@ -1,23 +1,27 @@
|
||||
# toolchain set up
|
||||
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../../cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
||||
|
||||
|
||||
if (NOT TARGET ${PROJECT})
|
||||
# toolchain set up, include before project()
|
||||
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
||||
else ()
|
||||
function(family_configure_target TARGET)
|
||||
if (NOT BOARD)
|
||||
message(FATAL_ERROR "BOARD not specified")
|
||||
endif ()
|
||||
|
||||
# set output name to .elf
|
||||
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
|
||||
|
||||
# TOP is absolute path to root directory of TinyUSB git repo
|
||||
set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
|
||||
get_filename_component(TOP "${TOP}" REALPATH)
|
||||
|
||||
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
|
||||
set(DEPS_SUBMODULES ${SDK_DIR})
|
||||
|
||||
# include basic family CMake functionality
|
||||
#set(FAMILY_MCUS RP2040)
|
||||
include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
cmake_print_variables(TOP CMAKE_CURRENT_FUNCTION_LIST_DIR)
|
||||
|
||||
target_compile_definitions(${PROJECT} PUBLIC
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
CFG_TUSB_MCU=OPT_MCU_MIMXRT
|
||||
__ARMVFP__=0
|
||||
__ARMFPV5__=0
|
||||
@ -25,18 +29,18 @@ else ()
|
||||
XIP_BOOT_HEADER_ENABLE=1
|
||||
)
|
||||
|
||||
target_link_options(${PROJECT} PUBLIC
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
--specs=nosys.specs
|
||||
--specs=nano.specs
|
||||
)
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# TinyUSB
|
||||
${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
|
||||
# BSP
|
||||
${CMAKE_CURRENT_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${SDK_DIR}/drivers/common/fsl_common.c
|
||||
${SDK_DIR}/drivers/igpio/fsl_gpio.c
|
||||
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
|
||||
@ -47,18 +51,19 @@ else ()
|
||||
)
|
||||
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
target_sources(${TARGET} PUBLIC
|
||||
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
|
||||
)
|
||||
|
||||
target_link_options(${PROJECT} PUBLIC
|
||||
target_link_options(${TARGET} PUBLIC
|
||||
"LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld"
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
${SDK_DIR}/CMSIS/Include
|
||||
${SDK_DIR}/devices/${MCU_VARIANT}
|
||||
${SDK_DIR}/devices/${MCU_VARIANT}/project_template
|
||||
@ -67,4 +72,11 @@ else ()
|
||||
${SDK_DIR}/drivers/igpio
|
||||
${SDK_DIR}/drivers/lpuart
|
||||
)
|
||||
endif ()
|
||||
|
||||
# include tinyusb cmake
|
||||
include(${TOP}/src/CMakeLists.txt)
|
||||
endfunction()
|
||||
|
||||
function(family_configure_device_example TARGET)
|
||||
family_configure_target(${TARGET})
|
||||
endfunction()
|
||||
|
25
src/CMakeLists.txt
Normal file
25
src/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
# cmake_minimum_required(VERSION 3.17)
|
||||
# TODO make tinyusb as library that depends on 'tusb_config' interface that exposes the tusb_config.h file
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}/tusb.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/common/tusb_fifo.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/device/usbd.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/device/usbd_control.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/audio/audio_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/cdc/cdc_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/dfu/dfu_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/dfu/dfu_rt_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/hid/hid_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/midi/midi_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/msc/msc_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/net/ecm_rndis_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/net/ncm_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/usbtmc/usbtmc_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/vendor/vendor_device.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/class/video/video_device.c
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user