Skip to main content

STM32CubeMX to PlatformIO Migration Tool

Project description

STM32Bridge - STM32CubeMX to PlatformIO Migration Tool

Python 3.8+ MIT License PlatformIO

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

  1. Generate STM32CubeMX Project: Create your project with Makefile toolchain
  2. Analyze: python main.py analyze /path/to/project to verify compatibility
  3. Migrate: python main.py migrate /path/to/project /path/to/output --board nucleo_l432kc --build --open
  4. Develop: Your PlatformIO project is ready with full build and debug support!

๐Ÿ› Troubleshooting

Common Issues

  • Build Failures: Use --build flag to get detailed error analysis and automatic fixes
  • Missing Dependencies: Tool automatically installs required Python packages (GitPython, etc.)
  • FreeRTOS Issues: Try --no-freertos or --framework-freertos flags
  • Board Detection: Use python main.py list-boards to find the correct board name

Debug Options

  • Use python main.py analyze to 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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stm32bridge-1.3.3-py3-none-any.whl (45.7 kB view details)

Uploaded Python 3

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

Hashes for stm32bridge-1.3.3.tar.gz
Algorithm Hash digest
SHA256 e02b357a87656e530af4bcb95425addb3f2a2307e0a38d5ae2071b9bc81e72c4
MD5 24d0738fc17c1247b862e749d09b10d1
BLAKE2b-256 dff979c7fc9b153b3c20d4fabf3bcc096a700b82f61fca17f612f8f1ac8b5203

See more details on using hashes here.

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

Hashes for stm32bridge-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 98c23b5c87cdcc0f21f9b5e605e826c604aa431177a0194e9d11a05499b6b85f
MD5 26723e60788c21203438d2b3ae29cb28
BLAKE2b-256 a8b6f3a2b76e51a375750a89b7bb510a828b1c498b635a926316ca90ec68b19f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page