Skip to content

Conversation

@dirkju
Copy link

@dirkju dirkju commented Oct 21, 2025

Adding Arduino_core_STM32 support

Three previous attempts of adding STM32 support were abandoned (#1422, #1437, #1486).
@tekka007 s branch also served as inspiration. Thanks to everyone of you.

I'm asking you to please consider my attempt :-) @tekka007 @mfalkvidd

Risks

The change is rather local in hal/STM32 and should not cause problems with other architectures.
I've kept the existing legacy hal/STM32F1 unchanged and the respective constant is checked in MySensors.h before my STM32 addition. This should maximize backward-compatibility for STM32F1 (blue pill) legacy users.

Implemented in this version

  • Serial communication (USB CDC and Hardware UART)
  • SPI interface for radios
  • EEPROM emulation using Flash memory
  • Watchdog support (requires explicit initialization)
  • System reboot
  • Random number generation (using internal temperature sensor)
  • Unique device ID (96-bit STM32 UID)
  • CPU voltage reading (via VREFINT)
  • CPU temperature reading (via internal sensor)
  • CPU frequency reporting
  • Critical section (interrupt disable/restore)
  • RAM routing table support

Planned

  • Low-power sleep modes (STOP, STANDBY)
  • RTC-based timekeeping
  • Interrupt-based wake from sleep
  • Free memory reporting (heap analysis)

Build

I developed under VS Code + Platformio on Windows. I test-compiled examples under the Arduino IDE (also Windows).

Testing

I've tested mostly on a generic black pill STM32F401CE (gateway, node using Ra-01 LoRa and nRF24L01+).
I encourage to test on a broader variety of boards.

Final note

The code has mostly been generated using AI. I asked for a comprehensive review of the previously mentioned three abandoned STM32 PRs and a comparison between building on STM32duino vs the original STM32Cube HAL. Both are feasible but the simplicity of the STM32duino solution stood out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant