Skip to content

Commit

Permalink
install_uf2: fix join() and wait for drive to show up
Browse files Browse the repository at this point in the history
  • Loading branch information
Neradoc committed Nov 21, 2022
1 parent 4fcc131 commit d691df1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/install_uf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ def serial_trick(port):
continue

for i in range(10):
print("Looking for boot device")
print("Waiting for boot device with drive")
time.sleep(1)
devices = discotool.get_identified_devices()
found = False
for device in devices:
if device["usb_location"] == usb_port:
board = device
found = True
if device.drive is not None:
board = device
found = True
if found:
break
else: # no break:
Expand All @@ -60,4 +61,4 @@ def serial_trick(port):

print(f"Copy {uf2_file} to {board.drive}")
uf2_name = os.path.basename(uf2_file)
shutil.copyfile(uf2_file, os.join(board.drive, uf2_name))
shutil.copyfile(uf2_file, os.path.join(board.drive, uf2_name))

0 comments on commit d691df1

Please sign in to comment.