[BUG] arch/arm/stm32n6: USART hardware format and baud rate changes silently ignored at runtime (UE not disabled)
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #21380 de @Swatantra-66 — fusionado
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 4.1k
- Forks
- 1.7k
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 836
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/nuttx
-
Please rerun `pre-commit run -a`AbiertoArch: all Arch: arm Area: Build system OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/nuttx#19435 · 8 comentarios ·
Los mantenedores suelen responder en 1 día
-
Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
apache/nuttx#17343 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Arch: all OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/nuttx#16249 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
-
Type: Enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de apache/nuttx
Issues similares
-
Properties side panel changes width when switching panels (MOs wider, Density Profile narrower)Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
FriendsofECCE/ECCE#843 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 63/100
HandBrake/HandBrake#8238 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Integer overflow → heap out-of-bounds write in `contrib/pngminus/pnm2png.c` via crafted PNM widthAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
meshcore-dev/MeshCore#3760 · 1 comentario ·
Los mantenedores suelen responder en 1 día