Skip to content

using cmake to quickly organizing your cubemx stm32 project

License

Notifications You must be signed in to change notification settings

JasonLrh/CMake_STM32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CMake_STM32

using cmake to quickly organizing your cubemx stm32 project

features:

  1. HAL/LL and some system library are built as static library so that each time you add your new files/library, you won't wait for a long time rebuilding HAL/LL lib
  2. generate compile_commands.json which can easily used by visual studio code's auto-complete system. c_cpp_properties.json may be edit as below
{
    "configurations": [
        {
            "name": "ProjectName",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "macos-gcc-arm",
            "compileCommands": "${workspaceFolder}/cmake_build/compile_commands.json"
        }
    ],
    "version": 4
}
  1. beta feature: automatically code import and pack to library(speed up code rebuild when sources change)

tools

  • STM32CubeMX(Generate with Makefile)
    IDE
    and have settings as below
    Settings
  • STM32CubeProgramer(Flash tool)
  • CMake
  • arm-none-eabi-gcc toolchain(strongly suggest)

configure

  1. drag CMakeLists.txt from this rep to the root path of your project(which is generate automatically by STM32CubeMX)
  2. edit your project name with below
project(A_NAME_THAT_YOU_LIKE)
  1. edit ${MCU_FLAGS} to your hardware platform. if you don't know how to write, find them in Makefile which generate by CubeMX
# cpu
CPU = -mcpu=cortex-m4

# fpu
FPU = -mfpu=fpv4-sp-d16

# float-abi
FLOAT-ABI = -mfloat-abi=hard
  1. check defines and include dir recording to your Makefile
  2. edit your file and lib settings
  3. use it well

build and flash

mkdir cmake_build # anyname\anywhere
cmake ../   # ../ is the dir with CMakeLists.txt
make -j     # build with this arg to have max speed
make flash  # flash to your device

About

using cmake to quickly organizing your cubemx stm32 project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages