← index #10898Issue #7485
Off-topic · high · value 0.621
QUERY · ISSUE

Interrupting soft reset (Ctrl-D) with Ctrl-C erases filesystem on Raspberry Pi Pico

openby connorclopened 2023-03-01updated 2023-03-01
bug

Sending a Ctrl-D to the MicroPython REPL to initiate a soft reset and then immediately issuing a Ctrl-C causes the entire filesystem to be erased on the Raspberry Pi Pico board. This issue was observed on 2 separate Pico boards across the following nightly builds (the 4 latest as of 01 March 2023):

However, the bug was not observed in the latest stable version 1.19.1.

Steps to reproduce

These steps were tested on a Linux host (Ubuntu 22.04).

First, load one of the above nightly versions of MicroPython onto a Raspberry Pi Pico board.

Next, using mpremote, install a library on the Pico’s filesystem, for example hashlib:

mpremote mip install hashlib

Then check that the library exists on the Pico’s filesystem:

mpremote fs ls /lib

This should show the hashlib folder:

ls :/lib
           0 hashlib/

Then, to send the required keystrokes (Ctrl-D followed by Ctrl-C), execute the following lines of Python on the Linux host machine to which the Pico is connected, replacing /dev/ttyACM0 with the serial port of the MicroPython REPL. This script requires pyserial.

import serial
s = serial.Serial('/dev/ttyACM0')
s.write(b'\x04') # Ctrl-D
s.write(b'\x03') # Ctrl-C
s.close()

Less precisely, the issue can also be reproduced by entering a REPL with mpremote and pressing Ctrl-D and Ctrl-C in rapid succession.

Then check the Pico’s filesystem once again:

mpremote fs ls

This should show that the lib folder and all files it contains have been removed:

ls :

This issue became evident because the visual studio code extension Pico-W-Go exhibits this behaviour when running a MicroPython file, issuing a Ctrl-D and Ctrl-C in rapid succession before running the given code. This issue has been reported on that project’s GitHub page here, suggesting it affects other nightly versions older than the 4 listed above.

CANDIDATE · ISSUE

mpremote with mount fails on ESP32

closedby peterhinchopened 2021-07-04updated 2022-02-07
tools

Re-installed mpremote today - tail end of pip3:

Successfully installed mpremote-0.0.5

ESP32 works OK, with ctrl-d resetting the ESP uneventfully if there is no mount.

With a mount, ctrl-d kills mpremote. In the following, when the REPL appeared I pressed ctrl-d:

>>> [adminpete@capybara]: ~/temp
$ mpremote mount .
Local directory . is mounted at /remote
Connected to MicroPython at /dev/ttyUSB0
Use Ctrl-] to exit this shell
>
MicroPython v1.16 on 2021-06-28; ESP32 module with ESP32
Type "help()" for more information.
>>> 
MPY: soft reboot
Traceback (most recent call last):
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/main.py", line 452, in main
    do_repl(pyb, args)
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/main.py", line 332, in do_repl
    do_repl_main_loop(
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/main.py", line 259, in do_repl_main_loop
    pyb.soft_reset_with_mount(console_out_write)
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/pyboardextended.py", line 612, in soft_reset_with_mount
    self.exec_(fs_hook_code)
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/pyboard.py", line 465, in exec_
    ret, ret_err = self.exec_raw(command, data_consumer=data_consumer)
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/pyboard.py", line 456, in exec_raw
    self.exec_raw_no_follow(command)
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/pyboard.py", line 453, in exec_raw_no_follow
    raise PyboardError("could not exec command (response: %r)" % data)
mpremote.pyboard.PyboardError: could not exec command (response: b'R\x01')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adminpete/.local/bin/mpremote", line 8, in <module>
    sys.exit(main())
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/main.py", line 455, in main
    do_disconnect(pyb)
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/main.py", line 208, in do_disconnect
    pyb.umount_local()
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/pyboardextended.py", line 620, in umount_local
    self.exec_('uos.umount("/remote")')
  File "/home/adminpete/.local/lib/python3.8/site-packages/mpremote/pyboard.py", line 467, in exec_
    raise PyboardError("exception", ret, ret_err)
mpremote.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 1, in <module>\r\nOSError: [Errno 22] EINVAL\r\n')

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