Skip to content

Commit e0d33e2

Browse files
Try to mount Pico drive if not already present (#175)
Fixes #27 As @vslinuxdotnet discovered, sometimes the Pico firmware update emulated USB stick does not get automounted under Linux. Add logic to attempt to use standard tools to mount it to the uploader, only tried if no drives are detected normally.
1 parent 657464f commit e0d33e2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/uf2conv.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import os.path
3434
import argparse
3535
import time
36+
import glob
3637

3738
toolspath = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/') # CWD in UNIX format
3839
try:
@@ -357,6 +358,13 @@ def error(msg):
357358
args.output = "flash." + ext
358359
else:
359360
drives = get_drives()
361+
if (len(drives) == 0) and (sys.platform == "linux"):
362+
rpidisk = glob.glob("/dev/disk/by-id/usb-RPI_RP2*-part1")
363+
try:
364+
subprocess.run(["udisksctl", "mount", "--block-device", os.path.realpath(rpidisk[0])])
365+
drives = get_drives()
366+
except:
367+
pass # If it fails, no problem since it was a heroic attempt
360368

361369
if args.output:
362370
write_file(args.output, outbuf)

0 commit comments

Comments
 (0)