Repository navigation
arch/arm/src/stm32n6: disable the USART while changing the line format - #21380
Merged
xiaoxiang781216 merged 1 commit intoNov 3, 2026
Merged
Conversation
xiaoxiang781216
previously approved these changes
Nov 2, 2026
|
stm32serial_setformat() writes BRR, CR2 STOP bits, and the PCE, PS, and M0/M1 bits of CR1 with the USART enabled. They can only be written while UE = 0 per the ST Reference Manual (RM0486), so a run-time tcsetattr() that changes baud rate, parity, or word length returned success but left the hardware USART registers unchanged. Clear UE around the update and restore it inside a critical section, matching the approved STM32L4 (commit 47180bf), STM32WB (PR apache#21334), STM32WL5 (PR apache#21336), STM32H7, and F7 implementations. Also fix pre-existing nxstyle alignment, declaration, and brace issues in stm32serial_pm_setsuspend, stm32serial_setapbclock, stm32serial_detach, stm32serial_interrupt, stm32serial_ioctl, and stm32serial_pmprepare. Fixes apache#21377 Signed-off-by: Swatantra Yadav <[email protected]> Assisted-by: Google Gemini
Swatantra-66
force-pushed
the
fix/stm32n6-serial-setformat-ue
branch
from
November 2, 2026 16:10
5d4f4e1 to
0f693f6
Compare
xiaoxiang781216
approved these changes
Nov 3, 2026
jerpelea
approved these changes
Nov 3, 2026
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
Fixes #21377
In
arch/arm/src/stm32n6/stm32_serial.c,stm32serial_setformat()writes the baud rate register (BRR),CR2STOP bits, and the parity/word length bits (PCE,PS,M0,M1) inCR1while the USART is enabled (UE = 1).Per the ST Reference Manual (RM0486), these registers/bits are write-protected and can only be written when the USART is disabled (
UE = 0). Consequently, run-timetcsetattr()calls attempting to change baud rate, parity, or word length return success (0) while leaving the hardware USART registers unchanged.This patch clears
USART_CR1_UEbefore the update and restores it upon completion inside a critical section, aligning the STM32N6 serial driver with the approved implementations in:47180bf5ea)0f22e12dd2)1cc41cbcb1)Also fixes pre-existing
nxstylecase indentation issues instm32serial_ioctl()and a comment typo instm32serial_rxint().Impact
tcsetattr()calls to change serial line speed, parity, or format on STM32N6 now correctly reconfigure the hardware USART peripheral instead of silently failing.Testing
Verified code logic against ST Reference Manual RM0486. Built cleanly. Verified
nxstylecompliance.