From 546b765e962e084337724e65841439eebc61e0b8 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Wed, 10 Jun 2026 10:15:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AD=90=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 ++ .project | 33 ++++++++++++++++ CMakeLists.txt | 5 ++- CMakePresets.json | 86 ++++++++++++++++++++++++----------------- gcc-arm-none-eabi.cmake | 48 +++++++++++++++++++++++ robot | 1 + 6 files changed, 139 insertions(+), 37 deletions(-) create mode 100644 .gitmodules create mode 100644 .project create mode 100644 gcc-arm-none-eabi.cmake create mode 160000 robot diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b853892 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "robot"] + path = robot + url = http://123.207.52.103:3000/LiZongdi/robot.git diff --git a/.project b/.project new file mode 100644 index 0000000..a82cbf2 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + 32g431 + + + + + + com.st.stm32cube.ide.cmake.CmakeConfigureProjectBuilder + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + com.st.stm32cube.ide.cmake.CmakeConfigProjectNature + com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d60ab8..a52ad40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,11 @@ target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ob) # Add linked libraries +set(GENERATED_COMMON_DIR "${CMAKE_BINARY_DIR}/library/common") +include_directories("${GENERATED_COMMON_DIR}") +add_subdirectory(robot) target_link_libraries(${CMAKE_PROJECT_NAME} stm32cubemx - + main # Add user defined libraries ) diff --git a/CMakePresets.json b/CMakePresets.json index 9a0c120..f4b57da 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,38 +1,52 @@ { - "version": 3, - "configurePresets": [ - { - "name": "default", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "toolchainFile": "${sourceDir}/cmake/gcc-arm-none-eabi.cmake", - "cacheVariables": { - } - }, - { - "name": "Debug", - "inherits": "default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "Release", - "inherits": "default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - } - ], - "buildPresets": [ - { - "name": "Debug", - "configurePreset": "Debug" - }, - { - "name": "Release", - "configurePreset": "Release" - } - ] + "version": 4, + "configurePresets": [ + { + "name": "default-release", + "hidden": true, + "displayName": "Default Release Build", + "description": "Default Release Build", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "A_BUILD_MAIN": "ON", + "BUILD_COMMON": "ON", + "MY_BUILD_STATIC": "ON" + } + }, + { + "name": "Spool-end", + "generator": "Ninja", + "toolchainFile": "${sourceDir}/gcc-arm-none-eabi.cmake", + "inherits": "default-release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "BUILD_LUA": "ON", + "A_BUILD_MAIN_AS_STATIC_LIB": "ON", + "BUILD_LUA_STANDALONE": "OFF", + "MY_BUILD_STATIC": "OFF", + "BUILD_RINGBUFFER": "ON", + "BUILD_PERIPHERAL": "ON", + "BUILD_LIST": "ON", + "BUILD_BSPMCU": "ON", + "MEM_POOL_TOTAL_SIZE": "46*1024", + "USE_UART": true, + "USE_CAN": true + } + }, + { + "name": "robot", + "inherits": "Spool-end", + "cacheVariables": { + "BUILD_RBCORE": "ON", + "BUILD_OPTIONAL": "ON", + "IOC_100PIN": true, + "USE_LUA_ST": true, + "USE_LUA_ST_CAN": true, + "USE_TALNET": true, + "USE_LWIP": true, + "USE_FREERTOS": true + } + } + ] } \ No newline at end of file diff --git a/gcc-arm-none-eabi.cmake b/gcc-arm-none-eabi.cmake new file mode 100644 index 0000000..bc0924f --- /dev/null +++ b/gcc-arm-none-eabi.cmake @@ -0,0 +1,48 @@ +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(CMAKE_C_COMPILER_ID GNU) +set(CMAKE_CXX_COMPILER_ID GNU) + +# Some default GCC settings +# arm-none-eabi- must be part of path environment +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_LINKER ${TOOLCHAIN_PREFIX}g++) +set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy) +set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size) + +set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf") +set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") +set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +# MCU specific flags +set(TARGET_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard ") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS}") +set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -MMD -MP") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fdata-sections -ffunction-sections -fstack-usage") + +# The cyclomatic-complexity parameter must be defined for the Cyclomatic complexity feature in STM32CubeIDE to work. +# However, most GCC toolchains do not support this option, which causes a compilation error; for this reason, the feature is disabled by default. +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcyclomatic-complexity") + +set(CMAKE_C_FLAGS_DEBUG "-O0 -g3") +set(CMAKE_C_FLAGS_RELEASE "-Os -g0") +set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3") +set(CMAKE_CXX_FLAGS_RELEASE "-Os -g0") + +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -fno-threadsafe-statics") +set(LINKER_SYMBOLS "-u _fputc -u fputc -u _fgetc -u fgetc") +set(CMAKE_EXE_LINKER_FLAGS "${TARGET_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T \"${CMAKE_SOURCE_DIR}/STM32G431XX_FLASH.ld\"") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--print-memory-usage") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_SYMBOLS}") +set(TOOLCHAIN_LINK_LIBRARIES "m") diff --git a/robot b/robot new file mode 160000 index 0000000..07754e0 --- /dev/null +++ b/robot @@ -0,0 +1 @@ +Subproject commit 07754e024e60b4b8766b89f34581dc0738639533