At least on ESP32, calling esp_rom_uart_set_clock_baudrate() causes the contents of the UART FIFO to be discarded.