Skip to content

Commit 7751fdd

Browse files
committed
update toolchain
1 parent d21817e commit 7751fdd

7 files changed

+175
-62
lines changed

CMakeLists.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,39 @@ if(USE_PLATFORM_UBUNTU)
1919
set(CAN_PLATFORM socketcan)
2020
set(APP_PLATFORM ubuntu)
2121
set(PLATFORM_NAME sitl)
22+
include(${CMAKE_DIR}/toolchain-ubuntu.cmake)
2223
elseif(USE_PLATFORM_NODE_V2)
2324
set(LIBPARAMS_PLATFORM stm32f103)
2425
set(CAN_PLATFORM bxcan)
2526
set(APP_PLATFORM stm32f103)
2627
set(PLATFORM_NAME v2)
27-
include(${CMAKE_DIR}/stm32f103xB.cmake)
28+
29+
set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/stm32-cube-project)
30+
FILE(GLOB ldFile ${stm32cubeMxProjectPath}/*_FLASH.ld)
31+
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
32+
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/*/*/*.c)
33+
FILE(GLOB startupFile ${stm32cubeMxProjectPath}/*.s
34+
${stm32cubeMxProjectPath}/Core/Startup/*.s
35+
)
36+
37+
set(CMAKE_EXE_LINKER_FLAGS "-T${ldFile} -Wl,-Map=${PROJECT_NAME}.map,--cref")
38+
include(${CMAKE_DIR}/toolchain-stm32f103xB.cmake)
2839
elseif(USE_PLATFORM_NODE_V3)
2940
set(LIBPARAMS_PLATFORM stm32g0b1)
3041
set(CAN_PLATFORM fdcan)
3142
set(APP_PLATFORM stm32g0b1)
3243
set(PLATFORM_NAME v3)
33-
include(${CMAKE_DIR}/stm32g0b1.cmake)
44+
45+
set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/mini-v3-ioc)
46+
FILE(GLOB ldFile ${stm32cubeMxProjectPath}/*_FLASH.ld)
47+
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
48+
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/*/*/*.c)
49+
FILE(GLOB startupFile ${stm32cubeMxProjectPath}/*.s
50+
${stm32cubeMxProjectPath}/Core/Startup/*.s
51+
)
52+
53+
set(CMAKE_EXE_LINKER_FLAGS "-T${ldFile} -Wl,-Map=${PROJECT_NAME}.map,--cref")
54+
include(${CMAKE_DIR}/toolchain-stm32g0b1.cmake)
3455
add_compile_definitions(CYPHAL_NUM_OF_CAN_BUSES=2)
3556
else()
3657
message(SEND_ERROR "Platform Error: Either v2 (stm32f103), v3 (stm32g0) or SITL (Linux) should be specified.")

cmake/Toolchain-arm-none-eabi.cmake

Lines changed: 0 additions & 32 deletions
This file was deleted.

cmake/stm32f103xB.cmake

Lines changed: 0 additions & 15 deletions
This file was deleted.

cmake/stm32g0b1.cmake

Lines changed: 0 additions & 13 deletions
This file was deleted.

cmake/toolchain-stm32f103xB.cmake

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (C) 2023-2024 Dmitry Ponomarev <[email protected]>
2+
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.
3+
4+
cmake_minimum_required(VERSION 3.15.3)
5+
6+
if(NOT CMAKE_BUILD_TYPE)
7+
set(CMAKE_BUILD_TYPE Release)
8+
endif()
9+
10+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
11+
12+
# ==================================
13+
# Target System
14+
# ==================================
15+
set(CMAKE_SYSTEM_NAME Generic)
16+
set(CMAKE_SYSTEM_PROCESSOR arm)
17+
18+
# ==================================
19+
# Compiler Paths
20+
# ==================================
21+
set(TOOLCHAIN_PREFIX arm-none-eabi)
22+
23+
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
24+
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
25+
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
26+
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}-objcopy)
27+
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}-size)
28+
29+
# ==================================
30+
# Compilation and Linker Flags
31+
# ==================================
32+
set(COMMON_FLAGS "-mcpu=cortex-m3 -mthumb -fdata-sections -ffunction-sections")
33+
set(WARNING_FLAGS "-Wall -Wextra -Wfloat-equal -Werror -Wundef -Wshadow -Wpointer-arith -Wunreachable-code -Wstrict-overflow=5 -Wwrite-strings -Wswitch-default") # these could be also useful: -Wconversion -Wsign-conversion
34+
35+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} ${WARNING_FLAGS}") # these could be also useful: -Wmissing-prototypes -Wstrict-prototypes
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${WARNING_FLAGS} -Wno-volatile -fno-exceptions -fno-rtti")
37+
38+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-m3 -mthumb -lc -lm -lnosys -specs=nano.specs -Wl,--gc-sections")
39+
40+
# ==================================
41+
# Language Standards
42+
# ==================================
43+
if(NOT CMAKE_C_STANDARD)
44+
set(CMAKE_C_STANDARD 11)
45+
endif()
46+
if(NOT CMAKE_CXX_STANDARD)
47+
set(CMAKE_CXX_STANDARD 20)
48+
endif()
49+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
50+
# set(CMAKE_CXX_EXTENSIONS OFF) # todo
51+
52+
# ==================================
53+
# Preprocessor Definitions
54+
# ==================================
55+
add_compile_definitions(
56+
USE_HAL_DRIVER
57+
STM32F103xB
58+
)

cmake/toolchain-stm32g0b1.cmake

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (C) 2023-2024 Dmitry Ponomarev <[email protected]>
2+
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.
3+
4+
cmake_minimum_required(VERSION 3.15.3)
5+
6+
if(NOT CMAKE_BUILD_TYPE)
7+
set(CMAKE_BUILD_TYPE Release)
8+
endif()
9+
10+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
11+
12+
# ==================================
13+
# Target System
14+
# ==================================
15+
set(CMAKE_SYSTEM_NAME Generic)
16+
set(CMAKE_SYSTEM_PROCESSOR arm)
17+
18+
# ==================================
19+
# Compiler Paths
20+
# ==================================
21+
set(TOOLCHAIN_PREFIX arm-none-eabi)
22+
23+
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
24+
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
25+
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
26+
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}-objcopy)
27+
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}-size)
28+
29+
# ==================================
30+
# Compilation and Linker Flags
31+
# ==================================
32+
set(COMMON_FLAGS "-mcpu=cortex-m0plus -mthumb -fdata-sections -ffunction-sections")
33+
set(WARNING_FLAGS "-Wall -Wextra -Wfloat-equal -Werror -Wundef -Wshadow -Wpointer-arith -Wunreachable-code -Wstrict-overflow=5 -Wwrite-strings -Wswitch-default") # these could be also useful: -Wconversion -Wsign-conversion
34+
35+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} ${WARNING_FLAGS}") # these could be also useful: -Wmissing-prototypes -Wstrict-prototypes
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${WARNING_FLAGS} -Wno-volatile -fno-exceptions -fno-rtti")
37+
38+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-m0plus -mthumb -lc -lm -lnosys -specs=nano.specs -Wl,--gc-sections")
39+
40+
# ==================================
41+
# Language Standards
42+
# ==================================
43+
if(NOT CMAKE_C_STANDARD)
44+
set(CMAKE_C_STANDARD 11)
45+
endif()
46+
if(NOT CMAKE_CXX_STANDARD)
47+
set(CMAKE_CXX_STANDARD 20)
48+
endif()
49+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
50+
# set(CMAKE_CXX_EXTENSIONS OFF) # todo
51+
52+
# ==================================
53+
# Preprocessor Definitions
54+
# ==================================
55+
add_compile_definitions(
56+
USE_HAL_DRIVER
57+
STM32G0B1xx
58+
)

cmake/toolchain-ubuntu.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (C) 2023-2024 Dmitry Ponomarev <[email protected]>
2+
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.
3+
4+
cmake_minimum_required(VERSION 3.15.3)
5+
6+
if(NOT CMAKE_BUILD_TYPE)
7+
set(CMAKE_BUILD_TYPE Release)
8+
endif()
9+
10+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
11+
12+
# ==================================
13+
# Target System
14+
# ==================================
15+
set(CMAKE_SYSTEM_NAME Linux)
16+
set(CMAKE_SYSTEM_PROCESSOR x86_64)
17+
18+
# ==================================
19+
# Compilation and Linker Flags
20+
# ==================================
21+
set(WARNING_FLAGS "-Wall -Wextra -Wfloat-equal -Werror -Wundef -Wshadow -Wpointer-arith -Wunreachable-code -Wstrict-overflow=5 -Wwrite-strings -Wswitch-default") # these could be also useful: -Wconversion -Wsign-conversion
22+
23+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} ${WARNING_FLAGS}") # these could be also useful: -Wmissing-prototypes -Wstrict-prototypes
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Wno-volatile")
25+
26+
# ==================================
27+
# Language Standards
28+
# ==================================
29+
if(NOT CMAKE_C_STANDARD)
30+
set(CMAKE_C_STANDARD 11)
31+
endif()
32+
if(NOT CMAKE_CXX_STANDARD)
33+
set(CMAKE_CXX_STANDARD 20)
34+
endif()
35+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
36+
set(CMAKE_CXX_EXTENSIONS OFF)

0 commit comments

Comments
 (0)