Description
Originally posted by @garberw in #7409
I have this problem on raspbian 12 bookworm Linux weathers 6.12.28-v8+ #1877 SMP PREEMPT Wed May 14 12:07:03 BST 2025 aarch64 GNU/Linux
lots of weird errors trying to mount 5 picos simultaneously on a Pi4b. I have done the erase_filesystem and installed the latest circuitpython and all my uuids are different and I used "fatlabel" to set different labels on each pico.
it's my special day can someone fix it please. Often the disks don't even show up in blkid although they do in "fdisk -l | grep sd". I also noticed that the raspberry pi program "pcmanfm" shows at most 4 identical copies of CIRCUITPYTHON if you have 5 picos present.
so it seems that every time you transfer a file to the pico (a) it ejects the CIRCUITPY drive (b) it starts running from scratch (software reboot) (c) it expects something like pcmanfm to automatically remount it. I have 15 files in my program. So I rsync them to the pico and it gets confused. Also I disabled pcmanfm so when it ejects it does not get remounted. Also some unix process writes to the CIRCUITPY sporadically ejecting the drive. So when not programming (writing to CIRCUITPY) I prefer to leave it mounted read-only. Add to that the fact that it is better to have only one pico attached at a time. As the original poster said "it's the doctor joke if it hurts stop doing it" so instead of leaving all the picos mounted read write and rsyncing them one after another, I rewrote all my scripts. Now they only leave one pico mounted at a time. Note the whole project would not work if the /dev/ttypico? were not working simultaneously. Then I would really be in trouble. Since picos are $15 it's reasonable to expect people to use lots of them at once.
for udev I use
# ACTION=="add", SUBSYSTEMS=="usb",KERNEL=="ttyACM[0-9]*" ,ATTRS{idVendor}=="239a",ATTRS{idProduct}=="8120",ATTRS{serial}=="E66141040383362E",OWNER="garberw",GROUP="garberw",MODE="0600",SYMLINK+="ttypicoi"
# ACTION=="add", SUBSYSTEMS=="usb",SUBSYSTEM=="block",ENV{ID_FS_USAGE}=="filesystem",ATTRS{idVendor}=="239a",ATTRS{idProduct}=="8120",ATTRS{serial}=="E66141040383362E",SYMLINK+="picoi", RUN+="/usr/bin/logger --tag rpi-pico-mount mounting pico",RUN+="/usr/bin/mount $devnode /media/picoi"
# ACTION=="remove",SUBSYSTEMS=="usb",SUBSYSTEM=="block",ENV{ID_FS_USAGE}=="filesystem",ATTRS{idVendor}=="239a",ATTRS{idProduct}=="8120",ATTRS{serial}=="E66141040383362E",RUN+="/usr/bin/logger --tag rpi-pico-mount unmounting pico",RUN+="/usr/bin/systemd-umount /media/picoi"
SUBSYSTEM=="block", KERNEL=="sd[a-z]1", ATTRS{idVendor}=="239a", ATTRS{idProduct}=="8120", ATTRS{serial}=="E66141040383362E", OWNER="garberw", GROUP="garberw", MODE="0600", SYMLINK+="picoi"
SUBSYSTEM=="tty", ATTRS{idVendor}=="239a", ATTRS{idProduct}=="8120", ATTRS{serial}=="E66141040383362E", OWNER="garberw", GROUP="garberw", MODE="0600", SYMLINK+="ttypicoi"
Note You can't use the ACTION="add" version because it keeps remounting them when not wanted.
for fstab I use
/dev/picoi /media/picoi vfat ro,auto,nofail,noatime,nodiratime,uid=1000,gid=1000,fmask=0022,dmask=0022,sync 0 0
I will post the scripts I use if someone explains how please. Looks like I have to upload them to github first.
so it seems that every time you transfer a file to the pico (a) it ejects the CIRCUITPY drive (b) it starts running from scratch (software reboot) (c) it expects something like pcmanfm to automatically remount it.
You can disable this behavior with:
import supervisor
supervisor.runtime.autoreload = False
Yes but sometimes the pico locks up e.g. spewing output to tty and CIRCUITPY (AND the tty maybe ????) may become unaccessible. If this behavior is default (autoreload NOT disabled) I use it as follows. I have a script "zip.sh" which mounts the CIRCUITPY then immediately copies hello_world.py to code.py. Otherwise if you wait too long (not immediately) you can no longer access CIRCUITPY. Then it continues running hello world and is back to normal.
Maybe somehow e.g. using the debug probe or a second raspi you could redirect the tty output so it was not on the same usb connection as the CIRCUITPY. But then it would just crash the usb connection of whatever it was outputting to.