Skip to content

Initial support for STM32H743/H745 CPUs#5376

Merged
deadprogram merged 2 commits into
tinygo-org:devfrom
helvionics:de_stm32h7_support
Jul 23, 2026
Merged

Initial support for STM32H743/H745 CPUs#5376
deadprogram merged 2 commits into
tinygo-org:devfrom
helvionics:de_stm32h7_support

Conversation

@digitalentity

@digitalentity digitalentity commented May 8, 2026

Copy link
Copy Markdown
Contributor

This PR adds base support for the STM32H7 series, specifically targeting STM32H743 and STM32H745.

  1. Runtime & System Setup
  • Clock Tree: Implements clock configuration in runtime_stm32h7.go.
    • HSE (8MHz) as source.
    • PLL1 configured for 400MHz SYSCLK.
    • PLL2 configured for 80MHz ADC kernel clock.
    • HSI48 enabled for USB and RNG.
  • MPU & Cache: Introduced runtime_stm32h7_mpu.go to manage the Memory Protection Unit.
    • Enables L1 Instruction and Data Caches.
    • Configures memory regions (Flash: Write-Through, AXI SRAM: Write-Back) for better performance.
  • Linker & Target: Added targets/stm32h7.ld and targets/stm32h743.json.
  1. Peripheral Support
  • ADC: Added 16-bit ADC support with calibration and H7-specific channel mapping.
  • Window Watchdog (WWDG): Added a new WindowWatchdog API specifically for H7, providing protection against runaway code.
  • USB: Initial support for USB OTG FS (Full Speed) with CDC/Serial integration.
  • GPIO/EXTI: Integration with existing STM32 GPIO and external interrupt logic.
  1. Examples
  • src/examples/wwdg: a new cross-platform example demonstrating the Window Watchdog.
  • src/examples/pwm/nucleo-h743zi.go: pin mapping for PWM on the Nucleo-H743 board.
  • src/examples/blinky1/blinky1.go: verified to work.
  • src/examples/echo/echo.go: verified to work over USB CDC and UART1

Disclaimer: A significant amount of this PR is AI-generated with human supervision and review.

Fixes #5369

@digitalentity
digitalentity force-pushed the de_stm32h7_support branch 2 times, most recently from 56a38a8 to 5b2e643 Compare July 12, 2026 18:40
@digitalentity
digitalentity marked this pull request as ready for review July 12, 2026 18:41
@digitalentity

Copy link
Copy Markdown
Contributor Author

@deadprogram this is now ready

@knieriem

Copy link
Copy Markdown
Contributor

This looks interesting.
I would suggest to move the MPU definitions to device/arm, as it seems a standard Cortex-M feature.
To you think that makes sense? (Please compare to my commit 6401fd9, where this has been done).

BTW, I have been working on the H7 too, with the focus on basic support (and ETH) for H723 and H757_cm7. I hope it can be merged with your changes, esp. with the H723 being a smaller variant.
Along those lines, I am currently extending the G0B1 FDCAN support to H7x7 (it is running since yesterday, but i need to prepare commits and restructure stuff).
(There is more previous work at #1829, especially targeting the H747.)


On a broader note regarding STM32 support in TinyGo:
When implementing support for G031/71 and H7, I noticed some difficulties regarding peripheral clock
configuration flexibility (in reality, projects need different configurations, some run from HSI, some from HSE, at different speeds -- I think MPU configuration needs to be per-project as well, as different project may need different settings) and different sets of supported peripherals in one MCU family, perhaps you encountered some of them too. For example, if support is implemented for G0B1 or U585, it is not easy to add support for smaller variants of these families, like G031 or U545, as they have a more limited peripheral set; build would fail, one needs to fallback to new build variants files, with lots of code duplication. I think, generally, some restructuring, perhaps code generation, is needed -- see knieriem/tinygo/#1 for a tracking issue.

@digitalentity

digitalentity commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

I would suggest to move the MPU definitions to device/arm, as it seems a standard Cortex-M feature.
To you think that makes sense? (Please compare to my commit 6401fd9, where this has been done).

If this is a standard Cortex-M feature, I think it belongs to the arm package. I need to check if it is indeed a standard feature.

I think this PR is somewhat more mature than dev...knieriem:tinygo:stm32-h7, maybe try rebasing your code on top of this PR? This PR was heavily inspired by https://github.com/ardnew/tinygo/tree/feature/usb-common-arduino-portenta (which seems to be abandoned), but I was focusing on the M7 core and ignoring the M4 core for now.

@digitalentity

Copy link
Copy Markdown
Contributor Author

On a broader note regarding STM32 support in TinyGo:

I think the bigger issue is that there is no way to inject the project-specific machine package without modifying the TinyGo source. Being able to inject or override the custom machine package would immediately solve many issues related to project-specific configurations.

@deadprogram

Copy link
Copy Markdown
Member

@digitalentity can you please add smoke tests for new boards to https://github.com/tinygo-org/tinygo/blob/dev/GNUmakefile#L600

@digitalentity

Copy link
Copy Markdown
Contributor Author

@deadprogram done and rebased.

@deadprogram

Copy link
Copy Markdown
Member

Thank you very much @digitalentity

This PR would be great as 2 commits:

  • adds the ARM v7-M support 1ae8b50
  • adds the stm32hxxxx

Does not have to be a separate PR, but that would make these changes a lot more atomic. What do you think?

@digitalentity

Copy link
Copy Markdown
Contributor Author

Done

@deadprogram

Copy link
Copy Markdown
Member

Thank you @digitalentity now merging!

@deadprogram
deadprogram merged commit 3797e89 into tinygo-org:dev Jul 23, 2026
20 checks passed
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.

Support for STM32H7xx family CPUs

3 participants