Skip to content

Commit

Permalink
stm32: disable overrun
Browse files Browse the repository at this point in the history
This was found on the Mantis where the following happened:
1. Boot command is sent to a bootloader without a firmware flashed.
2. After boot command, there is a 100 ms delay.
3. During that time, more data is sent to the bootloader causing an
   overrun.
4. Without overrun disabled, this will set the ORE flag, and
   reads will fail because RXNE is not set.

By disabling the overrun flag we can recover from an overrun.
  • Loading branch information
julianoes authored and davids5 committed Nov 24, 2021
1 parent 2e13d53 commit d487c4c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stm32/usart.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ uart_cinit(void *config)
usart_set_parity(usart, USART_PARITY_NONE);
usart_set_flow_control(usart, USART_FLOWCONTROL_NONE);

#ifdef USART_CR3_OVRDIS
/* Disable overrun. Otherwise, an overrun leads to the situation where
* we can't read from a UART anymore. */
USART_CR3(usart) |= USART_CR3_OVRDIS;
#endif

/* and enable */
usart_enable(usart);

Expand Down

0 comments on commit d487c4c

Please sign in to comment.