- CMake
- ARM GNU GCC Tools
- MinGW
-
Create a build folder (ex. cmake-build-debug) and cd to that folder
-
Run
cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=../arm-none-eabi-gcc.cmake -DCMAKE_BUILD_TYPE=Debug ..
-
Then, run
cmake --build . -- -j 4
-
You should obtain .bin and .hex files for your target
- Use STM32CubeProgrammer to program the device.
- Open the folder containing CMakeLists.txt and *.cmake file with CLion.
- In File -> Settings -> Build, Execution, Deployment section, add the following to CMake options field:
-DCMAKE_TOOLCHAIN_FILE=arm-none-eabi-gcc.cmake
- CLion should reload the CMake project without any errors.
- Build the project
- Create a new run configuration (Run -> Edit Configurations)
- Add a new OpenOCD Download & Run configuration
- In the board config file field, supply the appropriate configuration file. Ex. https://github.com/ntfreak/openocd/blob/master/tcl/board/st_nucleo_f4.cfg
- Also make sure to fill the Executable field ex. template.out file in the build folder
- Pressing the Run button should now flash the target
- To debug, place a breakpoint and click on the green bug (debug) icon. The debugger should stop at the breakpoint
- Undefined reference to _sbrk: https://stackoverflow.com/questions/5764414/undefined-reference-to-sbrk