2021-07-12 21:50:48 +02:00
|
|
|
################################################################################
|
|
|
|
# CMake support for the Flight Software Framework
|
|
|
|
# Author: R. Mueller
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Pre-Project preparation
|
|
|
|
################################################################################
|
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
|
|
# set(CMAKE_VERBOSE TRUE)
|
|
|
|
|
|
|
|
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2021-07-12 22:11:03 +02:00
|
|
|
set(STM32_CMAKE_PATH "${CMAKE_SCRIPT_PATH}/stm32-cmake")
|
|
|
|
set(STM32_CUBE_H7_PATH STM32CubeH7)
|
|
|
|
set(STM32_TOOLCHAIN_PATH $ENV{STM32_TOOLCHAIN_PATH})
|
|
|
|
set(TARGET_TRIPLET "arm-none-eabi")
|
2021-07-14 00:55:24 +02:00
|
|
|
set(FSFW_OSAL freertos CACHE STRING "OS for the FSFW")
|
2021-07-13 09:15:56 +02:00
|
|
|
set(STM32_ADD_NETWORKING_CODE ON)
|
2021-07-13 10:23:17 +02:00
|
|
|
set(FSFW_HAL_ADD_STM32H7 ON)
|
2021-07-12 21:50:48 +02:00
|
|
|
|
2021-07-12 22:11:03 +02:00
|
|
|
# This call has to come before the project call
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE ${STM32_CMAKE_PATH}/cmake/stm32_gcc.cmake)
|
2021-07-12 21:50:48 +02:00
|
|
|
# Project Name
|
2021-07-12 21:54:04 +02:00
|
|
|
project(fsfw-example-stm32h7-freertos ASM C CXX)
|
2021-07-12 21:50:48 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Pre-Sources preparation
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Specify the C++ standard
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
|
2021-07-12 22:11:03 +02:00
|
|
|
|
2021-10-27 17:09:41 +02:00
|
|
|
set(FSFW_OSAL "freertos")
|
2021-07-12 23:33:05 +02:00
|
|
|
set(TGT_BSP "arm/stm32h743zi-nucleo")
|
2021-07-12 22:11:03 +02:00
|
|
|
set(FREERTOS_NAMESPACE FreeRTOS::STM32::H7::M7)
|
|
|
|
|
2021-07-12 21:50:48 +02:00
|
|
|
# Set names and variables
|
|
|
|
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
|
|
|
|
set(LIB_FSFW_NAME fsfw)
|
|
|
|
|
|
|
|
# Set path names
|
|
|
|
set(FSFW_PATH fsfw)
|
|
|
|
set(COMMON_PATH example_common)
|
|
|
|
|
2021-07-12 21:54:04 +02:00
|
|
|
set(BSP_PATH "bsp_stm32h7_freertos")
|
2021-07-12 21:50:48 +02:00
|
|
|
set(COMMON_CONFIG_PATH "${COMMON_PATH}/config")
|
|
|
|
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
|
2021-07-12 23:33:05 +02:00
|
|
|
set(BSP_NUCLEO_PATH "${BSP_PATH}/NUCLEO-H743ZI")
|
2021-07-13 10:23:17 +02:00
|
|
|
set(BSP_NUCLEO_INC_PATH "${BSP_NUCLEO_PATH}/Inc")
|
|
|
|
|
2021-07-13 11:04:31 +02:00
|
|
|
# See stm32-cmake documentation for more information
|
|
|
|
find_package(CMSIS COMPONENTS STM32H743ZI STM32H7_M7 RTOS REQUIRED)
|
|
|
|
find_package(FreeRTOS COMPONENTS STM32H7 ARM_CM7 REQUIRED)
|
|
|
|
find_package(HAL COMPONENTS STM32H7M7 STM32H743ZI RCC GPIO UART TIM CORTEX ETH SPI DMA REQUIRED)
|
|
|
|
find_package(LwIP REQUIRED)
|
2021-07-12 23:33:05 +02:00
|
|
|
|
2021-07-13 11:04:31 +02:00
|
|
|
# These need to be set for the FSFW so the sources are compiled with the ABI flags
|
|
|
|
# and to compile FreeRTOS first
|
|
|
|
set(LIB_OS_NAME ${FREERTOS_NAMESPACE}::ARM_CM7)
|
|
|
|
# This target is used because a custom linker script is used
|
|
|
|
set(CMSIS_LINK_TARGET CMSIS::STM32::H743xx::M7)
|
|
|
|
set(FSFW_ADDITIONAL_LINK_LIBS ${CMSIS_LINK_TARGET})
|
|
|
|
set(FSFW_HAL_LINK_LIBS
|
|
|
|
HAL::STM32::H7::M7::CORTEX
|
|
|
|
${CMSIS_LINK_TARGET}
|
|
|
|
${LIB_OS_NAME}
|
|
|
|
)
|
|
|
|
set(FSFW_HAL_ADDITIONAL_INC_PATHS ${BSP_NUCLEO_INC_PATH})
|
2021-07-12 21:50:48 +02:00
|
|
|
set(FSFW_ADDITIONAL_INC_PATHS
|
|
|
|
"${COMMON_CONFIG_PATH}"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
CACHE STRING
|
|
|
|
"FSFW configuration paths"
|
|
|
|
)
|
|
|
|
|
|
|
|
configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h)
|
|
|
|
configure_file(${FSFW_CONFIG_PATH}/FSFWConfig.h.in FSFWConfig.h)
|
|
|
|
configure_file(${FSFW_CONFIG_PATH}/OBSWConfig.h.in OBSWConfig.h)
|
2021-07-12 23:33:05 +02:00
|
|
|
configure_file(${BSP_NUCLEO_PATH}/Inc/FreeRTOSConfig.h.in FreeRTOSConfig.h)
|
|
|
|
configure_file(${BSP_NUCLEO_PATH}/Inc/lwipopts.h.in lwipopts.h)
|
2021-07-12 21:50:48 +02:00
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(WARNING_FLAGS
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wimplicit-fallthrough=1
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-psabi
|
|
|
|
)
|
|
|
|
|
|
|
|
set(FSFW_WARNING_FLAGS ${WARNING_FLAGS})
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|
|
|
add_compile_options(/permissive- /d2SSAOptimizer-)
|
|
|
|
# To avoid nameclashes with min and max macro
|
|
|
|
add_compile_definitions(NOMINMAX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Executable and Sources
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Add executable
|
|
|
|
add_executable(${TARGET_NAME})
|
|
|
|
|
|
|
|
# Add subdirectories
|
|
|
|
add_subdirectory(${BSP_PATH})
|
|
|
|
add_subdirectory(${FSFW_PATH})
|
2021-07-15 19:23:43 +02:00
|
|
|
# add_subdirectory(${LIB_FSFW_HAL_PATH})
|
2021-07-12 21:50:48 +02:00
|
|
|
add_subdirectory(${COMMON_PATH})
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Post-Sources preparation
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Add libraries for all sources.
|
|
|
|
target_link_libraries(${TARGET_NAME} PRIVATE
|
2021-07-12 22:11:03 +02:00
|
|
|
${LIB_FSFW_NAME}
|
2021-07-15 19:23:43 +02:00
|
|
|
# ${LIB_FSFW_HAL_NAME}
|
2021-07-12 22:11:03 +02:00
|
|
|
${FREERTOS_NAMESPACE}::Heap::4
|
|
|
|
${FREERTOS_NAMESPACE}::ARM_CM7
|
|
|
|
HAL::STM32::H7::M7::RCC
|
2021-07-12 23:40:26 +02:00
|
|
|
HAL::STM32::H7::M7::RCCEx
|
2021-07-12 22:11:03 +02:00
|
|
|
HAL::STM32::H7::M7::GPIO
|
2021-07-12 23:40:26 +02:00
|
|
|
HAL::STM32::H7::M7::UART
|
2021-07-12 22:11:03 +02:00
|
|
|
HAL::STM32::H7::M7::CORTEX
|
2021-07-12 23:40:26 +02:00
|
|
|
HAL::STM32::H7::M7::TIM
|
|
|
|
HAL::STM32::H7::M7::TIMEx
|
|
|
|
HAL::STM32::H7::M7::ETH
|
2021-07-13 10:23:17 +02:00
|
|
|
HAL::STM32::H7::M7::SPI
|
|
|
|
HAL::STM32::H7::M7::DMA
|
|
|
|
${CMSIS_LINK_TARGET}
|
2021-07-12 23:33:05 +02:00
|
|
|
CMSIS::STM32::H7::M7::RTOS
|
2021-07-12 22:11:03 +02:00
|
|
|
STM32::NoSys
|
|
|
|
STM32::Nano
|
|
|
|
STM32::Nano::FloatPrint
|
|
|
|
STM32::Nano::FloatScan
|
2021-07-13 09:15:56 +02:00
|
|
|
LwIP
|
|
|
|
LwIP::IPv4
|
|
|
|
LwIP::NETIF
|
2021-07-12 21:50:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Add include paths for all sources.
|
|
|
|
target_include_directories(${TARGET_NAME} PRIVATE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${FSFW_CONFIG_PATH}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
target_link_options(${TARGET_NAME} PRIVATE
|
|
|
|
"-Wl,-Map=${TARGET_NAME}.map"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Remove unused sections.
|
|
|
|
target_compile_options(${TARGET_NAME} PRIVATE
|
|
|
|
"-ffunction-sections"
|
|
|
|
"-fdata-sections"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Removed unused sections.
|
2021-07-14 00:55:24 +02:00
|
|
|
if(NOT FSFW_OSAL MATCHES rtems)
|
2021-07-12 21:50:48 +02:00
|
|
|
target_link_options(${TARGET_NAME} PRIVATE
|
|
|
|
"-Wl,--gc-sections"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_VERBOSE)
|
|
|
|
message(STATUS "Warning flags: ${WARNING_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# Compile options for all sources.
|
|
|
|
target_compile_options(${TARGET_NAME} PRIVATE
|
|
|
|
${WARNING_FLAGS}
|
|
|
|
)
|
|
|
|
|
|
|
|
if(TGT_BSP)
|
|
|
|
set(TARGET_STRING "Target BSP: ${TGT_BSP}")
|
|
|
|
else()
|
|
|
|
set(TARGET_STRING "Target BSP: Hosted")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(CONCAT POST_BUILD_COMMENT
|
|
|
|
"Build directory: ${CMAKE_BINARY_DIR}\n"
|
2021-07-14 00:55:24 +02:00
|
|
|
"Target OSAL: ${FSFW_OSAL}\n"
|
2021-07-12 21:50:48 +02:00
|
|
|
"Target Build Type: ${CMAKE_BUILD_TYPE}\n"
|
|
|
|
"${TARGET_STRING}"
|
|
|
|
)
|
|
|
|
|
2021-07-13 10:23:17 +02:00
|
|
|
stm32_add_linker_script(${TARGET_NAME} "PRIVATE" "${BSP_NUCLEO_PATH}/STM32H743ZITx_FLASH.ld")
|
|
|
|
|
2021-07-12 21:50:48 +02:00
|
|
|
include (${CMAKE_SCRIPT_PATH}/BuildType.cmake)
|
|
|
|
set_build_type()
|
2021-07-12 22:11:03 +02:00
|
|
|
|
|
|
|
stm32_print_size_of_target(${TARGET_NAME})
|
|
|
|
stm32_generate_binary_file(${TARGET_NAME})
|