Skip to content

STM32L4: Support more UARTs#41

Open
xarantolus wants to merge 2 commits intomainfrom
feature/more-uarts
Open

STM32L4: Support more UARTs#41
xarantolus wants to merge 2 commits intomainfrom
feature/more-uarts

Conversation

@xarantolus
Copy link
Contributor

@xarantolus xarantolus commented Mar 26, 2026

This MR adds support for more UARTs (all the STM32L4 family has).

I have tested all UARTs' TX by using an USB to TTL CH340 bridge (3.3V), except for USART1 (this one is a bit weird, as on the Nucleo board the pin PA9, which would be tx, is not exposed) and LPUART1 (obviously this is directly available via the Nucleo USB connection).

Then I configured that UART as debug output, and had a program just print in a loop:

loop {
    osiris::syscall_print(0, "Hello World!".as_bytes().as_ptr(), 12);
}

Then on Linux, get the output of the TTL connector:

stty -F /dev/ttyUSB0 115200 raw && cat /dev/ttyUSB0

I'm not sure if we always want to set the mode, pull and speed this way (makes sense for output, may make less sense for other use cases like sensor drivers), but I'd leave it like that for now.

Also note the pin change for LPUART1, where the RX pin was wrong. PG7 is tx, PG8 is rx. So we keep the same tx pin (that's why output worked before) - see page 100 here.

Copilot AI review requested due to automatic review settings March 26, 2026 18:08
@github-actions
Copy link

LCOV of commit f0c1e65 during Osiris CI #349

Total coverage: 14.04%

lcov: WARNING: lcov: WARNING: RC option 'lcov_branch_coverage' is deprecated.  Consider using 'branch_coverage. instead.  (Backward-compatible support will be removed in the future
Summary coverage rate:
  lines......: 14.0% (232 of 1653 lines)
  functions..: 16.7% (39 of 233 functions)
  branches...: no data found

Files changed coverage rate: n/a

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands the STM32L4 debug-UART selection to cover additional UART/USART peripherals and wires up the corresponding RCC + GPIO configuration in the STM32L4 HAL interface layer.

Changes:

  • Extend debug.uart allowed values to include USART1/2/3 and UART4 (in addition to UART5 and LPUART1).
  • Update HAL_UART_MspInit to initialize clocks and pins for the newly supported UART instances.
  • Fix LPUART1 pin mapping to use PG7 (TX) / PG8 (RX).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
options.toml Expands the selectable debug UART peripherals.
machine/arm/stm32l4xx/interface/uart.c Adds MSP init support for additional USART/UART instances and corrects LPUART1 RX pin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants