diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 74b7acde31..fc16be6c39 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -2473,6 +2473,20 @@ config SERIAL_TERMIOS If this is not defined, then the terminal settings (baud, parity, etc). are not configurable at runtime; serial streams cannot be flushed, etc.. +config SERIAL_DISABLE_REORDERING + bool "Disable reordering of ttySx devices." + depends on STM32_USART1 || STM32_USART2 || STM32_USART3 || STM32_UART4 || STM32_UART5 || STM32_USART6 || STM32_USART7 || STM32_USART8 + default n + ---help--- + NuttX per default reorders the serial ports (/dev/ttySx) so that the + console is always on /dev/ttyS0. If more than one UART is in use this + can, however, have the side-effect that all port mappings + (hardware USART1 -> /dev/ttyS0) change if the console is moved to another + UART. This is in particular relevant if a project uses the USB console + in some configs and a serial console in other configs, but does not + want the side effect of having all serial port names change when just + the console is moved from serial to USB. + endmenu config STM32_USART_SINGLEWIRE diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 52a77e2558..037ad07db8 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -2417,7 +2417,13 @@ void up_serialinit(void) #if CONSOLE_UART > 0 (void)uart_register("/dev/console", &uart_devs[CONSOLE_UART - 1]->dev); - (void)uart_register("/dev/ttyS0", &uart_devs[CONSOLE_UART - 1]->dev); + +#ifndef CONFIG_SERIAL_DISABLE_REORDERING + /* If not disabled, register the console UART to ttyS0 and exclude + * it from initializing it further down + */ + + (void)uart_register("/dev/ttyS0", &uart_devs[CONSOLE_UART - 1]->dev); minor = 1; /* If we need to re-initialise the console to enable DMA do that here. */ @@ -2425,6 +2431,7 @@ void up_serialinit(void) # ifdef SERIAL_HAVE_CONSOLE_DMA up_dma_setup(&uart_devs[CONSOLE_UART - 1]->dev); # endif +#endif /* CONFIG_SERIAL_DISABLE_REORDERING not defined */ #endif /* CONSOLE_UART > 0 */ @@ -2434,12 +2441,14 @@ void up_serialinit(void) for (i = 0; i < STM32_NUSART; i++) { +#ifndef CONFIG_SERIAL_DISABLE_REORDERING /* Don't create a device for the console - we did that above */ if ((uart_devs[i] == 0) || (uart_devs[i]->dev.isconsole)) { continue; } +#endif /* Register USARTs as devices in increasing order */