cmake_minimum_required(VERSION 3.10) project(lq_rt1052_va1_template) enable_language(CXX) enable_language(ASM) # Different linker scripts set(TARGET_LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/SDK/devices/MIMXRT1052/gcc/MIMXRT1052xxxxx_flexspi_nor.ld") set(TARGET_LDSCRIPT_RAM "${CMAKE_SOURCE_DIR}/SDK/devices/MIMXRT1052/gcc/MIMXRT1052xxxxx_ram.ld") set(TARGET_SOURCES "SDK/components/lists/fsl_component_generic_list.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/MIMXRT1052/drivers/fsl_adc.c" "SDK/devices/MIMXRT1052/drivers/fsl_adc_etc.c" "SDK/devices/MIMXRT1052/drivers/fsl_aipstz.c" "SDK/devices/MIMXRT1052/drivers/fsl_aoi.c" "SDK/devices/MIMXRT1052/drivers/fsl_bee.c" "SDK/devices/MIMXRT1052/drivers/fsl_cache.c" "SDK/devices/MIMXRT1052/drivers/fsl_clock.c" "SDK/devices/MIMXRT1052/drivers/fsl_cmp.c" "SDK/devices/MIMXRT1052/drivers/fsl_common.c" "SDK/devices/MIMXRT1052/drivers/fsl_common_arm.c" "SDK/devices/MIMXRT1052/drivers/fsl_csi.c" "SDK/devices/MIMXRT1052/drivers/fsl_dcdc.c" "SDK/devices/MIMXRT1052/drivers/fsl_dcp.c" "SDK/devices/MIMXRT1052/drivers/fsl_dmamux.c" "SDK/devices/MIMXRT1052/drivers/fsl_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_elcdif.c" "SDK/devices/MIMXRT1052/drivers/fsl_enc.c" "SDK/devices/MIMXRT1052/drivers/fsl_enet.c" "SDK/devices/MIMXRT1052/drivers/fsl_ewm.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexcan.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_camera.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_camera_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_i2c_master.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_i2s.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_i2s_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_mculcd.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_mculcd_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_spi.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_spi_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_uart.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexio_uart_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexram.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexram_allocate.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexspi.c" "SDK/devices/MIMXRT1052/drivers/fsl_flexspi_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_gpc.c" "SDK/devices/MIMXRT1052/drivers/fsl_gpio.c" "SDK/devices/MIMXRT1052/drivers/fsl_gpt.c" "SDK/devices/MIMXRT1052/drivers/fsl_kpp.c" "SDK/devices/MIMXRT1052/drivers/fsl_lpi2c.c" "SDK/devices/MIMXRT1052/drivers/fsl_lpi2c_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_lpspi.c" "SDK/devices/MIMXRT1052/drivers/fsl_lpspi_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_lpuart.c" "SDK/devices/MIMXRT1052/drivers/fsl_lpuart_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_ocotp.c" "SDK/devices/MIMXRT1052/drivers/fsl_pit.c" "SDK/devices/MIMXRT1052/drivers/fsl_pmu.c" "SDK/devices/MIMXRT1052/drivers/fsl_pwm.c" "SDK/devices/MIMXRT1052/drivers/fsl_pxp.c" "SDK/devices/MIMXRT1052/drivers/fsl_qtmr.c" "SDK/devices/MIMXRT1052/drivers/fsl_romapi.c" "SDK/devices/MIMXRT1052/drivers/fsl_rtwdog.c" "SDK/devices/MIMXRT1052/drivers/fsl_sai.c" "SDK/devices/MIMXRT1052/drivers/fsl_sai_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_semc.c" "SDK/devices/MIMXRT1052/drivers/fsl_snvs_hp.c" "SDK/devices/MIMXRT1052/drivers/fsl_snvs_lp.c" "SDK/devices/MIMXRT1052/drivers/fsl_spdif.c" "SDK/devices/MIMXRT1052/drivers/fsl_spdif_edma.c" "SDK/devices/MIMXRT1052/drivers/fsl_src.c" "SDK/devices/MIMXRT1052/drivers/fsl_tempmon.c" "SDK/devices/MIMXRT1052/drivers/fsl_trng.c" "SDK/devices/MIMXRT1052/drivers/fsl_tsc.c" "SDK/devices/MIMXRT1052/drivers/fsl_usdhc.c" "SDK/devices/MIMXRT1052/drivers/fsl_wdog.c" "SDK/devices/MIMXRT1052/drivers/fsl_xbara.c" "SDK/devices/MIMXRT1052/drivers/fsl_xbarb.c" "SDK/devices/MIMXRT1052/gcc/startup_MIMXRT1052.S" "SDK/devices/MIMXRT1052/system_MIMXRT1052.c" "SDK/devices/MIMXRT1052/utilities/debug_console/fsl_debug_console.c" "SDK/devices/MIMXRT1052/utilities/fsl_assert.c" "SDK/devices/MIMXRT1052/utilities/fsl_notifier.c" "SDK/devices/MIMXRT1052/utilities/fsl_sbrk.c" "SDK/devices/MIMXRT1052/utilities/str/fsl_str.c" "SDK/devices/MIMXRT1052/xip/fsl_flexspi_nor_boot.c" "board/board.c" "board/clock_config.c" "board/dcd.c" "board/peripherals.c" "board/pin_mux.c" "src/freertos_helpers.c" "src/main.c" "xip/lq_va1_flexspi_nor_config.c" ) set(TARGET_C_DEFINES "CPU_MIMXRT1052DVL6B" "DEBUG_CONSOLE_TRANSFER_NON_BLOCKING" "MCUXPRESSO_SDK" "SDK_OS_FREE_RTOS" "SERIAL_PORT_TYPE_UART" "__STARTUP_CLEAR_BSS" "__STARTUP_INITIALIZE_NONCACHEDATA" ) set(TARGET_C_DEFINES_XIP "XIP_BOOT_HEADER_ENABLE=1" "XIP_EXTERNAL_FLASH=1" ) set(TARGET_C_INCLUDES "SDK/CMSIS/Core/Include" "SDK/components/lists" "SDK/components/serial_manager" "SDK/components/uart" "SDK/devices/MIMXRT1052" "SDK/devices/MIMXRT1052/drivers" "SDK/devices/MIMXRT1052/utilities" "SDK/devices/MIMXRT1052/utilities/debug_console" "SDK/devices/MIMXRT1052/utilities/str" "board" "include" ) # Shared libraries linked with application set(TARGET_LIBS "freertos_kernel" ) # Shared library and linker script search paths set(TARGET_LIB_DIRECTORIES ) # Device specific settings, goes to CFLAGS and LDFLAGS set(TARGET_CFLAGS_HARDWARE "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard") # 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} ${TARGET_CFLAGS_HARDWARE} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_CFLAGS_HARDWARE} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${CMAKE_C_FLAGS} -x assembler-with-cpp") set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -Wl,--print-memory-usage -lc -lm -lnosys ") # Add subdirectories here. set(FREERTOS_CONFIG_FILE_DIRECTORY "${CMAKE_SOURCE_DIR}/include" CACHE STRING "") set(FREERTOS_PORT "GCC_ARM_CM7" CACHE STRING "") 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}" ) 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") # Create ELF add_executable("${CMAKE_PROJECT_NAME}_RAM.elf" ${TARGET_SOURCES}) target_link_options("${CMAKE_PROJECT_NAME}_RAM.elf" PRIVATE "-T${TARGET_LDSCRIPT_RAM}" ) 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")