← index #18875PR #15914
Off-topic · high · value 4.367
QUERY · ISSUE

docs: No instructions for REPL over UART on RP2

openby MarcelloTheArcaneopened 2026-02-26updated 2026-03-04
docs

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

CANDIDATE · PULL REQUEST

rp2: Fix dropped UART REPL bytes on soft reset.

mergedby projectgusopened 2024-09-26updated 2024-09-26
port-rp2

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

  1. Build rp2 port with MICROPY_HW_ENABLE_UART_REPL set.
  2. Open interactive REPL and type Ctrl-D. Note the "MPY: soft reboot" line is not printed, only one invalid character is received.
  3. 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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied