summaryrefslogtreecommitdiff
path: root/util/uf2conv.py
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-06-01 21:12:25 +0100
committerGitHub <noreply@github.com>2023-06-01 21:12:25 +0100
commit0a3ec7f59c0b809ae0a0a7a91c427c29c1c9b33c (patch)
tree57bc05a20db3ca44a06ace24dc6bc3c07db3eaf3 /util/uf2conv.py
parenta4ed6ad0f5ccbbf1b497dc03ba64820bdaaa8957 (diff)
Merge upstream uf2conv.py changes (#21107)
Diffstat (limited to 'util/uf2conv.py')
-rwxr-xr-xutil/uf2conv.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/util/uf2conv.py b/util/uf2conv.py
index 578b2b4977..84271cee4f 100755
--- a/util/uf2conv.py
+++ b/util/uf2conv.py
@@ -74,7 +74,7 @@ def convert_from_uf2(buf):
assert False, "Non-word padding size at " + ptr
while padding > 0:
padding -= 4
- outp += b"\x00\x00\x00\x00"
+ outp.append(b"\x00\x00\x00\x00")
if familyid == 0x0 or ((hd[2] & 0x2000) and familyid == hd[7]):
outp.append(block[32 : 32 + datalen])
curraddr = newaddr + datalen
@@ -218,18 +218,17 @@ def get_drives():
if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
drives.append(words[0])
else:
- rootpath = "/media"
+ searchpaths = ["/media"]
if sys.platform == "darwin":
- rootpath = "/Volumes"
+ searchpaths = ["/Volumes"]
elif sys.platform == "linux":
- tmp = rootpath + "/" + os.environ["USER"]
- if os.path.isdir(tmp):
- rootpath = tmp
- tmp = "/run" + rootpath + "/" + os.environ["USER"]
- if os.path.isdir(tmp):
- rootpath = tmp
- for d in os.listdir(rootpath):
- drives.append(os.path.join(rootpath, d))
+ searchpaths += ["/media/" + os.environ["USER"], '/run/media/' + os.environ["USER"]]
+
+ for rootpath in searchpaths:
+ if os.path.isdir(rootpath):
+ for d in os.listdir(rootpath):
+ if os.path.isdir(rootpath):
+ drives.append(os.path.join(rootpath, d))
def has_info(d):