Skip to content

arch/arm/stm32: disable UE in stm32_serial_m0_v3 setformat - #21892

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Wooohaaa:fix/stm32f0-setformat-ue
Nov 17, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
Wooohaaa:fix/stm32f0-setformat-ue

Conversation

@Wooohaaa

Copy link
Copy Markdown
Contributor

Summary

stm32serial_setformat() in stm32_serial_m0_v3.c (used by F0 boards
such as nucleo-f072rb) writes the parity and word-length bits in CR1
(PCE, PS, M0/M1) with UE = 1. On USART v2 and later, these bits can
only be written while UE = 0, so tcsetattr(8E1) returns 0 but the
parity and word length do not change.

Change

Test plan

  • Built nucleo-f072rb:nsh with arm-none-eabi-gcc; the serial driver
    compiles cleanly.
  • Not tested on hardware (no F0 board available).
  • The change is gated on CONFIG_SUPPRESS_UART_CONFIG being undefined,
    matching the existing code.

Fixes #20969

On USART v2 and later, the parity and word-length bits in CR1 (PCE, PS,
M0/M1) can only be written while UE = 0. stm32serial_setformat() in
stm32_serial_m0_v3.c (used by F0 boards such as nucleo-f072rb) wrote
CR1 with UE = 1, so tcsetattr(8E1) returned 0 but the parity and word
length did not change.

Follow the pattern already used by the L4 (apache#20914) and WB (apache#21334)
drivers: enter a critical section, save and clear UE, configure the
format bits, then restore UE.

Built nucleo-f072rb:nsh with arm-none-eabi-gcc; the serial driver
compiles cleanly. Not tested on hardware.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash

Fixes apache#20969
@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@xiaoxiang781216
xiaoxiang781216 merged commit 880dbc6 into apache:master Nov 17, 2026
29 of 31 checks passed
@darrylring

Copy link
Copy Markdown
Contributor

These changes need to be tested on hardware. They cause a crash on boot: #21903

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

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arch/arm/stm32: serial setformat writes CR1 parity/word-length bits with UE=1 in several drivers

4 participants