Skip to content

Commit fab48e5

Browse files
committed
adding cmake build for imxrt1010
1 parent 9771c76 commit fab48e5

File tree

9 files changed

+172
-6
lines changed

9 files changed

+172
-6
lines changed

.idea/cmake.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/msc_dual_lun.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmake/cpu/cortex-m7.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
set(TOOLCHAIN_COMMON_FLAGS
2+
-mthumb
3+
-mcpu=cortex-m7
4+
-mfloat-abi=hard
5+
-mfpu=fpv5-d16
6+
)

cmake/toolchain/arm_gcc.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
set(CMAKE_SYSTEM_NAME Generic)
2+
3+
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
4+
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
5+
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
6+
set(GCC_ELF2BIN "arm-none-eabi-objcopy")
7+
set_property(GLOBAL PROPERTY ELF2BIN ${GCC_ELF2BIN})
8+
9+
# Look for includes and libraries only in the target system prefix.
10+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
11+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
13+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
14+
15+
# pass TOOLCHAIN_CPU to
16+
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
17+
18+
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
19+
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

cmake/toolchain/set_flags.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
2+
3+
# join the toolchain flags into a single string
4+
list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
5+
6+
foreach(LANG IN ITEMS C CXX ASM)
7+
set(CMAKE_${LANG}_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS}")
8+
if (PICO_DEOPTIMIZED_DEBUG)
9+
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
10+
else()
11+
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
12+
endif()
13+
set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none")
14+
15+
# try_compile is where the feature testing is done, and at that point,
16+
# pico_standard_link is not ready to be linked in to provide essential
17+
# functions like _exit. So pass -nostdlib so it doesn't link in an exit()
18+
# function at all.
19+
if(IS_IN_TRY_COMPILE)
20+
set(CMAKE_${LANG}_LINK_FLAGS "${CMAKE_${LANG}_LINK_FLAGS} -nostdlib")
21+
endif()
22+
endforeach()

examples/device/board_test/CMakeLists.txt

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.13)
2+
include(CMakePrintHelpers)
3+
4+
# default toolchain is gcc
5+
if (NOT TOOLCHAIN)
6+
set(TOOLCHAIN "gcc")
7+
endif ()
28

39
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
410

@@ -24,7 +30,40 @@ if(NOT FAMILY STREQUAL "espressif")
2430
${CMAKE_CURRENT_SOURCE_DIR}/src
2531
)
2632

27-
# Configure compilation flags and libraries for the example... see the corresponding function
28-
# in hw/bsp/FAMILY/family.cmake for details.
29-
family_configure_device_example(${PROJECT})
33+
if(FAMILY STREQUAL "rp2040")
34+
# Configure compilation flags and libraries for the example... see the corresponding function
35+
# in hw/bsp/FAMILY/family.cmake for details.
36+
family_configure_device_example(${PROJECT})
37+
else ()
38+
# TOP is absolute path to root directory of TinyUSB git repo
39+
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..")
40+
get_filename_component(TOP "${TOP}" REALPATH)
41+
42+
# re-include family.cmake
43+
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
44+
45+
target_sources(${PROJECT} PUBLIC
46+
${TOP}/src/device/usbd.c
47+
${TOP}/src/device/usbd_control.c
48+
${TOP}/src/class/audio/audio_device.c
49+
${TOP}/src/class/cdc/cdc_device.c
50+
${TOP}/src/class/dfu/dfu_device.c
51+
${TOP}/src/class/dfu/dfu_rt_device.c
52+
${TOP}/src/class/hid/hid_device.c
53+
${TOP}/src/class/midi/midi_device.c
54+
${TOP}/src/class/msc/msc_device.c
55+
${TOP}/src/class/net/ecm_rndis_device.c
56+
${TOP}/src/class/net/ncm_device.c
57+
${TOP}/src/class/usbtmc/usbtmc_device.c
58+
${TOP}/src/class/vendor/vendor_device.c
59+
${TOP}/src/class/video/video_device.c
60+
)
61+
62+
target_include_directories(${PROJECT} PUBLIC
63+
${TOP}/hw
64+
${TOP}/src
65+
)
66+
67+
68+
endif ()
3069
endif()

examples/device/cdc_msc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.13)
22

33
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
44

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set(MCU_VARIANT MIMXRT1011)
2+
3+
target_sources(${PROJECT} PUBLIC
4+
${CMAKE_CURRENT_LIST_DIR}/evkmimxrt1010_flexspi_nor_config.c
5+
)
6+
7+
target_compile_definitions(${PROJECT} PUBLIC
8+
CPU_MIMXRT1011DAE5A
9+
CFG_EXAMPLE_VIDEO_READONLY
10+
)

hw/bsp/imxrt/family.cmake

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# toolchain set up, include before project()
2+
if (NOT TARGET ${PROJECT})
3+
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
4+
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../cmake/toolchain/arm_${TOOLCHAIN}.cmake)
5+
else ()
6+
if (NOT BOARD)
7+
message(FATAL_ERROR "BOARD not specified")
8+
endif ()
9+
10+
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
11+
set(DEPS_SUBMODULES ${SDK_DIR})
12+
13+
# include basic family CMake functionality
14+
#set(FAMILY_MCUS RP2040)
15+
16+
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
17+
18+
target_compile_definitions(${PROJECT} PUBLIC
19+
CFG_TUSB_MCU=OPT_MCU_MIMXRT
20+
__ARMVFP__=0
21+
__ARMFPV5__=0
22+
XIP_EXTERNAL_FLASH=1
23+
XIP_BOOT_HEADER_ENABLE=1
24+
)
25+
26+
target_link_options(${PROJECT} PUBLIC
27+
--specs=nosys.specs
28+
--specs=nano.specs
29+
#-lgcc -lm -lnosys
30+
)
31+
32+
# target_link_libraries(${PROJECT} PUBLIC
33+
# -lgcc -lm -lnosys
34+
# )
35+
36+
target_sources(${PROJECT} PUBLIC
37+
# TinyUSB
38+
${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
39+
${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
40+
${TOP}/src/portable/ehci/ehci.c
41+
# BSP
42+
${CMAKE_CURRENT_LIST_DIR}/family.c
43+
${SDK_DIR}/drivers/common/fsl_common.c
44+
${SDK_DIR}/drivers/igpio/fsl_gpio.c
45+
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
46+
${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT}.c
47+
${SDK_DIR}/devices/${MCU_VARIANT}/xip/fsl_flexspi_nor_boot.c
48+
${SDK_DIR}/devices/${MCU_VARIANT}/project_template/clock_config.c
49+
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
50+
)
51+
52+
if (TOOLCHAIN STREQUAL "gcc")
53+
target_sources(${PROJECT} PUBLIC
54+
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
55+
)
56+
endif ()
57+
58+
target_include_directories(${PROJECT} PUBLIC
59+
${CMAKE_CURRENT_LIST_DIR}
60+
${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}
61+
${SDK_DIR}/CMSIS/Include
62+
${SDK_DIR}/devices/${MCU_VARIANT}
63+
${SDK_DIR}/devices/${MCU_VARIANT}/project_template
64+
${SDK_DIR}/devices/${MCU_VARIANT}/drivers
65+
${SDK_DIR}/drivers/common
66+
${SDK_DIR}/drivers/igpio
67+
${SDK_DIR}/drivers/lpuart
68+
)
69+
endif ()

0 commit comments

Comments
 (0)