You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Paste mode hangs ESP32 TTGO with FS mounted via mpremote #7731
% mpremote connect /dev/tty.usbserial-XXXXXX mount . repl
Local directory . is mounted at /remote
Connected to MicroPython at /dev/tty.usbserial-XXXXXX
Use Ctrl-] to exit this shell
>
MicroPython v1.15-835-g1fcd6e97f-dirty on 2021-08-27; ESP32 module with ESP32
Type "help()" for more information.
>>> import gc
>>> gc.collect()
>>> gc.mem_free()
104976
>>> import lvgl as lv
>>> lv
<module 'lvgl'>
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== print(15)
===
15
>>>
Hangs here, and reports:
>>> b''
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 445, in main
do_repl(pyb, args)
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 332, in do_repl
do_repl_main_loop(
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 259, in do_repl_main_loop
pyb.soft_reset_with_mount(console_out_write)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboardextended.py", line 613, in soft_reset_with_mount
self.exec_("__mount(%s)" % (self.dev_out is not None))
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 465, in exec_
ret, ret_err = self.exec_raw(command, data_consumer=data_consumer)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 457, in exec_raw
return self.follow(timeout, data_consumer)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 367, in follow
raise PyboardError("timeout waiting for first EOF reception")
mpremote.pyboard.PyboardError: timeout waiting for first EOF reception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/mpremote", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 455, in main
do_disconnect(pyb)
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 207, in do_disconnect
pyb.enter_raw_repl(soft_reset=False)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 355, in enter_raw_repl
raise PyboardError("could not enter raw repl")
mpremote.pyboard.PyboardError: could not enter raw repl
I can replicate this on the reference board, running today's firmware. The paste mode works, but then the ESP32 hangs before producing a dump similar to yours.
I have found this occurs at other times, for example on failed imports from /remote, so it seems to be more of a general issue than just paste mode.
^[[C
b'\r\n\x18\x01'
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 445, in main
do_repl(pyb, args)
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 332, in do_repl
do_repl_main_loop(
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 259, in do_repl_main_loop
pyb.soft_reset_with_mount(console_out_write)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboardextended.py", line 612, in soft_reset_with_mount
self.exec_(fs_hook_code)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 465, in exec_
ret, ret_err = self.exec_raw(command, data_consumer=data_consumer)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 456, in exec_raw
self.exec_raw_no_follow(command)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 423, in exec_raw_no_follow
raise PyboardError("could not enter raw repl")
mpremote.pyboard.PyboardError: could not enter raw repl
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/mpremote", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 455, in main
do_disconnect(pyb)
File "/usr/local/lib/python3.9/site-packages/mpremote/main.py", line 207, in do_disconnect
pyb.enter_raw_repl(soft_reset=False)
File "/usr/local/lib/python3.9/site-packages/mpremote/pyboard.py", line 355, in enter_raw_repl
raise PyboardError("could not enter raw repl")
mpremote.pyboard.PyboardError: could not enter raw repl
I can see the problem: ctrl-D is intercepted by the terminal handling loop (on the PC) and if mpremote mount is active then it sends ctrl-D to the board followed by re-executing of the remote mounting code. It thinks that the ctrl-D did a soft reset, but it just ended the paste mode and now the PC is mounted twice on the board, leading to problems.
I think a decent fix would be for it to wait for MPY: soft reboot after passing through the ctrl-D, and only re-execute the mount code if it sees that string.
Well, ctrl-D can be sent in many different places, eg while entering text to delete the current character. So mpremote would need to be very aware of the current state. I'd say that's too difficult/flaky to do.
Ah good point, yeah it's a wider problem than just raw mode. I guess a background task in mpremote that handles serial read and watches the stream for important markers could really help mpremote keep in sync with the device
Activity
peterhinch commentedon Aug 31, 2021
I can replicate this on the reference board, running today's firmware. The paste mode works, but then the ESP32 hangs before producing a dump similar to yours.
peterhinch commentedon Aug 31, 2021
I have also reproduced this on a Pyboard D SF6W.
jdtsmith commentedon Aug 31, 2021
I have found this occurs at other times, for example on failed imports from /remote, so it seems to be more of a general issue than just paste mode.
jdtsmith commentedon Aug 31, 2021
May be related to #7732
peterhinch commentedon Dec 22, 2021
In my experience paste mode always crashes on a RP2 Pico if
mpremoteis issued with$ mpremote mount .It has caught me out numerous times and seems entirely repeatable.
It also leaves the REPL unresponsive on a Pyboard 1.1.
peterhinch commentedon Feb 4, 2022
Also happens on a Pyboard:
While this works, the Pyboard is in an unstable state with the REPL unresponsive. Then, after a while and with no user input, this happens:
dpgeorge commentedon Feb 4, 2022
I can see the problem: ctrl-D is intercepted by the terminal handling loop (on the PC) and if
mpremote mountis active then it sends ctrl-D to the board followed by re-executing of the remote mounting code. It thinks that the ctrl-D did a soft reset, but it just ended the paste mode and now the PC is mounted twice on the board, leading to problems.dpgeorge commentedon Feb 4, 2022
I think a decent fix would be for it to wait for
MPY: soft rebootafter passing through the ctrl-D, and only re-execute the mount code if it sees that string.andrewleech commentedon Feb 4, 2022
Ah that makes sense! Shouldn't mpremote be aware if the board should be in raw mode and skip the soft reboot hooks?
dpgeorge commentedon Feb 4, 2022
Well, ctrl-D can be sent in many different places, eg while entering text to delete the current character. So mpremote would need to be very aware of the current state. I'd say that's too difficult/flaky to do.
andrewleech commentedon Feb 4, 2022
Ah good point, yeah it's a wider problem than just raw mode. I guess a background task in mpremote that handles serial read and watches the stream for important markers could really help mpremote keep in sync with the device
tools/mpremote: Fix special handling of ctrl-D when host FS is mounted.
dpgeorge commentedon Feb 5, 2022
See #8265 for a fix.
peterhinch commentedon Feb 5, 2022
Excellent! Tested on Pyboard 1.1 and RP2 Pico.
dpgeorge commentedon Feb 6, 2022
Thanks for testing!
tools/mpremote: Fix special handling of ctrl-D when host FS is mounted.
dpgeorge commentedon Feb 7, 2022
Fixed by fecfd52
Merge pull request micropython#7731 from kreasteve/statemachine_run_fix
tools/mpremote: Fix special handling of ctrl-D when host FS is mounted.
tools/mpremote: Fix special handling of ctrl-D when host FS is mounted.