Small cross-platform Python app that can create and update PlatformIO projects from STM32CubeMX .ioc files. It uses STM32CubeMX to generate a HAL-framework-based code and alongside creates PlatformIO project with compatible parameters to stick them both together
It uses the STM32CubeMX to generate a HAL-framework-based code and alongside creates the PlatformIO project with compatible parameters to bind them both together.
The GUI version is available, too (please, read this main introduction first).
Table of contents
- Originate the new full-fledged project in a single directory starting only from an
- Seamlessly update an existing project after the hardware changes by CubeMX
- Quickly check the current state
- Inspect tools (CubeMX, PlatformIO, etc.)
- Clean-up the project
- [optional] Automatically run your favorite editor or initiate a build in the end
- [optional] GUI edition (see the dedicated README file) (please, read this main introduction first)
OS: macOS, Linux, Windows 7-10
The app introduces zero dependencies by itself. Of course, you need to have all the necessary tools installed in order to perform the operations:
- STM32CubeMX with the desired downloaded frameworks (F0, F1, etc.). All recent versions are fine (5.x, 6.x)
- Java (JRE, Java runtime environment) for the CubeMX (already installed if the CubeMX is working). Which version is appropriate for the CubeMX you can find in its own description
- PlatformIO (4.2.0 and above) CLI (most likely is already present if you have installed it via some package manager (
brew, etc.) or need to be installed as a "command line extension" from the PlatformIO IDE (see its docs for more information))
If you, for some reasons, don't want to (or simply cannot) install (i.e. register in PATH) command line versions of these applications in your system, you can always specify the direct paths to them overriding the default values in the project configuration file
stm32pio.ini. Check the config reference to see all possible ways of telling stm32pio where the tools are residing on your machine.
As a normal Python package the app can be run in a completely portable way by downloading (or cloning) the snapshot of this repository and invoking the main script:
stm32pio-repo/ $ python3 stm32pio/cli/app.py stm32pio-repo/ $ python3 -m stm32pio.cli # or as the Python module any-path/ $ python3 path/to/stm32pio-repo/stm32pio/cli/app.py
Note: we will assume
However, it's handier to install the utility to be able to run from anywhere. The PyPI distribution is available:
$ pip install stm32pio
To uninstall run
$ pip uninstall stm32pio
You can always run
$ stm32pio --help
to see help on available commands.
Basically, you need to follow such a workflow (refer to the example which explains the same just illustrating it with some screenshots/command snippets):
- Create the CubeMX project (
.iocfile) like you're used to, set up your hardware configuration, but after all save it with the compatible parameters
- Run stm32pio that automatically invokes CubeMX to generate a code, creates the PlatformIO project, patches the
- Work with your project normally as you wish, build/upload/debug etc.
- When necessary, come back to the hardware configuration in the CubeMX, then run stm32pio again to re-generate the code
See the commands reference file listing the complete help about the available commands/options. On the first run, stm32pio will create a config file
stm32pio.ini, syntax of which is similar to the
platformio.ini. You can also create this config without any following operations by initializing the project:
$ stm32pio init -d path/to/project
It may be useful to tweak some parameters before proceeding. See the config reference showing meanings for every key.
If you're stuck and the basic logs doesn't clear the situation, try the following:
- Run the same command in the verbose mode using the
$ stm32pio -v [command] [options]This will unlock additional logs which might help to clarify
- Validate your environment, i.e. check whether the stm32pio can find all the essential tools on your machine:
$ stm32pio validate -d path/to/projectThis will print the report about the current set up according to your config
- Use the dynamic help feature which outputs information specifically about the requested command, e.g.:
$ stm32pio new -h
- The tool doesn't check for different parameters' compatibility, e.g. CPU/IO/etc frequencies, allocated memory and so on. It simply eases your workflow with these 2 programs (PlatformIO and STM32CubeMX) a little bit.
- In order to add CubeMX middlewares to your build the manual adjustments should be applied, the stm32pio doesn't handle them automatically. For example, FreeRTOS can be added via PlatformIO'
libfeature or be directly compiled in its own directory using
lib_extra_dirs = Middlewares/Third_Party/FreeRTOSYou also need to move all
.hfiles to the appropriate folders respectively. See PlatformIO documentation for more information.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size stm32pio-2.1.0-py3-none-any.whl (61.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size stm32pio-2.1.0.tar.gz (967.9 kB)||File type Source||Python version None||Upload date||Hashes View|