rp2/machine_uart: Fix dropped UART REPL bytes on soft reset.

Necessary to fix "mpremote run" over hardware UART.

Bisect shows bug was introduced by d420b4e4, but looks like made more
complex by 01c046d2. Specifically: resetting and re-initialising the REPL
UART during soft reset clears the FIFO before it's done printing the "MPY:
soft reboot" line.

Fixed by adding a UART TX flush in the deinit path.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton 2024-09-26 10:32:04 +10:00 committed by Damien George
parent 43b05afdf5
commit 73feaaf931

View File

@ -458,6 +458,7 @@ static mp_obj_t mp_machine_uart_make_new(const mp_obj_type_t *type, size_t n_arg
} }
static void mp_machine_uart_deinit(machine_uart_obj_t *self) { static void mp_machine_uart_deinit(machine_uart_obj_t *self) {
uart_tx_wait_blocking(self->uart); // Flush TX FIFO if necessary
uart_deinit(self->uart); uart_deinit(self->uart);
if (self->uart_id == 0) { if (self->uart_id == 0) {
irq_set_enabled(UART0_IRQ, false); irq_set_enabled(UART0_IRQ, false);