Skip to content

Pi Pico-Filesystem (CIRCUITPY) mounted Read-Only for versions >= v9 on Debian 11.10 #9384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BusterRaid opened this issue Jun 29, 2024 · 36 comments
Labels
bug rp2040 Raspberry Pi RP2040 usb
Milestone

Comments

@BusterRaid
Copy link

BusterRaid commented Jun 29, 2024

CircuitPython version

Version en-GB-8.1.0 is mounted read-write.
Version en-GB-8.2.10 is mounted read-write.
Version en_GB-9.0.0-beta is mounted read-only.
Version en_GB-9.0.5 is mounted read-only.
Version en_GB-20240626-main-PR9375-396aaef (latest at test) is mounted read-only.

Code/REPL

N/A.

Behavior

When using CircuitPython >= v9 on Raspberry Pi Pico, the file system (CIRCUITPY) is mounted Read-Only when the Pico is connected to a Raspberry Pi Desktop Debian 11.10 virtual machine.

Versions 8.x of CircuitPython seem to mount the file system (CIRCUITPY) as read-write.

(This is is possibly due to the age of my system or my inexperiance with CircuitPython/Pico.)

I did notice the one of the versions that loaded RO had the following in journalctl, which did not appear in the RW mounted version.

Jun 29 15:23:32 XRCERIUM mtp-probe[5152]: checking bus 2, device 16: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1"
Jun 29 15:23:32 XRCERIUM mtp-probe[5152]: bus: 2, device: 16 was not an MTP device
Jun 29 15:23:32 XRCERIUM systemd-udevd[5147]: mouse3: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-udevd[5151]: event7: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-logind[487]: Watching system buttons on /dev/input/event7 (Raspberry Pi Pico Consumer Control)
Jun 29 15:23:32 XRCERIUM systemd-udevd[5156]: event6: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-udevd[5165]: event5: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-logind[487]: Watching system buttons on /dev/input/event5 (Raspberry Pi Pico Keyboard)
Jun 29 15:23:32 XRCERIUM mtp-probe[5173]: checking bus 2, device 16: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1"
Jun 29 15:23:32 XRCERIUM mtp-probe[5173]: bus: 2, device: 16 was not an MTP device
Jun 29 15:23:32 XRCERIUM pulseaudio[1095]: Failed to find a working profile.
Jun 29 15:23:32 XRCERIUM pulseaudio[1095]: Failed to load module "module-alsa-card" (argument: "device_id="1" name="usb-Raspberry_Pi_Pico_E66038B713777233-04" card_name="alsa_card.usb-Raspberry_Pi_Pico_E66038B713777233-04" >

Description

N/A.

Additional information

Environment:

  • Raspberry Pi Pico (not W):

No modifications.

  • VM hypervisor/host:

Dell 490 Precision.
Intel 5000X (Greencreek) + 631x/6321 ESB2
Dual Intel Xeon 5160
Microsoft Windows 10 Professional (x64) Build 19045.4529 (22H2

  • VM Guest:

Raspberry Pi Desktop.
Debian 11.10 Bullseye
Linux XRCERIUM 5.10.0-15-amd64 #1 SMP Debian 5.10.120-1 (2022-06-09) x86_64 GNU/Linux

/bin/ls: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=00695414aa5413c8667e62c2362d119cb233a504, for GNU/Linux 3.2.0, stripped

  • Hypervisor:

VMware Player 12.5.9 - Most recent version that will run on host's chipset.

Testing (method):

  • VM guest suspended.
  • Pico plugged in to host ready for firmware loading.
  • "flash_nuke.uf2" loaded.
  • Target firmware/CircuitPython loaded.
  • Ejected from host.
  • Connected to host.
  • Test that "copy.py" is R/W via host - Always OK.
  • VM guest opened from suspend.
  • Pico connected to guest from host.
    • Note: Prior to connection to the VM, the icon in the VM tool bar looks like a web cam, not a storage device.
    • Once connected to the VM "Connect (Disconnect from host)" it appears as a speaker icon.
  • "Mu" development environment opened.
  • Attempt to change "code.py" made, via "Mu"
  • Some information gathered from guest.
  • Pico removed from guest (back to host).
  • "Mu" closed.
  • VM guest suspended.
  • Test that "copy.py" is R/W via host - Works for 8.x, fails for 9.x64
  • Pico ejected from host.

Testing (detail):

Version: adafruit-circuitpython-raspberry_pi_pico-en_GB-8.1.0.uf2:
Can write to file system (code.py) OK in VM (Raspberry Pi Desktop Bullseye).

  • "mount" output for Pico:

/dev/sdb1 on /media/pi/CIRCUITPY type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

  • dmesg (On connection of Pico to VM):

[ 2631.666209] systemd-journald[313]: Received client request to rotate journal.
[ 2631.735924] systemd-journald[313]: Vacuuming done, freed 0B of archived journals from /var/log/journal/b81c0c47b8274aeebb400a9f02934605.
[ 2714.812654] usb 2-2.1: new full-speed USB device number 16 using uhci_hcd
[ 2715.168416] usb 2-2.1: New USB device found, idVendor=239a, idProduct=80f4, bcdDevice= 1.00
[ 2715.168423] usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2715.168483] usb 2-2.1: Product: Pico
[ 2715.168486] usb 2-2.1: Manufacturer: Raspberry Pi
[ 2715.168488] usb 2-2.1: SerialNumber: E66038B713777233
[ 2715.192169] cdc_acm 2-2.1:1.0: ttyACM0: USB ACM device
[ 2715.224008] usb-storage 2-2.1:1.2: USB Mass Storage device detected
[ 2715.245105] scsi host3: usb-storage 2-2.1:1.2
[ 2715.289409] input: Raspberry Pi Pico Keyboard as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000E/input/input43
[ 2715.351780] input: Raspberry Pi Pico Mouse as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000E/input/input44
[ 2715.351997] input: Raspberry Pi Pico Consumer Control as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000E/input/input45
[ 2715.354939] hid-generic 0003:239A:80F4.000E: input,hidraw1: USB HID v1.11 Keyboard [Raspberry Pi Pico] on usb-0000:02:00.0-2.1/input3
[ 2716.279965] scsi 3:0:0:0: Direct-Access Raspberr Pico 1.0 PQ: 0 ANSI: 2
[ 2716.282047] sd 3:0:0:0: Attached scsi generic sg2 type 0
[ 2716.323858] sd 3:0:0:0: [sdb] 2049 512-byte logical blocks: (1.05 MB/1.00 MiB)
[ 2716.341907] sd 3:0:0:0: [sdb] Write Protect is off
[ 2716.341914] sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 2716.359746] sd 3:0:0:0: [sdb] No Caching mode page found
[ 2716.359775] sd 3:0:0:0: [sdb] Assuming drive cache: write through
[ 2716.465419] sdb: sdb1
[ 2716.579146] sd 3:0:0:0: [sdb] Attached SCSI removable disk

  • journalctl (On connection of Pico to VM):

-- Journal begins at Sat 2024-06-29 15:22:08 BST, ends at Sat 2024-06-29 15:23:34 BST. --
Jun 29 15:22:08 XRCERIUM systemd-journald[313]: System Journal (/var/log/journal/b81c0c47b8274aeebb400a9f02934605) is 16.0M, max 1.8G, 1.7G free.
Jun 29 15:22:12 XRCERIUM dhcpcd[604]: eth0: no IPv6 Routers available
Jun 29 15:22:34 XRCERIUM systemd-timesyncd[459]: Initial synchronization to time server 162.159.200.1:123 (3.debian.pool.ntp.org).
Jun 29 15:23:31 XRCERIUM kernel: usb 2-2.1: new full-speed USB device number 16 using uhci_hcd
Jun 29 15:23:32 XRCERIUM kernel: usb 2-2.1: New USB device found, idVendor=239a, idProduct=80f4, bcdDevice= 1.00
Jun 29 15:23:32 XRCERIUM kernel: usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 29 15:23:32 XRCERIUM kernel: usb 2-2.1: Product: Pico
Jun 29 15:23:32 XRCERIUM kernel: usb 2-2.1: Manufacturer: Raspberry Pi
Jun 29 15:23:32 XRCERIUM kernel: usb 2-2.1: SerialNumber: E66038B713777233
Jun 29 15:23:32 XRCERIUM kernel: cdc_acm 2-2.1:1.0: ttyACM0: USB ACM device
Jun 29 15:23:32 XRCERIUM kernel: usb-storage 2-2.1:1.2: USB Mass Storage device detected
Jun 29 15:23:32 XRCERIUM kernel: scsi host3: usb-storage 2-2.1:1.2
Jun 29 15:23:32 XRCERIUM kernel: input: Raspberry Pi Pico Keyboard as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000E/input/input43
Jun 29 15:23:32 XRCERIUM kernel: input: Raspberry Pi Pico Mouse as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000E/input/input44
Jun 29 15:23:32 XRCERIUM kernel: input: Raspberry Pi Pico Consumer Control as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000E/input/input45
Jun 29 15:23:32 XRCERIUM kernel: hid-generic 0003:239A:80F4.000E: input,hidraw1: USB HID v1.11 Keyboard [Raspberry Pi Pico] on usb-0000:02:00.0-2.1/input3
Jun 29 15:23:32 XRCERIUM mtp-probe[5152]: checking bus 2, device 16: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1"
Jun 29 15:23:32 XRCERIUM mtp-probe[5152]: bus: 2, device: 16 was not an MTP device
Jun 29 15:23:32 XRCERIUM systemd-udevd[5147]: mouse3: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-udevd[5151]: event7: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-logind[487]: Watching system buttons on /dev/input/event7 (Raspberry Pi Pico Consumer Control)
Jun 29 15:23:32 XRCERIUM systemd-udevd[5156]: event6: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-udevd[5165]: event5: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:23:32 XRCERIUM systemd-logind[487]: Watching system buttons on /dev/input/event5 (Raspberry Pi Pico Keyboard)
Jun 29 15:23:32 XRCERIUM mtp-probe[5173]: checking bus 2, device 16: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1"
Jun 29 15:23:32 XRCERIUM mtp-probe[5173]: bus: 2, device: 16 was not an MTP device
Jun 29 15:23:32 XRCERIUM pulseaudio[1095]: Failed to find a working profile.
Jun 29 15:23:32 XRCERIUM pulseaudio[1095]: Failed to load module "module-alsa-card" (argument: "device_id="1" name="usb-Raspberry_Pi_Pico_E66038B713777233-04" card_name="alsa_card.usb-Raspberry_Pi_Pico_E66038B713777233-04" >
Jun 29 15:23:33 XRCERIUM kernel: scsi 3:0:0:0: Direct-Access Raspberr Pico 1.0 PQ: 0 ANSI: 2
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: Attached scsi generic sg2 type 0
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] 2049 512-byte logical blocks: (1.05 MB/1.00 MiB)
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Write Protect is off
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] No Caching mode page found
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Assuming drive cache: write through
Jun 29 15:23:33 XRCERIUM kernel: sdb: sdb1
Jun 29 15:23:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Attached SCSI removable disk
Jun 29 15:23:34 XRCERIUM udisksd[489]: Mounted /dev/sdb1 at /media/pi/CIRCUITPY on behalf of uid 1000

  • USB data from HWinfo64 v7.62 (host) when Pico connected:

[Device Information]
Device Manufacturer: Raspberry Pi
Product Name: Pico
Serial Number: E66038B713777233
USB Version Supported: 2.00
USB Device Speed: USB 1.1 Full-speed
Driver Description: USB Composite Device
Hardware ID: USB\VID_239A&PID_80F4

[Driver Information]
Driver Manufacturer: (Standard USB Host Controller)
Driver Description: USB Composite Device
Driver Provider: Microsoft
Driver Version: 10.0.19041.4474
Driver Date: 21-Jun-2006
DeviceInstanceId USB\VID_239A&PID_80F4\E66038B713777233
Location Paths PCIROOT(0)#PCI(1D03)#USBROOT(0)#USB(2)

Version: adafruit-circuitpython-raspberry_pi_pico-en_GB-8.2.10:
Can write to file system (code.py) OK in VM (Raspberry Pi Desktop Bullseye).

  • "mount" output for Pico:

/dev/sdb1 on /media/pi/CIRCUITPY type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Version: adafruit-circuitpython-raspberry_pi_pico-en_GB-9.0.0-beta.0.uf2:

Can NOT write to file system (code.py) in VM (Raspberry Pi Desktop Bullseye).

When disconnected from the VM, the file system is no longer writeable from Windows.
Ejecting/Connecting the Pico makes the file system writeable again, for Windows.

  • "mount" output for Pico:

/dev/sdb1 on /media/pi/CIRCUITPY type vfat (ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Version: adafruit-circuitpython-raspberry_pi_pico-en_GB-9.0.5.uf2:
Can NOT write to file system (code.py) in VM (Raspberry Pi Desktop Bullseye).

When disconnected from the VM, the file system is no longer writeable from Windows.
Ejecting/Connecting the Pico makes the file system writeable again, for Windows.

  • "mount" output for Pico:

/dev/sdb1 on /media/pi/CIRCUITPY type vfat (ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Version: adafruit-circuitpython-raspberry_pi_pico-en_GB-20240626-main-PR9375-396aaef:
Can NOT write to file system (code.py) in VM (Raspberry Pi Desktop Bullseye).

When disconnected from the VM, the file system is no longer writeable from Windows.
Ejecting/Connecting the Pico makes the file system writeable again, for Windows.

  • "mount" output for Pico:

/dev/sdb1 on /media/pi/CIRCUITPY type vfat (ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

  • "Mu" development environment log after failure to save (partial):

2024-06-29 15:06:00,453 - mu.logic:787(_load) DEBUG: #121
print("Hello World!")

2024-06-29 15:06:05,515 - mu.logic:869(save_tab_to_file) INFO: Saving script to: /media/pi/CIRCUITPY/code.py
2024-06-29 15:06:05,515 - mu.logic:870(save_tab_to_file) DEBUG: #1212
print("Hello World!")

2024-06-29 15:06:05,516 - mu.logic:874(save_tab_to_file) ERROR: [Errno 30] Read-only file system: '/media/pi/CIRCUITPY/code.py'
2024-06-29 15:06:05,518 - mu.interface.main:723(show_message) DEBUG: Could not save file (disk problem)
2024-06-29 15:06:05,519 - mu.interface.main:724(show_message) DEBUG: Error saving file to disk. Ensure you have permission to write the file and sufficient disk space.
2024-06-29 15:06:14,206 - mu.logic:1075(show_admin) INFO: Showing logs from /home/pi/.cache/mu/log/mu.log

  • lsusb (When Pico connected to VM guest):

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 012: ID 239a:80f4 Adafruit Pico
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

  • blkid (When Pico connected to VM guest):

/dev/sda1: UUID="89bcd5d7-fbb6-4c34-b9b2-afe4b3ed2ac4" BLOCK_SIZE="1024" TYPE="ext2" PARTUUID="e49b40f1-01"
/dev/sda5: UUID="T9YbuA-aJzc-p2WA-wAWC-iTTh-tQ5K-90LJ3b" TYPE="LVM2_member" PARTUUID="e49b40f1-05"
/dev/mapper/raspberry--vg-root: UUID="9b6b1cd4-c228-4ff6-ac1f-660f7952f38f" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/raspberry--vg-swap_1: UUID="a54c0ead-45df-4b64-9c41-890aa89d93ae" TYPE="swap"
/dev/sdb1: SEC_TYPE="msdos" LABEL="CIRCUITPY" UUID="2895-BCA3" BLOCK_SIZE="512" TYPE="vfat"

  • fdisk -l (When Pico connected to VM guest):

Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe49b40f1

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 41940991 40939522 19.5G 5 Extended
/dev/sda5 1001472 41940991 40939520 19.5G 8e Linux LVM

Disk /dev/mapper/raspberry--vg-root: 18.56 GiB, 19931332608 bytes, 38928384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/raspberry--vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sdb: 1 MiB, 1049088 bytes, 2049 sectors
Disk model: Pico
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type
/dev/sdb1 1 2048 2048 1M 6 FAT16

  • usb-devices (When Pico connected to VM guest):

T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev=05.10
S: Manufacturer=Linux 5.10.0-15-amd64 ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=0000:02:03.0
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub

T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev=05.10
S: Manufacturer=Linux 5.10.0-15-amd64 uhci_hcd
S: Product=UHCI Host Controller
S: SerialNumber=0000:02:00.0
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub

T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0003 Rev=01.03
S: Manufacturer=VMware
S: Product=VMware Virtual USB Mouse
C: #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=0mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid

T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 7
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0002 Rev=01.00
S: Product=VMware Virtual USB Hub
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub

T: Bus=02 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#= 12 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=239a ProdID=80f4 Rev=01.00
S: Manufacturer=Raspberry Pi
S: Product=Pico
S: SerialNumber=E66038B713777233
C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=00 Driver=cdc_acm
I: If#=0x1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
I: If#=0x2 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
I: If#=0x3 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
I: If#=0x4 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I: If#=0x5 Alt= 0 #EPs= 2 Cls=01(audio) Sub=03 Prot=00 Driver=snd-usb-audio

  • dmesg (On connection of Pico to VM):

[ 2421.759719] usb 2-2.1: new full-speed USB device number 14 using uhci_hcd
[ 2422.078129] usb 2-2.1: New USB device found, idVendor=239a, idProduct=80f4, bcdDevice= 1.00
[ 2422.078136] usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2422.078138] usb 2-2.1: Product: Pico
[ 2422.078139] usb 2-2.1: Manufacturer: Raspberry Pi
[ 2422.078141] usb 2-2.1: SerialNumber: E66038B713777233
[ 2422.110240] cdc_acm 2-2.1:1.0: ttyACM0: USB ACM device
[ 2422.196460] usb-storage 2-2.1:1.2: USB Mass Storage device detected
[ 2422.210213] scsi host3: usb-storage 2-2.1:1.2
[ 2422.295726] input: Raspberry Pi Pico Keyboard as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000C/input/input37
[ 2422.350148] input: Raspberry Pi Pico Mouse as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000C/input/input38
[ 2422.350337] input: Raspberry Pi Pico Consumer Control as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000C/input/input39
[ 2422.350592] hid-generic 0003:239A:80F4.000C: input,hidraw1: USB HID v1.11 Keyboard [Raspberry Pi Pico] on usb-0000:02:00.0-2.1/input3
[ 2423.231366] scsi 3:0:0:0: Direct-Access Raspberr Pico 1.0 PQ: 0 ANSI: 2
[ 2423.236999] sd 3:0:0:0: Attached scsi generic sg2 type 0
[ 2423.249473] sd 3:0:0:0: [sdb] 2049 512-byte logical blocks: (1.05 MB/1.00 MiB)
[ 2423.267208] sd 3:0:0:0: [sdb] Write Protect is on
[ 2423.267215] sd 3:0:0:0: [sdb] Mode Sense: 03 00 80 00
[ 2423.284114] sd 3:0:0:0: [sdb] No Caching mode page found
[ 2423.284138] sd 3:0:0:0: [sdb] Assuming drive cache: write through
[ 2423.389080] sdb: sdb1
[ 2423.503738] sd 3:0:0:0: [sdb] Attached SCSI removable disk

  • journalctl (On connection of Pico to VM):

Jun 29 15:15:31 XRCERIUM kernel: usb 2-2.1: new full-speed USB device number 14 using uhci_hcd
Jun 29 15:15:32 XRCERIUM kernel: usb 2-2.1: New USB device found, idVendor=239a, idProduct=80f4, bcdDevice= 1.00
Jun 29 15:15:32 XRCERIUM kernel: usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 29 15:15:32 XRCERIUM kernel: usb 2-2.1: Product: Pico
Jun 29 15:15:32 XRCERIUM kernel: usb 2-2.1: Manufacturer: Raspberry Pi
Jun 29 15:15:32 XRCERIUM kernel: usb 2-2.1: SerialNumber: E66038B713777233
Jun 29 15:15:32 XRCERIUM kernel: cdc_acm 2-2.1:1.0: ttyACM0: USB ACM device
Jun 29 15:15:32 XRCERIUM kernel: usb-storage 2-2.1:1.2: USB Mass Storage device detected
Jun 29 15:15:32 XRCERIUM kernel: scsi host3: usb-storage 2-2.1:1.2
Jun 29 15:15:32 XRCERIUM kernel: input: Raspberry Pi Pico Keyboard as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000C/input/input37
Jun 29 15:15:32 XRCERIUM kernel: input: Raspberry Pi Pico Mouse as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000C/input/input38
Jun 29 15:15:32 XRCERIUM kernel: input: Raspberry Pi Pico Consumer Control as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1/2-2.1:1.3/0003:239A:80F4.000C/input/input39
Jun 29 15:15:32 XRCERIUM kernel: hid-generic 0003:239A:80F4.000C: input,hidraw1: USB HID v1.11 Keyboard [Raspberry Pi Pico] on usb-0000:02:00.0-2.1/input3
Jun 29 15:15:32 XRCERIUM mtp-probe[4773]: checking bus 2, device 14: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1"
Jun 29 15:15:32 XRCERIUM mtp-probe[4773]: bus: 2, device: 14 was not an MTP device
Jun 29 15:15:33 XRCERIUM systemd-udevd[4768]: mouse3: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:15:33 XRCERIUM systemd-udevd[4774]: event6: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:15:33 XRCERIUM systemd-udevd[4776]: event7: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:15:33 XRCERIUM systemd-logind[487]: Watching system buttons on /dev/input/event7 (Raspberry Pi Pico Consumer Control)
Jun 29 15:15:33 XRCERIUM systemd-udevd[4787]: event5: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 29 15:15:33 XRCERIUM systemd-logind[487]: Watching system buttons on /dev/input/event5 (Raspberry Pi Pico Keyboard)
Jun 29 15:15:33 XRCERIUM mtp-probe[4794]: checking bus 2, device 14: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.1"
Jun 29 15:15:33 XRCERIUM mtp-probe[4794]: bus: 2, device: 14 was not an MTP device
Jun 29 15:15:33 XRCERIUM kernel: scsi 3:0:0:0: Direct-Access Raspberr Pico 1.0 PQ: 0 ANSI: 2
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: Attached scsi generic sg2 type 0
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] 2049 512-byte logical blocks: (1.05 MB/1.00 MiB)
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Write Protect is on
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Mode Sense: 03 00 80 00
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] No Caching mode page found
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Assuming drive cache: write through
Jun 29 15:15:33 XRCERIUM kernel: sdb: sdb1
Jun 29 15:15:33 XRCERIUM kernel: sd 3:0:0:0: [sdb] Attached SCSI removable disk
Jun 29 15:15:33 XRCERIUM pulseaudio[1095]: Failed to find a working profile.
Jun 29 15:15:33 XRCERIUM pulseaudio[1095]: Failed to load module "module-alsa-card" (argument: "device_id="1" name="usb-Raspberry_Pi_Pico_E66038B713777233-04" card_name="alsa_card.usb-Raspberry_Pi_Pico_E66038B713777233-04" >
Jun 29 15:15:34 XRCERIUM udisksd[489]: Mounted /dev/sdb1 at /media/pi/CIRCUITPY on behalf of uid 1000
lines 1-37/37 (END)

  • USB data from HWinfo64 v7.62 (host) when Pico connected:

[Device Information]
Device Manufacturer: Raspberry Pi
Product Name: Pico
Serial Number: E66038B713777233
USB Version Supported: 2.00
USB Device Speed: USB 1.1 Full-speed
Driver Description: USB Composite Device
Hardware ID: USB\VID_239A&PID_80F4

[Driver Information]
Driver Manufacturer: (Standard USB Host Controller)
Driver Description: USB Composite Device
Driver Provider: Microsoft
Driver Version: 10.0.19041.4474
Driver Date: 21-Jun-2006
DeviceInstanceId USB\VID_239A&PID_80F4\E66038B713777233
Location Paths PCIROOT(0)#PCI(1D03)#USBROOT(0)#USB(2)

@BusterRaid BusterRaid added the bug label Jun 29, 2024
@BusterRaid BusterRaid changed the title Pi Pico-Filesystem (CIRCUITPY) mounted Read-only for versions > v9 on Debian 11.10 Pi Pico-Filesystem (CIRCUITPY) mounted Read-Only for versions > v9 on Debian 11.10 Jun 29, 2024
@BusterRaid BusterRaid changed the title Pi Pico-Filesystem (CIRCUITPY) mounted Read-Only for versions > v9 on Debian 11.10 Pi Pico-Filesystem (CIRCUITPY) mounted Read-Only for versions >= v9 on Debian 11.10 Jun 29, 2024
@dhalbert
Copy link
Collaborator

What happens if you try the board directly on the RPi without using a VM?

Also try erasing and reformatting CIRCUITPY.

import storage 
storage.erase_filesystem()

@dhalbert dhalbert added this to the Support milestone Jun 30, 2024
@tannewt tannewt added the rp2040 Raspberry Pi RP2040 label Jul 1, 2024
@BusterRaid
Copy link
Author

BusterRaid commented Jul 1, 2024

Hi.

Thank you for the reply.

On the "original" set up (Dell 490-Win 10 VM host running "Raspberry Pi Desktop - Bullseye, 11.x" as a VM and the Pico connected to the VM):

import storage 
storage.erase_filesystem()

.. did not resolve the issue.

After running the command the Pico seems to be "ejected" from the VM and then reconnected.
However the Pico is (re)mounted as ReadOnly.

When directly connecting the Pico to a Raspberry Pi 3 Model B Plus Rev 1.3 running Raspberry Pi OS Bookworm 12.x, the Pico seems to be OK-it is mounted as ReadWrite.

At the moment I dont have access to a physical Pi which is running "Raspberry Pi OS - Bullseye, 11.x". I'll see if I can spin one up tomorrow.

The current version of the x86 desktop (which I use for the VM) is "stuck" on Bullseye - there is no Bookworm version.

As I do most of my tinkering on a VM, I'd like to get the Pico/CircuitPython combo working when connected to this Raspberry Pi Desktop - Bullseye VM.

@dhalbert
Copy link
Collaborator

dhalbert commented Jul 1, 2024

We have not seen problems like this with Bullseye on a physical RPi, so I suspect it is something about using the VM, perhaps something about the VM settings.

Can you see the serial connection from the VM to the board, and connect to the REPL? If not, that may be confusing the issue.

@BusterRaid
Copy link
Author

BusterRaid commented Jul 2, 2024

Can you see the serial connection from the VM to the board, and connect to the REPL? If not, that may be confusing the issue.

I think I can (it's all a bit new to me) - I'm using Mu on the Pi VM and the option "serial" is available and seems to work - it seems to connect and I can run stuff on the Pico (e.g.: turning the onboard LED on/off).
This is the case for both Circuit Python v8.x and v9.x versions that i have tried.

Some other tests I carried out:

- For Raspberry Pi Desktop, Bullseye (VM), CircuitPython en_GB-9.0.5:

The Pico is mounted ReadOnly.
There is no change to this behaviour if, within the hypervisor, I set "USB compatibility" as 1.1, 2 or 3 between reboots of the VM.

- For Raspberry Pi Desktop, Buster(10.13) (VM), CircuitPython en_GB-9.0.5:

Mostly a vanilla install, with updates.
The Pico is mounted ReadOnly.

- For Debian Bullseye(11.10) i386 (VM), CircuitPython en_GB-9.0.5:

Mostly a vanilla install, with updates.
When using the hypervisor option "Connect (Disconnect from host)", the Pico is connected to the VM but not automagically mounted.
Mounting via the "CIRCUITPY" icon on the desktop causes the Pico to be mounted ReadOnly.

Issuing the mount command:

`mount -t vfat /dev/sdb1 /media/user1/CIRCUITPY -o rw`

... elicits the response:

`mount: /media/user1/CIRCUITPY: WARNING: source write-protected, mounted read-only.`

... suggesting the device is being considered as a ReadOnly USB device.

In summary:
CircuitPython en_GB-8.2.10 - OK on every VM I tried. - Mounted as ReadWrite.
CircuitPython en_GB-9.0.5 - Not OK on every VM I tried. - Mounted as ReadOnly.

If using "CircuitPython en_GB-9.0.5", the Pico is mounted on the HOST machine (the Dell Windows 10 physical) as ReadWrite.
Once the Pico is connected/mounted to a VM its file system is "set" to ReadOnly.
Shutting down the VM (returning the Pico to the host), the Pico file system is remains ReadOnly.
Removing the Pico from the host and reinserting it restores the filesystem to ReadWrite.

I agree the issue is almost certainly in the hypervisor handling of the USB device but the behaviour seems different between CircuitPython versions v8.x and v9.x (Caveat: I have tested a few of the available v8.x and v9.x versions).

Thanks.

@asmagill
Copy link

I am seeing similar behavior on a Raspberry Pi 5 running the latest bookworm pi os release (no VM).

I've seen it with multiple Pi Picos and with the PyPortal Titano most recently -- if I run the latest 8.x version of Circuitpython, the flash will be mountable read-write; if I install Circuitpython 9.x, about 4 out of 5 times when I plug the device into my Pi, it shows up in the logs with:

[  +0.022841] sd 5:0:0:0: [sdi] Write Protect is on
[  +0.000008] sd 5:0:0:0: [sdi] Mode Sense: 03 00 80 00
[  +0.019416]  sdi: sdi1
[  +0.000587] sd 5:0:0:0: [sdi] Attached SCSI removable disk

and, as you might expect, whenever I try to mount it, I'll get "WARNING: source write-protected, mounted read-only."

The odd thing is that if I run dmesg -w in a window on my Pi, and then plug and unplug the circuitpython device in, about 1 in 5 times, it will show "Write Protect mode is off"

I have also tried erasing the filesystem from a safe mode boot and it makes no difference -- getting a write enabled mount is a crapshoot -- the only reliable "fix" is to revert to the latest CP8.

@dhalbert
Copy link
Collaborator

@asmagill Could you post the string of consecutive relevant log entries from dmesg or /var/log/syslog (latter might have more or less info) when plugging in the board when it works and when it does not work, so we can compare the two sets of entries?

Do you see this problem even if code.py is not present or very simple? Do you have a boot.py?

I am using Ubuntu 24.04 which comes from the same code base, and don't see this problem. @jepler uses Debian and I think has not seen this. But the problems above are all on Raspberry Pi OS and we are running on x64.

@jepler
Copy link

jepler commented Jul 15, 2024 via email

@asmagill
Copy link

I'm not at home at moment, so it'll be a day or so to gather the logs requested.

As to to boot.py/code.py, mostly I've tested without these files (or the defaults as created after storage.erase_filesystem() -- no boot.py and a simple print statement in code.py).

I did have a thought... the system I do most of my work on has externally powered usb hubs, one to a USB3 port, the other to a USB2 port and these are what I plug devices into 90+% of the time... when I gather the requested logs in a day or so, I'll do so with another recently purchased Pi5 and plug directly into the Pi skipping any hubs. If it makes a difference, it still leaves the question as to what changed between 8 and 9, but sensitivity to various USB hubs is nothing new (my experience, at any rate) in the embedded world...

@asmagill
Copy link

Ok, yeah, some preliminary tests suggest that the hub is in fact the issue... I remove that and the write-protects almost entirely go away.

While that makes it a much less critical issue, it still leaves open the question of what changed the sensitivity between 8.x and 9.x and is it something that can be addressed or just needs to be documented and worked around?

...before I post logs, should I open this as a new issue?

@dhalbert
Copy link
Collaborator

...before I post logs, should I open this as a new issue

It's fine to open a new issue, and then close this as being superceded. That way the new thread will be more on point.

If you have a different hub, you might try that so see if it's that particular hub. I had a cheap USB-C to USB-A hub that disconnected frequently, causing all kinds of problems. Also maybe try the "bad" hub on some non-RPi computer.

@BusterRaid
Copy link
Author

With regard to my issue:
The pico was connected directly to the Dell 490 - I tried both front and rear USB ports.
I have also tried the Pico on a Dell 6400 Inspiron laptop - similar set up to the above Dell 490 (Win 10 Pro 22H2 x64, Raspberry Pi Desktop VM running under VMware 12.5.x Player).
In all cases the Pico mounts (in the Raspberry Pi Debian 11 VM) as ReadOnly.

@dhalbert
Copy link
Collaborator

@hathach This is odd: MSC is mounting read-only in CircuitPython 9 when using a VM or when using certain hubs. Do this ring any bells for you related to some TinyUSB update?

@asmagill
Copy link

Sorry, out of town unexpectedly and haven't been able to grab any logs yet or test with other hubs, but to add:

The specific hub I am having issues with is the D-Link DUB-H7 (https://www.amazon.com/D-Link-DUB-H7-7port-Usb-2-0/dp/B00DMLTG3G/). I haven't been able to test with other hubs, but should be able to in about a week when I return home.

Reverting to CircuitPython 8.x and using the hub works as expected (i.e. write-protect off for fresh CP install with default initial filesystem), or staying with 9.x and plugging directly into the Raspberry Pi will fix it.

@djairjr
Copy link

djairjr commented Aug 16, 2024

I'm working on a version of Circuitpython 9.2.0 for the Xiao ESP32S3 Sense and I had the same problem.
In my case, I have a machine with Dual Boot (Ubuntu 22.03 and Windows 11). I carried out all the customization of the source files in my fork on Github and cloned the Adafruit repository. Then, on Linux, I moved the custom files and compiled the firmware.
When I start the machine in Linux, I have the CIRCUITPY drive mounted and read and write access. But when I boot into Windows, I don't have access to the CIRCUITPY drive.
I can open the files to view in Thonny, but I can't save them.

Also try to repeat steps in Amazon ECS Ubuntu Machine, with Circuitpython 9.1.1. Same problem.

Tested workaround: manually install tinyuf2 bootloader at https://github.com/adafruit/tinyuf2/releases and copy .uf2 files also generates a unusable readonly CIRCUITPY (not show on windows system).

@dhalbert
Copy link
Collaborator

@djairjr Let's discuss in #9528.

@hathach
Copy link
Member

hathach commented Sep 5, 2024

@dhalbert sorry for late response. This does not ring any bell to me, I am not quite sure, but I remember to see this randomly (not very often). The flow would be around CPY is_writable_cb() usage

  • when is_writable = false tinyusb will reject WRITE_10 command
  • host will send TEST_UNIT_READY/REQUEST_SENSE for previous failed reason, currently is SCSI_SENSE_DATA_PROTECT
  • normally host will attempt to re-write again later

not sure what went wrong, maybe we could use a not sense such as NOT READY or something to prevent host to give up on this (depending on drivers, host may give up retry). I am not sure, this sense code has been doing fine so far.

@tannewt tannewt added the usb label Sep 5, 2024
@garberw
Copy link

garberw commented Sep 17, 2024

I have a raspberry pi zero as my "desktop" with the pico w attached to the data usb port of the raspi zero. I have run "mkdir /media/CIRCUITPY" on the raspi zero. Can someone please give me the mount parameters in the format for /etc/fstab.
I currently use a line in fstab:
UUID=******** /media/CIRCUITPY vfat defaults,nosuid,nodev,nofail,sync,uid=1000,gid=1000,umask=027 0 0
I have been having problems with it mounting read-only too. I swapped the usb cable and removed a hub as suggested above and that may have had something to do with it working now (not sure how long it will last).

@dhalbert
Copy link
Collaborator

@garberw The automount that Ubuntu is doing for shows up as this:

/dev/sdb1 on /media/halbert/CIRCUITPY type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Which board are you working with? We want to fix the read-only issue.

@garberw
Copy link

garberw commented Sep 17, 2024

I have a raspberry pi zero wh (not zero 2 w) as "desktop" and a pico wh as microcontroller. it's not the pico2.
I tried the above mount option and it did not improve things even with a simple straight through cable with no hubs or anything inbetween;
Previously I tried using fsck on a different pico board of the same model. that showed a corrupted boot sector on CIRCUITPY;
I also tried flashing the "nuke" .uf2 to reset the board and reinstall circuitpython;
the problem sometimes happens when I run my program which writes to the UART; that crashed it this time; have no idea what that has to do with anything;
best guess is that by unplugging the power to either the pico or the raspi zero without proper shutdown or syncing the pico I corrupted the filesystem on the pico; should definitely use "sync" mount options always for pico;

@garberw
Copy link

garberw commented Sep 17, 2024

or maybe you have to mount it as type "-t msdos"

@garberw
Copy link

garberw commented Sep 18, 2024

I used the mount options
UUID=4F17-3FFE /media/CIRCUITPY vfat rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2 0 0
and after rebooting and reflashing circuitpy .uf2 it was mounted read write. I have not been able to crash it yet.
Before this fix, the bug may have had something to do with the (wrong) mount options used when copying .mpy precompiled binaries to /media/CIRCUITPY/lib since the above mount options specify charset etc and may somehow translate the copied files;

@garberw
Copy link

garberw commented Sep 18, 2024

big hint

is this connected to systemctl daemon-reload warning bug which is probably upstream in debian not raspbian;
https://forums.raspberrypi.com/viewtopic.php?t=362156

The objective;
Development is done on an intel desktop; the objective is to use the desktop to remotely control a zero (headless) to copy code.py to a pico; Normally the zero is powered off; the zero is only used to copy code.py to the pico

The original problem was that I installed raspbian in desktop mode on the zero but I switched to booting to console mode.
Unfortunately when I ssh from my (intel) desktop to raspbian on the zero it still tried to autostart the gui pcmanfm when I plugged in the pico to the zero ... but since the zero was headless (logged in over ssh) pcmanfm just hanged; so I turned off the autostart for pcmanfm;

Does the autostart for pcmanfm come from udev ????

So I turned off the option to autostart pcmanfm and tried to mount the pico on the zero from fstab instead;

the rapsi zero keeps giving me the warning that e.g. after a reboot when I do umount /media/CIRCUITPY followed by mount -a that I need to run systemctl daemon-reload even though it has been run several times;
... which is the original problem; it usually (but not always) mounts it as read-only

Could this warning be caused by a problem from modifying fstab while the disk is mounted?

Could this be from some udev rule that has been conflicting with fstab all along? I don't think there is a udev rule for picos in raspbian; when I boot headless (before I added the fstab entry) the pico CIRCUITPY drive was not automounted;

Also note: it seems to still mount okay (read write) when I plug the pico directly into a fedora intel desktop.

@garberw
Copy link

garberw commented Sep 18, 2024

This is what you get when the pico is automounted on fedora:
/dev/sda1 on /media/CIRCUITPY type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

@garberw
Copy link

garberw commented Sep 19, 2024

FIXED ????
it seems to be mounting rw (read-write) now consistently; do not know how long this will last; only changes were
(1) update; full-upgrade;
(2) apt --reinstall install mount
(3) pipx install mpremote (I think this installs micropython also !!!!)
something fixed it; hopefully that will help you;

@garberw
Copy link

garberw commented Sep 21, 2024

@dhalbert
broken again. I did
apt --reinstall install mount pix install mpremote
then it worked fine as reported in the previous post. Was tested quite a bit. Stayed mounted but had other stability problems.

then installed blinka and it failed immediately. Mostly (only?) mounts read-only now. There's something in blinka that fouled it up.

@garberw
Copy link

garberw commented Sep 21, 2024

The problem that the CIRCUITPY disk on the pico keeps mounting read-only ... I fixed it myself. run fsck -CVlr /dev/sda1 as follows:
`root@weathervt ####-> fsck -CVlr /dev/sda1
fsck from util-linux 2.38.1
[/usr/sbin/fsck.vfat (1) -- /media/CIRCUITPY] fsck.vfat /dev/sda1
Locking disk by /run/fsck/sda.lock ... succeeded.
fsck.fat 4.2 (2021-01-31)
There is no label in boot sector, but there is volume label 'CIRCUITPY' stored in root directory

  1. Copy volume label from root directory to boot sector
  2. Remove volume label from root directory
    [12?q]? 1

*** Filesystem was changed ***
The changes have not yet been written, you can still choose to leave the
filesystem unmodified:

  1. Write changes
  2. Leave filesystem unchanged
    [12?q]? 1
    /dev/sda1: 62 files, 271/980 clusters
    /dev/sda1: status 1, rss 1888, real 51.965142, user 0.000000, sys 0.027163
    Unlocking /run/fsck/sda.lock.
    root@weathervt ####->
    `
    Now it mounts read-write.

@dhalbert
Copy link
Collaborator

If this happens again, could you run fsck -VN just to report with what fsck thinks is wrong? I am thinking that the drive is being dismounted when it is an inconsistent state or the dirty bit is set. The latter should not make it be read-only, but there may be some defaults on your system that are causing this. I am not sure that blinka has anything to do with this. The volume label manipulation you mentioned above may also have corrected some other issue as a side-effect.

I will do some research about similar non-CIRCUITPY reports on Rsapberry Pi OS.

@garberw
Copy link

garberw commented Sep 21, 2024

(env) root@weathervt ####>> fsck -VN /dev/sda1 fsck from util-linux 2.38.1 [/usr/sbin/fsck.vfat (1) -- /media/CIRCUITPY] fsck.vfat /dev/sda1 (env) root@weathervt ####>>
This time my "solution" did not work. Also did fsck -CVlr and did not work.
If this keeps up I can not use the pico as it (or something) is too unstable. Works better if it is plugged into a fedora machine. Mounts read-write more often.

@dhalbert
Copy link
Collaborator

dhalbert commented Sep 22, 2024

Do you have a regular x64 desktop as well? If so do you see the same kind of behavior? And do you have a second RP2040 board of some kind? If so does it also act up in the same way? I'm just trying to narrow the problem down. How about if you run regular Raspberry Pi OS on the Pi Pico W?

@garberw
Copy link

garberw commented Sep 22, 2024

I have two computers
(1) x86 running fedora
(2) raspberry pi zero W (not raspberry pi zero 2W) running raspberry pi os most recent version
And one microcontroller
(3) raspberry pi pico W (UPDATE this is also wireless) running whatever it came with plus circuit python .uf2
You can't run raspberry pi os on the pico w as it is not a computer just a microcontroller.

What I want is for the pico to plug into the zero over usb and mount the pico CIRCUITPY on the zero using fstab on the zero or anyhow reliable and controllable. This is what is so flaky. The pico flash memory often mounts on the zero under /media/CIRCUITPY as read-only. The zero sometimes shuts down when I plug the pico into it indicating that the zero power supply is possibly not good enough. What do you think ???? I usually leave the pico plugged into the zero and shutdown then unplug and re-plug in the zero to reboot the whole thing so the pico should get mounted by fstab when the zero boots.

When I sometimes plug the pico into the x86 fedora desktop directly it usually automounts (this is done using some automatic method not fstab on the fedora desktop) and this is quite reliable. It is usually (perhaps always?) successfully mounted read write not read only.

I have four picos to play with and four zeros. They are not expensive but I don't want to waste them.

@dhalbert
Copy link
Collaborator

Sorry, I mean Pi Zero W, of course. Too many boards with "Pi" and "W" in their names. I will test on a Pi W and maybe some other Pi's.

@garberw
Copy link

garberw commented Sep 22, 2024

see update it is a pico WH with wireless and a zero with wireless

The whole system uses only 350 mA max at 5 V which is distributed in a complicated way.
Summary: the zero power supply is 1.5 Amps usb at 5 V which should be enough to power the pico.

The only power source is a 3 A power supply plugged into a DFRobotics DFR0535 solar controller on a usb power port which takes 2 A max.
The load on the power supply was a peak of 350 mA at 5V usb.
The battery and solar are not plugged in.
Coming out of the DFR0535 there is a usb OUT plug which provides 5 V 1.5 A and is the power supply for the raspi zero W.
There are 3 other low current adafruit breakout boards and a modbus transceiver hooked up to the DFR0535 3 V terminal.
There is a SHT30 modbus temperature gauge hooked up to the DFR0535 12 V terminal .
That shouldn't use THAT much power.

The usb out of the raspi zero W powers the pico W and should be able to provide enough current for it at 5 V.
(CHECK THIS ????)
NOTE sometimes when I plug the pico into the zero the zero reboots.
Maybe this is why the pico has less trouble mounting when plugged directly into the intel fedora desktop ??
The pico is connected to the adafruit breakout boards on sda,scl.

Everything shares the same ground. Unless you unplug the pico and plug it directly into my desktop intel fedora (rarely done).

@dhalbert
Copy link
Collaborator

It seems to me very unusual that Pi Zero W shuts down sometimes when you plug in the Pico W.

If you disconnect everything from your unusual power supply but the Pi Zero W does it happen?
If you use a more conventional wall wart power supply (say 1A or 2A), does that happen?
If you swap out the Pi Zero W for another Pi Zero W, does it also happen?

These are all things I would try in an effort to isolate the problem.

@garberw
Copy link

garberw commented Sep 23, 2024

The answer is no to all of those questions. I suspect those are in fact due to my complicated power supply (solar weather station)

But I have a clue about the mounting read-only problem.
At one point I thought the pico had crashed but it was just stuck in the repl after a crash. When I learned how to use the program "screen" I could differentiate between these crashes and real lockups.
There is another problem "real lockups" where what I think is going on is you are disconnected from /dev/ttyACM0 (no screen; no thonny; no mpremote; no terminal; no tail -f /dev/ttyACM0) and the program crashes; at the end of the program is a command to do a soft reset; The CIRCUITPY mount also disconnects after some timeout (then reconnects later);

One fix is to put a 60 second pause at the end of the program before the reset so the CIRCUITPY does not keep disconnecting and reconnecting; this allows you to copy a known working program to overwrite code.py so it will stop cycling;

The fsck fix plus the update/upgrade probably was actually effective for fixing the problem with it being mounted read-only.
There were so many unplug-without-dismount power cut offs that it may have actually corrupted the pico. but mount is working more predictably now. (embarassed ! :-) blush)

@dhalbert
Copy link
Collaborator

Glad to hear you have diagnosed it. Here are some ideas about how to make things more robust.

  • Wrap the entire program in a try-except that catches all exceptions. This could be something like:
try:
    do_everything()
except Exception:
    # do a reset, etc.

You can put the main program in do_everything(). That makes the code a little neater. However, if you have a lot of globals, this might force you to restructure the program, so the alternative is just to wrap the whole main loop or whatever in try-except, so it will all need to be indented.

  • call microcontroller.reset() (hard reset) or supervisor.reload() (soft restart) as necessary.
  • If you might be going into "brownout" safe mode, add a safemode.py to recover from that. See https://learn.adafruit.com/circuitpython-safe-mode. This was designed exactly for the kind of scenario where a solar power supply is not charging the battery well (say, due to clouds), and the board keeps rebooting because it gets just enough voltage to come up and then shuts down when more power is consumed.
  • It is possible that the RP2040 is coming up but the flash chip is not getting enough voltage to work well. We have seen this kind of thing before. Most flash chips require 2.6-2.7V to operate properly.
  • Resets or power failures when a write is happening to the flash will often result in corruption.

I will close this issue for now, but open a new issue or reopen this one if you think there are CircuitPython-caused problems.

@garberw
Copy link

garberw commented Sep 23, 2024

Thank you for your attention :-) sorry if I was panicked. wires everywhere !!!!
I am continuing this here
https://forums.adafruit.com/viewtopic.php?t=213700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rp2040 Raspberry Pi RP2040 usb
Projects
None yet
Development

No branches or pull requests

8 participants