Setting #uart parity to 'even' with #stm32 using device tree #uart #stm32


Hello all,

I have been doing development with stm32f103 (blue-pill) board - and it has the system bootloader burned in. The bootloader uses settings 115200, 1 stop, even parity [1]. I would like to change my "normal" uart settings accordingly. I tried googling for device tree bindings, but it seems like there is no bindings for parity at device-tree level?

If device tree has no support for parity - i guess it is OK to re-initialize the uart with proper settings in early "application" main() ?

Long story:

I have successfully flashed the device with UART_1 using over wire and wireless. Now final aim is to do firmware upgrade with the system bootloader over bluetooth by connecting HC-05 to the serial port and enter the bootloader programatically (by writing certain value to backup-registers, and checking that value on early boot). It shall require (for simplicity) that "normal mode" and "bootloader mode" shall use same uart settings. I tested that flashing over bluetooth seems to work ( but is painfully slow ).

[1] St / AN3155



Dear all,

if somebody tumbles here with google about the parity, i found no way to do it from device tree, but 8-databits, even parity, 1 stopbit seems to work in my case with patch pasted below. There are devicetree bindings on the same file, but nothing regarding the parity (i could make pull for this single case, but i guess the modifications should go to serial-device tree bindings, and that sounds like larger pull that i am afraid i do not have time).

Also, ror the record: with this setup one can use HC-05 with stm32_min_dev board, and with burned in st-system bootloader one can achive "update over bluetooth" using shell command to enter bootloader (writes to backup registers that next reset jump to bootloader, followed by system reset) -- and then closes command terminal and runs over bluetooth.


diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c
index 3d0dd1ca84..03948225a0 100644
--- a/drivers/serial/uart_stm32.c
+++ b/drivers/serial/uart_stm32.c
@@ -671,8 +671,8 @@ static int uart_stm32_init(struct device *dev)
        /* 8 data bit, 1 start bit, 1 stop bit, no parity */
-                                LL_USART_DATAWIDTH_8B,
-                                LL_USART_PARITY_NONE,
+                                LL_USART_DATAWIDTH_9B,
+                                LL_USART_PARITY_EVEN,
        if (config->hw_flow_control) {