ussserrr / stm32pio

Automate managing of STM32CubeMX + PlatformIO projects
https://pypi.org/project/stm32pio
Other
224 stars 24 forks source link
cubemx platformio qml qt-for-python stm32

stm32pio

Build Status

Small cross-platform Python app that can create and update PlatformIO projects from STM32CubeMX .ioc files.

It uses the STM32CubeMX to generate a HAL-framework-based code and alongside creates the PlatformIO project with compatible parameters to glue them both together.

The GUI version is available, too (but read this main introduction first, please).

Logo

Table of contents

Features

Requirements:

OS: Linux, macOS, Windows (few latest versions of 7, and above)

Python: 3.6+

The app introduces zero dependencies by itself. Of course, you need to have all necessary tools installed on your machine in order to perform the operations:

Either way, for every tool listed above, a simple direct path to the according executable can be specified just in case you cannot or don't want to register them in your PATH. Check the config reference to see all possible ways of telling stm32pio where the tools are residing on your machine.

Documentation

Installation

The most straightforward way is to get the PyPI distribution:

$ pip install stm32pio

To uninstall run

$ pip uninstall stm32pio

As a normal Python package, the app can be run completely portable. Simply download or clone this repository and launch the main script:

stm32pio-repo/ $   python stm32pio/cli/app.py  # call the file...
stm32pio-repo/ $   python -m stm32pio.cli  # ...or run as Python module
stm32pio-repo/ $   python -m stm32pio.cli.app
any-path/ $   python path/to/stm32pio-repo/stm32pio/cli/app.py  # the script can be invoked from anywhere

Usage

You can always run

$ stm32pio

to see help on available commands.

Essentially, you need to follow such a workflow:

  1. Create new CubeMX project, set up your hardware configuration, and save with compatible parameters. You'll end up with the .ioc file.
  2. Run stm32pio that automatically invokes CubeMX to generate a code, establishes new PlatformIO project with specific parameters and applies the patch.
  3. Work with your PlatformIO project normally as you like, build/upload/debug etc.
  4. When necessary, come back to hardware configuration in CubeMX, then run stm32pio again to re-generate the code.

Refer to the example guide which basically explains same concepts just in more details and illustrates with some screenshots/command snippets.

See the commands reference providing the complete help about available commands/options. On the first run in your project, stm32pio will create a config file stm32pio.ini, syntax of which is similar to platformio.ini. You can also create such config without any following operations by initializing the project:

path/to/project $ stm32pio init

Might be useful to tweak some parameters before proceeding. See the config reference showing meanings for every key.

Troubleshooting

If you've encountered a problem and basic logs doesn't clear the situation, try the following:

Restrictions