From 5c4a245c57c92237b7ab444784708baae9a1d62c Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Fri, 5 Jan 2024 18:59:32 +0300 Subject: [PATCH] sitl: wrap stm32f103 platform related part in USE_PLATFORM_UBUNTU --- CMakeLists.txt | 138 +++++++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 754d714..3d05a74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,32 +18,33 @@ else() include(${ROOT_DIR}/Src/cyphal_application/CMakeLists.txt) endif() -set(TOOLCHAIN_PREFIX arm-none-eabi-) -set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) -set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) -set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) -set(CMAKE_CXX_STANDARD 20) - -set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/stm32-cube-project) -FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*) -FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Src/*.c*) - -set(gitRelatedHeaders - ${ROOT_DIR}/build/src -) - -set(stm32CubeMxGeneratedFiles - ${coreSources} - ${driversSources} - ${stm32cubeMxProjectPath}/startup_stm32f103xb.s -) -set(stm32CubeMxHeaders - ${stm32cubeMxProjectPath}/Core/Inc - ${stm32cubeMxProjectPath}/Drivers/CMSIS/Device/ST/STM32F1xx/Include - ${stm32cubeMxProjectPath}/Drivers/CMSIS/Include - ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc - ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -) +if(USE_PLATFORM_UBUNTU) + message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!") +else() + set(TOOLCHAIN_PREFIX arm-none-eabi-) + set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) + set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) + set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) + set(CMAKE_CXX_STANDARD 20) + set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/stm32-cube-project) + FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*) + FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Src/*.c*) + set(gitRelatedHeaders + ${ROOT_DIR}/build/src + ) + set(stm32CubeMxGeneratedFiles + ${coreSources} + ${driversSources} + ${stm32cubeMxProjectPath}/startup_stm32f103xb.s + ) + set(stm32CubeMxHeaders + ${stm32cubeMxProjectPath}/Core/Inc + ${stm32cubeMxProjectPath}/Drivers/CMSIS/Device/ST/STM32F1xx/Include + ${stm32cubeMxProjectPath}/Drivers/CMSIS/Include + ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc + ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy + ) +endif() set(EXECUTABLE ${PROJECT_NAME}.out) add_executable(${EXECUTABLE} @@ -52,10 +53,15 @@ add_executable(${EXECUTABLE} ${libsSourceCode} ${applicationSourceCode} ) -target_compile_definitions(${EXECUTABLE} PRIVATE - -DUSE_HAL_DRIVER - -DSTM32F103xB -) + +if(USE_PLATFORM_UBUNTU) + message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!") +else() + target_compile_definitions(${EXECUTABLE} PRIVATE + -DUSE_HAL_DRIVER + -DSTM32F103xB + ) +endif() include_directories(${libsHeaders}) @@ -67,29 +73,33 @@ target_include_directories(${EXECUTABLE} PRIVATE SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-volatile") -target_compile_options(${EXECUTABLE} PRIVATE - -mcpu=cortex-m3 - -mthumb - -fdata-sections - -ffunction-sections - -lc -lm -lnosys - -specs=nano.specs - -Wall - --specs=nosys.specs -) +if(USE_PLATFORM_UBUNTU) + message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!") +else() + target_compile_options(${EXECUTABLE} PRIVATE + -mcpu=cortex-m3 + -mthumb + -fdata-sections + -ffunction-sections + -lc -lm -lnosys + -specs=nano.specs + -Wall + --specs=nosys.specs + ) -target_link_options(${EXECUTABLE} PRIVATE - -T${stm32cubeMxProjectPath}/STM32F103T8Ux_FLASH.ld - -mcpu=cortex-m3 - -mthumb - --specs=nosys.specs - -specs=nano.specs - -lc - -lm - -lnosys - -Wl,-Map=${PROJECT_NAME}.map,--cref - -Wl,--gc-sections -) + target_link_options(${EXECUTABLE} PRIVATE + -T${stm32cubeMxProjectPath}/STM32F103T8Ux_FLASH.ld + -mcpu=cortex-m3 + -mthumb + --specs=nosys.specs + -specs=nano.specs + -lc + -lm + -lnosys + -Wl,-Map=${PROJECT_NAME}.map,--cref + -Wl,--gc-sections + ) +endif() if(NOT USE_DRONECAN) execute_process( @@ -97,14 +107,18 @@ if(NOT USE_DRONECAN) ) endif() -add_custom_command(TARGET ${EXECUTABLE} - POST_BUILD - COMMAND arm-none-eabi-size ${EXECUTABLE} -) +if(USE_PLATFORM_UBUNTU) + message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!") +else() + add_custom_command(TARGET ${EXECUTABLE} + POST_BUILD + COMMAND arm-none-eabi-size ${EXECUTABLE} + ) -add_custom_command(TARGET ${EXECUTABLE} - POST_BUILD - COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex - COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin - COMMAND arm-none-eabi-objcopy -I binary -O elf32-little ${EXECUTABLE} ${PROJECT_NAME}.elf -) + add_custom_command(TARGET ${EXECUTABLE} + POST_BUILD + COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex + COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin + COMMAND arm-none-eabi-objcopy -I binary -O elf32-little ${EXECUTABLE} ${PROJECT_NAME}.elf + ) +endif()