mpremote: enter_raw_repl: not working with micropython v1.26
Port, board and/or hardware
esp32-s3, mpremote
MicroPython version
micropython v1.26 with ESP32-S3
Reproduction
mpremote cp process_handler.py :/process_handler.py
Expected behaviour
Should copy
Observed behaviour
mpremote.transport.TransportError: could not enter raw repl
Additional Information
I observed that from being in raw REPL, you cannot initiate a reboot with CTRL-D any more like it was in earlier micropython version.
For reboot, you now need to leave the raw REPL with CTRL-A first before being able to reboot with CTRL-D.
So the behavior of enter_raw_repl in transport_serial.pymight need modification.
Code of Conduct
Yes, I agree
ports/unix: Add raw REPL support.
Summary
Add raw REPL support to the unix port. This make it possible to connect to a unix micropython instance using mpremote and utilise the functionality of the raw REPL. This is useful for debugging and CI tests of mpremote and related tools.
For example, one can run micropython behind a PTY with socat and connect to the slave pty (as if it were a serial port) with mpremote:
socat PTY,link=$HOME/.upy-pty,rawer EXEC:./build-standard/micropython,pty,stderr,onlcr=0 &
mpremote resume connect ~/.upy-pty ls
(The resume argument is required since micropython v1.24 as a soft reset terminates the micropython process).
or, using the micropython docker image (thanks to @mattytrentini ):
socat PTY,link=$HOME/.upy-pty,rawer EXEC:"docker run -ti --rm micropython/unix\:v1.23.0",pty,stderr,onlcr=0
Testing
This has been tested using private CI workflows adapted from those in the mpremote-path tool (which uses mpremote as a library).
Trade-offs and Alternatives
The changes impact only the unix port (adding pyexec.c to the build) and present a user-visible change through behaviour when a ctrl-A character is entered at the repl. However, this reflects expected behaviour on other ports and should not impact on expected or supported usage.