STM32CubeMX to PlatformIO Migration Tool
Project description
STM32Bridge - STM32CubeMX to PlatformIO Migration Tool
A comprehensive CLI utility to automate the migration of STM32CubeMX projects to PlatformIO with full FreeRTOS support.
๐ฆ Installation
From PyPI (Recommended)
pip install stm32bridge
Development Installation
git clone https://github.com/jobenas/stm32bridge.git
cd stm32bridge
pip install -e .
# For testing and development
pip install -r requirements-dev.txt
# Or install specific dependency groups
pip install -e .[test] # Testing dependencies
pip install -e .[dev] # Development tools
pip install -e .[pdf] # PDF processing (optional)
pip install -e .[build] # Build tools
From Local Wheel
# Build and install from source
git clone https://github.com/jobenas/stm32bridge.git
cd stm32bridge
pip install build
python -m build
pip install dist/stm32bridge-1.0.0-py3-none-any.whl
Prerequisites
- Python 3.8 or higher
- PlatformIO Core (automatically checked and installed if needed)
- Git (for some FreeRTOS library dependencies)
๐ Features
- Complete Project Migration: Analyzes STM32CubeMX projects and creates fully configured PlatformIO projects
- FreeRTOS Support: Automatic FreeRTOS library integration with CMSIS-OS v2 compatibility
- Build Verification: Integrated build testing with automatic dependency resolution
- Editor Integration: Open migrated projects directly in your favorite code editor
- Board Detection: Automatic MCU and board detection with extensive board mapping
- Flexible Configuration: Support for custom boards, FreeRTOS configurations, and build options
๐ Project Structure
stm32bridge/
โโโ main.py # CLI entry point
โโโ stm32bridge/
โ โโโ __init__.py # Package initialization
โ โโโ constants.py # MCU families and board mappings
โ โโโ exceptions.py # Custom exceptions
โ โโโ core/ # Core migration logic
โ โ โโโ analyzer.py # STM32CubeMX project analysis
โ โ โโโ generator.py # PlatformIO project generation
โ โ โโโ migrator.py # File migration and adaptation
โ โโโ utils/ # Utility modules
โ โ โโโ build.py # Build verification and dependency management
โ โ โโโ editor.py # Code editor integration
โ โ โโโ platformio.py # PlatformIO command execution
โ โ โโโ boards.py # Board detection utilities
โ โโโ cli/ # CLI command implementations
โ โโโ migrate.py # Migration command
โ โโโ analyze.py # Analysis command
โ โโโ list_boards.py # Board listing command
โโโ stm32bridge.py # Legacy monolithic version (for reference)
๐ ๏ธ Installation
Prerequisites
- Python 3.8+
- PlatformIO Core (installed via pip or standalone)
Install STM32Bridge
# Clone the repository
git clone <repository-url>
cd stm32bridge
# Install in development mode
pip install -e .
# For development with all dependencies
pip install -r requirements-dev.txt
# Or install specific dependency groups
pip install -e .[test] # Testing dependencies
pip install -e .[dev] # Development tools
pip install -e .[pdf] # PDF processing (optional)
๐ Usage
Basic Migration
# Migrate a project with automatic board detection
stm32bridge migrate my_stm32_project my_platformio_project
# Specify a specific board
stm32bridge migrate my_stm32_project my_platformio_project --board nucleo_l432kc
# Windows example
stm32bridge migrate C:\Projects\MySTM32Project C:\Projects\MyPlatformIOProject --board nucleo_f401re
# Linux/Mac example
stm32bridge migrate ~/projects/my_stm32_project ~/projects/my_platformio_project --board disco_f407vg
Advanced Options
# Migrate with build verification
stm32bridge migrate my_stm32_project my_platformio_project --board nucleo_l432kc --build
# Migrate and open in VS Code
stm32bridge migrate my_stm32_project my_platformio_project --board nucleo_l432kc --open
# Use different editor
stm32bridge migrate my_stm32_project my_platformio_project --board nucleo_l432kc --open --editor code
# Force overwrite existing directory
stm32bridge migrate my_stm32_project my_platformio_project --force
FreeRTOS Options
# Use framework FreeRTOS instead of external library
stm32bridge migrate my_stm32_project my_platformio_project --no-freertos
# Completely disable FreeRTOS migration
stm32bridge migrate my_stm32_project my_platformio_project --disable-freertos
# Use PlatformIO framework's built-in FreeRTOS
stm32bridge migrate my_stm32_project my_platformio_project --framework-freertos
Analysis and Information
# Analyze project without migration
stm32bridge analyze my_stm32_project
# List supported boards
stm32bridge list-boards
# Get help
stm32bridge --help
stm32bridge migrate --help
๐ง Supported Features
MCU Families
- STM32F0, F1, F2, F3, F4, F7
- STM32G0, G4
- STM32H7
- STM32L0, L1, L4, L5
- STM32U5
- STM32WB
FreeRTOS Integration
- Automatic FreeRTOS library detection and integration
- CMSIS-OS v2 compatibility layer
- Custom FreeRTOS configuration preservation
- Support for timers, event groups, and other FreeRTOS features
Build System
- Complete PlatformIO configuration generation
- Automatic dependency resolution
- Build verification with memory usage reporting
- Support for custom build flags and configurations
Development Tools
- VS Code, VSCodium, Sublime Text, Atom, Vim support
- STLink upload and debug configuration
- Serial monitor setup
- Custom board definitions
๐ฏ Example Workflow
- Generate STM32CubeMX Project: Create your project with Makefile toolchain
- Analyze:
python main.py analyze /path/to/projectto verify compatibility - Migrate:
python main.py migrate /path/to/project /path/to/output --board nucleo_l432kc --build --open - Develop: Your PlatformIO project is ready with full build and debug support!
๐ Troubleshooting
Common Issues
- Build Failures: Use
--buildflag to get detailed error analysis and automatic fixes - Missing Dependencies: Tool automatically installs required Python packages (GitPython, etc.)
- FreeRTOS Issues: Try
--no-freertosor--framework-freertosflags - Board Detection: Use
python main.py list-boardsto find the correct board name
Debug Options
- Use
python main.py analyzeto validate project structure - Check PlatformIO installation:
pio --version - Verify board support:
pio boards | grep <your-mcu>
๐ค Contributing
The codebase is now well-organized and modular:
- Core Logic: Add new features in
stm32bridge/core/ - Utilities: Add helper functions in
stm32bridge/utils/ - CLI Commands: Add new commands in
stm32bridge/cli/ - Configuration: Update constants in
stm32bridge/constants.py
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
- PlatformIO team for the excellent embedded development platform
- STMicroelectronics for STM32CubeMX
- FreeRTOS community for real-time OS support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stm32bridge-1.3.3.tar.gz
(42.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stm32bridge-1.3.3.tar.gz.
File metadata
- Download URL: stm32bridge-1.3.3.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e02b357a87656e530af4bcb95425addb3f2a2307e0a38d5ae2071b9bc81e72c4
|
|
| MD5 |
24d0738fc17c1247b862e749d09b10d1
|
|
| BLAKE2b-256 |
dff979c7fc9b153b3c20d4fabf3bcc096a700b82f61fca17f612f8f1ac8b5203
|
File details
Details for the file stm32bridge-1.3.3-py3-none-any.whl.
File metadata
- Download URL: stm32bridge-1.3.3-py3-none-any.whl
- Upload date:
- Size: 45.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c23b5c87cdcc0f21f9b5e605e826c604aa431177a0194e9d11a05499b6b85f
|
|
| MD5 |
26723e60788c21203438d2b3ae29cb28
|
|
| BLAKE2b-256 |
a8b6f3a2b76e51a375750a89b7bb510a828b1c498b635a926316ca90ec68b19f
|