[BUG] arch/arm/stm32n6: USART hardware format and baud rate changes silently ignored at runtime (UE not disabled)
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #21380 của @Swatantra-66 — đã merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
- Lĩnh vực
- embedded-iot, operating-systems
Hướng nghiên cứu
The change belongs in stm32serial_setformat() in arch/arm/src/stm32n6/stm32_serial.c, which writes BRR, CR1 and CR2 while the USART may still be enabled. Compare it with the STM32L4 implementation the issue cites, which shows the expected UE save, clear and restore pattern inside enter_critical_section()/leave_critical_section(). Done means UE is cleared before the register writes, its previous state is restored afterwards, and a runtime tcsetattr() change takes effect on hardware. A linked pull request (#21380) already exists, so review it before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
In arch/arm/src/stm32n6/stm32_serial.c, stm32serial_setformat() updates the baud rate register (BRR), CR2 STOP bits, and the PCE, PS, M0, and M1 bits of CR1 without first clearing the USART enable bit (UE = 0).
Per the STMicroelectronics STM32N6 Reference Manual (RM0486), the baud rate register and line control bits in CR1 and CR2 are write-protected while the USART is enabled (UE = 1). Consequently, any runtime tcsetattr() call attempting to change baud rate, parity, word length, or stop bits returns 0 (Success), but the hardware USART registers silently remain unchanged.
Additionally, stm32serial_setformat() lacks critical section protection (enter_critical_section() / leave_critical_section()), leaving register modifications vulnerable to concurrent interrupts.
Steps to Reproduce
- Configure and boot a board using the STM32N6 USART driver (e.g.
nucleo-n657x0-q:nshorstm32n6570-dk:nsh). - From user space or NSH, open the serial port and attempt to reconfigure baud rate or framing at runtime via
tcsetattr(fd, TCSANOW, &termios). - Notice that
tcsetattr()returns success (OK), but the hardware continues transmitting/receiving with the initial boot baud rate and framing.
Expected Behavior
stm32serial_setformat() should:
- Enter a critical section (
enter_critical_section()). - Read
CR1, preserve the currentUSART_CR1_UEstate, and clearUSART_CR1_UE. - Apply the updated
BRR,CR1,CR2, andCR3settings whileUE = 0. - Restore
USART_CR1_UEto its previous state. - Exit the critical section (
leave_critical_section()).
This aligns STM32N6 with the approved implementations in STM32L4 (commit 47180bf5ea), STM32WB (PR #21334), STM32WL5 (PR #21336), STM32H7, and STM32F7.
Additional Context
I have verified the root cause and have a tested patch ready to submit
On which OS does this issue occur?
[OS: Linux]
What is the version of your OS?
Ubuntu 22.04 / Linux
NuttX Version
master
Issue Architecture
[Arch: arm]
Issue Area
[Area: Drivers]
Host information
No response
Verification
- I have verified before submitting the report.
- Ngôn ngữ chính
- C
- Star
- 4.1k
- Fork
- 1.8k
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 843
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/nuttx
-
Please rerun `pre-commit run -a`Đang mởArch: all Arch: arm Area: Build system OS: Linux Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/nuttx#19435 · 8 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apache/nuttx#17343 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Arch: all OS: Linux Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/nuttx#16249 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] fs/vfs: missing POSIX iovcnt bounds and iov_len overflow validation in readv/writevCó thể đã có người làm @Swatantra-66 đã nhận hôm nay. Đang mởArch: all Area: Posix OS: Linux Type: Bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
flac's CMake config is brokenĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
msys2/MINGW-packages#33356 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
kmod-project/kmod#492 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PecanProject/sipnet#435 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
SDL_GPU Vulkan: wrong screen orientation on OpenHarmony (preTransform set without pre-rotation)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
libsdl-org/SDL#16670 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100