Coder Social home page Coder Social logo

ioc2cmake's Introduction

ioc2cmake

This repository is deprecated, please use cubemx.cmake instead.

This is a small Python tool that allows building STM32CubeMX generated firmware with CMake. It parses STM32CubeMX *.ioc project files and generates CMake variables containing the appropriate settings for the microcontroller (include paths, compiler flags, etc.).

For VScode, it generates a c_cpp_properties.json config file, containing the relevant include paths & compiler definitions - as well as launch.json and settings.json files for the debugger. (The CortexDebug extension should be installed in order to use the debugger). With these config files, VScode can be used as an IDE for the firmware project.

How it works

ioc2cmake is called at configuration stage from within the CMake script. It spits out a list of key=value pairs on stdout, which are captured by the CMake script and saved in variables. These variables are then used to configure the firmware build.

Because the STM32 MCU type, include paths etc. are not hardcoded in the CMakeLists.txt but generated at configure stage, firmware can be ported to different MCUs without changing the build script, and the build script can be reused on firmwares targeting other STM32 MCUs.

Usage

Call ioc2cmake from the CMake script like this:

execute_process(COMMAND ${CMAKE_SOURCE_DIR}/ioc2cmake.py
    ${CMAKE_SOURCE_DIR}                 # Path to source tree
    ${CMAKE_SOURCE_DIR}/cubemx-proj.ioc # Path to CubeMX project file
    -s ${CMAKE_SOURCE_DIR}/app          # Extra source folder
    -i ${CMAKE_SOURCE_DIR}/app          # Extra include folder
    -t /opt/gcc-arm-none-eabi-7-2017-q4-major   # Toolchain location
    -v                                  # Create vscode properties file
    OUTPUT_VARIABLE ConfigContents
)

It needs the path to the source tree, path to the CubeMX *.ioc project file and the path to the toolchain. It assumes the regular CubeMX generated source structure. Additional source and include directories can be added with -s and -i switches, respectively. (I like to put my written source files in other directories than the autogenerated ones, for better clarity).

There is an example CMakeLists.txt in the repository demonstrating the use of ioc2cmake.

The firmware build can be set up like a regular CMake build.

It works with CubeMX LL drivers, HAL drivers, as well as with a mixed setup.

Caveats

For Cortex-M7 MCUs, at the moment it always assumes a double-precision FPU, but there are M7's which have single precision only.

Tested on following MCUs / boards so far:

  • STM32F407 / STM32F407G-DISC1
  • STM32F767 / NUCLEO-F767ZI
  • STM32L433 / NUCLEO-L433RC-P
  • STM32L476 / NUCLEO-L476RG
  • STM32L496 / NUCLEO-L496ZG
  • STM32L431
  • STM32L471

Feedback and contributions welcome.

ioc2cmake's People

Contributors

benbe avatar patrislav1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

kunyi benbe

ioc2cmake's Issues

Feature Request: Merge VSCode configurations into existing settings

It would be cool if the existing settings of .vscode for especially the launch.json could be kept and just supplemented by the settings defined in the Python script. Especially if you have a somewhat mixed project with an CubeMX project as well as some python code, it's a bit annoying to always have to reconfigure the Python debugging configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.