Browse Source

Merge upstream uf2conv changes (#25786)

Joel Challis 8 months ago
parent
commit
8eebc613cf
2 changed files with 99 additions and 12 deletions
  1. 14 12
      util/uf2conv.py
  2. 85 0
      util/uf2families.json

+ 14 - 12
util/uf2conv.py

@@ -142,9 +142,9 @@ def convert_to_uf2(file_content):
     return b"".join(outp)
 
 class Block:
-    def __init__(self, addr):
+    def __init__(self, addr, default_data=0xFF):
         self.addr = addr
-        self.bytes = bytearray(256)
+        self.bytes = bytearray([default_data] * 256)
 
     def encode(self, blockno, numblocks):
         global familyid
@@ -210,24 +210,26 @@ def to_str(b):
 def get_drives():
     drives = []
     if sys.platform == "win32":
-        r = subprocess.check_output(["wmic", "PATH", "Win32_LogicalDisk",
-                                     "get", "DeviceID,", "VolumeName,",
-                                     "FileSystem,", "DriveType"])
-        for line in to_str(r).split('\n'):
-            words = re.split(r'\s+', line)
-            if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
-                drives.append(words[0])
+        r = subprocess.check_output([
+            "powershell",
+            "-Command",
+            '(Get-WmiObject Win32_LogicalDisk -Filter "FileSystem=\'FAT\'").DeviceID'
+            ])
+        drives = [drive.strip() for drive in to_str(r).splitlines()]
     else:
-        searchpaths = ["/media"]
+        searchpaths = ["/mnt", "/media"]
         if sys.platform == "darwin":
             searchpaths = ["/Volumes"]
         elif sys.platform == "linux":
-            searchpaths += ["/media/" + os.environ["USER"], '/run/media/' + os.environ["USER"]]
+            searchpaths += ["/media/" + os.environ["USER"], "/run/media/" + os.environ["USER"]]
+            if "SUDO_USER" in os.environ.keys():
+                searchpaths += ["/media/" + os.environ["SUDO_USER"]]
+                searchpaths += ["/run/media/" + os.environ["SUDO_USER"]]
 
         for rootpath in searchpaths:
             if os.path.isdir(rootpath):
                 for d in os.listdir(rootpath):
-                    if os.path.isdir(rootpath):
+                    if os.path.isdir(os.path.join(rootpath, d)):
                         drives.append(os.path.join(rootpath, d))
 
 

+ 85 - 0
util/uf2families.json

@@ -34,6 +34,11 @@
         "short_name": "STM32WL",
         "description": "ST STM32WLxx"
     },
+    {
+        "id": "0x22e0d6fc",
+        "short_name": "RTL8710B",
+        "description": "Realtek AmebaZ RTL8710B"
+    },
     {
         "id": "0x2abc77ec",
         "short_name": "LPC55",
@@ -49,6 +54,11 @@
         "short_name": "GD32F350",
         "description": "GD32F350"
     },
+    {
+        "id": "0x3379CFE2",
+        "short_name": "RTL8720D",
+        "description": "Realtek AmebaD RTL8720D"
+    },
     {
         "id": "0x04240bdf",
         "short_name": "STM32L5",
@@ -64,6 +74,11 @@
         "short_name": "MIMXRT10XX",
         "description": "NXP i.MX RT10XX"
     },
+    {
+        "id": "0x51e903a8",
+        "short_name": "XR809",
+        "description": "Xradiotech 809"
+    },
     {
         "id": "0x53b80f00",
         "short_name": "STM32F7",
@@ -104,11 +119,21 @@
         "short_name": "STM32F0",
         "description": "ST STM32F0xx"
     },
+    {
+        "id": "0x675a40b0",
+        "short_name": "BK7231U",
+        "description": "Beken 7231U/7231T"
+    },
     {
         "id": "0x68ed2b88",
         "short_name": "SAMD21",
         "description": "Microchip (Atmel) SAMD21"
     },
+    {
+        "id": "0x6a82cc42",
+        "short_name": "BK7251",
+        "description": "Beken 7251/7252"
+    },
     {
         "id": "0x6b846188",
         "short_name": "STM32F3",
@@ -119,6 +144,11 @@
         "short_name": "STM32F407",
         "description": "ST STM32F407"
     },
+    {
+        "id": "0x4e8f1c5d",
+        "short_name": "STM32H5",
+        "description": "ST STM32H5xx"
+    },
     {
         "id": "0x6db66082",
         "short_name": "STM32H7",
@@ -129,6 +159,11 @@
         "short_name": "STM32WB",
         "description": "ST STM32WBxx"
     },
+    {
+        "id": "0x7b3ef230",
+        "short_name": "BK7231N",
+        "description": "Beken 7231N"
+    },
     {
         "id": "0x7eab61ed",
         "short_name": "ESP8266",
@@ -144,11 +179,21 @@
         "short_name": "STM32F407VG",
         "description": "ST STM32F407VG"
     },
+    {
+        "id": "0x9fffd543",
+        "short_name": "RTL8710A",
+        "description": "Realtek Ameba1 RTL8710A"
+    },
     {
         "id": "0xada52840",
         "short_name": "NRF52840",
         "description": "Nordic NRF52840"
     },
+    {
+        "id": "0x820d9a5f",
+        "short_name": "NRF52820",
+        "description": "Nordic NRF52820_xxAA"
+    },
     {
         "id": "0xbfdd4eee",
         "short_name": "ESP32S2",
@@ -194,6 +239,26 @@
         "short_name": "ESP32C61",
         "description": "ESP32-C61"
     },
+    {
+        "id": "0xb6dd00af",
+        "short_name": "ESP32H21",
+        "description": "ESP32-H21"
+    },
+    {
+        "id": "0x9e0baa8a",
+        "short_name": "ESP32H4",
+        "description": "ESP32-H4"
+    },
+    {
+        "id": "0xde1270b7",
+        "short_name": "BL602",
+        "description": "Boufallo 602"
+    },
+    {
+        "id": "0xe08f7564",
+        "short_name": "RTL8720C",
+        "description": "Realtek AmebaZ2 RTL8720C"
+    },
     {
         "id": "0xe48bff56",
         "short_name": "RP2040",
@@ -293,5 +358,25 @@
         "id": "0x7be8976d",
         "short_name": "RA4M1",
         "description": "Renesas RA4M1"
+    },
+    {
+        "id": "0x7410520a",
+        "short_name": "MAX32690",
+        "description": "Analog Devices MAX32690"
+    },
+    {
+        "id": "0xd63f8632",
+        "short_name": "MAX32650",
+        "description": "Analog Devices MAX32650/1/2"
+    },
+    {
+        "id": "0xf0c30d71",
+        "short_name": "MAX32666",
+        "description": "Analog Devices MAX32665/6"
+    },
+    {
+        "id": "0x91d3fd18",
+        "short_name": "MAX78002",
+        "description": "Analog Devices MAX78002"
     }
 ]