docs: No instructions for REPL over UART on RP2
Documentation URL
https://docs.micropython.org/en/latest/rp2/quickref.html
Description
On the UART documentation page, there is a note:
REPL over UART is disabled by default. You can see the Getting started with MicroPython on the RP2xxx for details on how to enable REPL over UART.
If you follow the link to the "getting started" page (https://docs.micropython.org/en/latest/rp2/tutorial/intro.html#rp2-intro), it just says:
Getting started with MicroPython on the RP2xxx
Let’s get started!
I can't seem to find any instructions for accessing the REPL over UART (i.e. which UART pins, and how to configure Micropython).
Code of Conduct
Yes, I agree
rp2: Fix dropped UART REPL bytes on soft reset.
Summary
Necessary to fix "mpremote run" over hardware UART (i.e. when MICROPY_HW_ENABLE_UART_REPL is set).
Bisect shows bug was introduced by d420b4e4 (#13718), but looks like made more complex by 01c046d2 (#14041). 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.
Testing
- Build rp2 port with
MICROPY_HW_ENABLE_UART_REPLset. - Open interactive REPL and type Ctrl-D. Note the "MPY: soft reboot" line is not printed, only one invalid character is received.
- Alternatively, try to use "mpremote run" over the hardware UART. It times out waiting for the "soft reboot" line.
Fails without this PR, works with this PR.
Trade-offs and Alternatives
- Alternative would be to not reset the REPL UART on soft reset. This may be better from the "principle of least surprise" point of view (i.e. if the user hasn't changed the UART settings then it makes no difference, and if they have changed them then having Soft Reboot change them and lose the REPL seems a bit unexpected.) However doing it that way has less clean layering, as the machine.UART code would need to know about the REPL configuration.