Repository navigation
arch/arm/stm32: disable UE in stm32_serial_m0_v3 setformat - #21892
Merged
Merged
Conversation
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
Wooohaaa
requested review from
acassis,
davids5,
jerpelea and
xiaoxiang781216
as code owners
November 16, 2026 15:47
xiaoxiang781216
approved these changes
Nov 16, 2026
|
This was referenced Nov 17, 2026
GUIDINGLI
approved these changes
Nov 17, 2026
Contributor
|
These changes need to be tested on hardware. They cause a crash on boot: #21903 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stm32serial_setformat()instm32_serial_m0_v3.c(used by F0 boardssuch 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 theparity and word length do not change.
Change
arch/arm/src/common/stm32/stm32_serial_m0_v3.c: enter a criticalsection, save and clear UE before configuring the format bits, then
restore UE. Follows the pattern from the L4 (arch/arm/src/stm32l4: disable the USART while changing the line format #20914) and WB (arch/arm/src/stm32wb: disable the USART while changing the line format #21334)
drivers.
Test plan
nucleo-f072rb:nshwith arm-none-eabi-gcc; the serial drivercompiles cleanly.
CONFIG_SUPPRESS_UART_CONFIGbeing undefined,matching the existing code.
Fixes #20969