230 lines
8.8 KiB
CMake
230 lines
8.8 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
|
|
project(fire_rt1021_evk_sdsmart)
|
|
|
|
enable_language(CXX)
|
|
enable_language(ASM)
|
|
|
|
# Different linker scripts
|
|
set(TARGET_LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/GCC/app_flash.ld")
|
|
set(TARGET_LDSCRIPT_RAM "${CMAKE_SOURCE_DIR}/SDK/devices/MIMXRT1021/gcc/MIMXRT1021xxxxx_ram.ld")
|
|
|
|
set(TARGET_SOURCES
|
|
"SDK/components/gpio/fsl_adapter_igpio.c"
|
|
"SDK/components/lists/fsl_component_generic_list.c"
|
|
"SDK/components/osa/fsl_os_abstraction_free_rtos.c"
|
|
"SDK/components/serial_manager/fsl_component_serial_manager.c"
|
|
"SDK/components/serial_manager/fsl_component_serial_port_uart.c"
|
|
"SDK/components/uart/fsl_adapter_lpuart.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_adc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_adc_etc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_aipstz.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_aoi.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_bee.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_cache.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_clock.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_cmp.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_common.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_common_arm.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_dcdc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_dcp.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_dmamux.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_enc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_enet.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_ewm.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexcan.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_camera.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_camera_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_i2c_master.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_i2s.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_i2s_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_mculcd.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_mculcd_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_spi.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_spi_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_uart.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexio_uart_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexram.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexram_allocate.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexspi.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_flexspi_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_gpc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_gpio.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_gpt.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_kpp.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_lpi2c.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_lpi2c_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_lpspi.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_lpspi_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_lpuart.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_lpuart_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_ocotp.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_pit.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_pmu.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_pwm.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_qtmr.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_romapi.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_rtwdog.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_sai.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_sai_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_semc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_snvs_hp.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_snvs_lp.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_spdif.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_spdif_edma.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_src.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_tempmon.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_trng.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_usdhc.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_wdog.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_xbara.c"
|
|
"SDK/devices/MIMXRT1021/drivers/fsl_xbarb.c"
|
|
"SDK/devices/MIMXRT1021/gcc/startup_MIMXRT1021.S"
|
|
"SDK/devices/MIMXRT1021/system_MIMXRT1021.c"
|
|
"SDK/devices/MIMXRT1021/utilities/debug_console/fsl_debug_console.c"
|
|
"SDK/devices/MIMXRT1021/utilities/fsl_assert.c"
|
|
"SDK/devices/MIMXRT1021/utilities/fsl_notifier.c"
|
|
"SDK/devices/MIMXRT1021/utilities/str/fsl_str.c"
|
|
"SDK/devices/MIMXRT1021/xip/fsl_flexspi_nor_boot.c"
|
|
"SDK/middleware/sdmmc/common/fsl_sdmmc_common.c"
|
|
"SDK/middleware/sdmmc/host/usdhc/non_blocking/fsl_sdmmc_host.c"
|
|
"SDK/middleware/sdmmc/osa/fsl_sdmmc_osa.c"
|
|
"SDK/middleware/sdmmc/sd/fsl_sd.c"
|
|
"board/board.c"
|
|
"board/clock_config.c"
|
|
"board/dcd.c"
|
|
"board/peripherals.c"
|
|
"board/pin_mux.c"
|
|
"board/sdmmc_config.c"
|
|
"src/app_sdmmc.c"
|
|
"src/main.c"
|
|
"xip/fire_rt1021_evk_flexspi_nor_config.c"
|
|
)
|
|
|
|
set(TARGET_C_DEFINES
|
|
"CPU_MIMXRT1021DAG5A"
|
|
"MCUXPRESSO_SDK"
|
|
"SD_ENABLED"
|
|
"SDK_OS_FREE_RTOS"
|
|
"SERIAL_PORT_TYPE_UART"
|
|
"__STARTUP_CLEAR_BSS"
|
|
"__STARTUP_INITIALIZE_NONCACHEDATA"
|
|
)
|
|
|
|
set(TARGET_C_DEFINES_XIP
|
|
"SKIP_SYSCLK_INIT"
|
|
"XIP_BOOT_HEADER_ENABLE=1"
|
|
"XIP_BOOT_HEADER_DCD_ENABLE=1"
|
|
"XIP_EXTERNAL_FLASH=1"
|
|
)
|
|
|
|
set(TARGET_C_INCLUDES
|
|
"SDK/CMSIS/Core/Include"
|
|
"SDK/components/gpio"
|
|
"SDK/components/lists"
|
|
"SDK/components/osa"
|
|
"SDK/components/serial_manager"
|
|
"SDK/components/uart"
|
|
"SDK/devices/MIMXRT1021"
|
|
"SDK/devices/MIMXRT1021/drivers"
|
|
"SDK/devices/MIMXRT1021/utilities"
|
|
"SDK/devices/MIMXRT1021/utilities/debug_console"
|
|
"SDK/devices/MIMXRT1021/utilities/str"
|
|
"SDK/middleware/sdmmc/common"
|
|
"SDK/middleware/sdmmc/host/usdhc"
|
|
"SDK/middleware/sdmmc/osa"
|
|
"SDK/middleware/sdmmc/sd"
|
|
"board"
|
|
"include"
|
|
)
|
|
|
|
# Shared libraries linked with application
|
|
set(TARGET_LIBS
|
|
"c"
|
|
"m"
|
|
"nosys"
|
|
"freertos_kernel"
|
|
)
|
|
|
|
# Shared library and linker script search paths
|
|
set(TARGET_LIB_DIRECTORIES
|
|
|
|
)
|
|
|
|
# Conditional flags
|
|
# DEBUG
|
|
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
|
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
|
|
|
# RELEASE
|
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
|
set(CMAKE_ASM_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto")
|
|
|
|
# Final compiler flags
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp")
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
|
|
|
# Subdirectories
|
|
set(FREERTOS_PORT "GCC_ARM_CM7" CACHE STRING "")
|
|
add_library(freertos_config INTERFACE)
|
|
target_include_directories(freertos_config SYSTEM INTERFACE include)
|
|
add_subdirectory(lib/freertos)
|
|
|
|
# Shared sources, includes and definitions
|
|
add_compile_definitions(${TARGET_C_DEFINES})
|
|
include_directories(${TARGET_C_INCLUDES})
|
|
link_directories(${TARGET_LIB_DIRECTORIES})
|
|
link_libraries(${TARGET_LIBS})
|
|
|
|
# Main targets are added here
|
|
|
|
# Create ELF
|
|
add_executable("${CMAKE_PROJECT_NAME}_FLASH.elf" ${TARGET_SOURCES})
|
|
target_compile_definitions("${CMAKE_PROJECT_NAME}_FLASH.elf"
|
|
PRIVATE ${TARGET_C_DEFINES_XIP}
|
|
)
|
|
target_link_options("${CMAKE_PROJECT_NAME}_FLASH.elf"
|
|
PRIVATE "-T${TARGET_LDSCRIPT_FLASH}"
|
|
PRIVATE "-Wl,--Map=${CMAKE_PROJECT_NAME}_FLASH.map"
|
|
)
|
|
set_property(TARGET "${CMAKE_PROJECT_NAME}_FLASH.elf" APPEND
|
|
PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}_FLASH.map"
|
|
)
|
|
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_FLASH.hex"
|
|
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_FLASH.elf" "${CMAKE_PROJECT_NAME}_FLASH.hex"
|
|
DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.elf"
|
|
)
|
|
add_custom_target("${CMAKE_PROJECT_NAME}_FLASH_HEX" DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.hex")
|
|
if(DEFINED TARGET_TOOLCHAIN_SIZE)
|
|
add_custom_command(TARGET "${CMAKE_PROJECT_NAME}_FLASH.elf" POST_BUILD
|
|
COMMAND ${TARGET_TOOLCHAIN_SIZE} "${CMAKE_PROJECT_NAME}_FLASH.elf"
|
|
)
|
|
endif()
|
|
|
|
# Create ELF
|
|
add_executable("${CMAKE_PROJECT_NAME}_RAM.elf" ${TARGET_SOURCES})
|
|
target_link_options("${CMAKE_PROJECT_NAME}_RAM.elf"
|
|
PRIVATE "-T${TARGET_LDSCRIPT_RAM}"
|
|
PRIVATE "-Wl,--Map=${CMAKE_PROJECT_NAME}_RAM.map"
|
|
)
|
|
set_property(TARGET "${CMAKE_PROJECT_NAME}_RAM.elf" APPEND
|
|
PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}_RAM.map"
|
|
)
|
|
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_RAM.hex"
|
|
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_RAM.elf" "${CMAKE_PROJECT_NAME}_RAM.hex"
|
|
DEPENDS "${CMAKE_PROJECT_NAME}_RAM.elf"
|
|
)
|
|
add_custom_target("${CMAKE_PROJECT_NAME}_RAM_HEX" DEPENDS "${CMAKE_PROJECT_NAME}_RAM.hex")
|
|
if(DEFINED TARGET_TOOLCHAIN_SIZE)
|
|
add_custom_command(TARGET "${CMAKE_PROJECT_NAME}_RAM.elf" POST_BUILD
|
|
COMMAND ${TARGET_TOOLCHAIN_SIZE} "${CMAKE_PROJECT_NAME}_RAM.elf"
|
|
)
|
|
endif()
|