summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-03-02 23:26:37 +0000
committerGitHub <noreply@github.com>2023-03-03 10:26:37 +1100
commitbe781927c15b5452546a9132d30c3baaf101cef5 (patch)
tree726849cae93f24d01f100bc0f7cecb329b634ba0 /util
parent0a7f15964c6f8e10f7c1125cc61d31fc485ec25c (diff)
Merge upstream changes to uf2conv (#19993)
Diffstat (limited to 'util')
-rwxr-xr-xutil/uf2conv.py44
-rw-r--r--util/uf2families.json19
2 files changed, 42 insertions, 21 deletions
diff --git a/util/uf2conv.py b/util/uf2conv.py
index 7f5645414a..52d3861cba 100755
--- a/util/uf2conv.py
+++ b/util/uf2conv.py
@@ -8,6 +8,7 @@ import os
8import os.path 8import os.path
9import argparse 9import argparse
10import json 10import json
11from time import sleep
11 12
12 13
13UF2_MAGIC_START0 = 0x0A324655 # "UF2\n" 14UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
@@ -276,23 +277,25 @@ def main():
276 parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.') 277 parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
277 parser.add_argument('input', metavar='INPUT', type=str, nargs='?', 278 parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
278 help='input file (HEX, BIN or UF2)') 279 help='input file (HEX, BIN or UF2)')
279 parser.add_argument('-b' , '--base', dest='base', type=str, 280 parser.add_argument('-b', '--base', dest='base', type=str,
280 default="0x2000", 281 default="0x2000",
281 help='set base address of application for BIN format (default: 0x2000)') 282 help='set base address of application for BIN format (default: 0x2000)')
282 parser.add_argument('-o' , '--output', metavar="FILE", dest='output', type=str, 283 parser.add_argument('-f', '--family', dest='family', type=str,
284 default="0x0",
285 help='specify familyID - number or name (default: 0x0)')
286 parser.add_argument('-o', '--output', metavar="FILE", dest='output', type=str,
283 help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible') 287 help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible')
284 parser.add_argument('-d' , '--device', dest="device_path", 288 parser.add_argument('-d', '--device', dest="device_path",
285 help='select a device path to flash') 289 help='select a device path to flash')
286 parser.add_argument('-l' , '--list', action='store_true', 290 parser.add_argument('-l', '--list', action='store_true',
287 help='list connected devices') 291 help='list connected devices')
288 parser.add_argument('-c' , '--convert', action='store_true', 292 parser.add_argument('-c', '--convert', action='store_true',
289 help='do not flash, just convert') 293 help='do not flash, just convert')
290 parser.add_argument('-D' , '--deploy', action='store_true', 294 parser.add_argument('-D', '--deploy', action='store_true',
291 help='just flash, do not convert') 295 help='just flash, do not convert')
292 parser.add_argument('-f' , '--family', dest='family', type=str, 296 parser.add_argument('-w', '--wait', action='store_true',
293 default="0x0", 297 help='wait for device to flash')
294 help='specify familyID - number or name (default: 0x0)') 298 parser.add_argument('-C', '--carray', action='store_true',
295 parser.add_argument('-C' , '--carray', action='store_true',
296 help='convert binary file to a C array, not UF2') 299 help='convert binary file to a C array, not UF2')
297 parser.add_argument('-i', '--info', action='store_true', 300 parser.add_argument('-i', '--info', action='store_true',
298 help='display header information from UF2, do not convert') 301 help='display header information from UF2, do not convert')
@@ -337,20 +340,23 @@ def main():
337 print("Converted to %s, output size: %d, start address: 0x%x" % 340 print("Converted to %s, output size: %d, start address: 0x%x" %
338 (ext, len(outbuf), appstartaddr)) 341 (ext, len(outbuf), appstartaddr))
339 if args.convert or ext != "uf2": 342 if args.convert or ext != "uf2":
340 drives = []
341 if args.output == None: 343 if args.output == None:
342 args.output = "flash." + ext 344 args.output = "flash." + ext
343 else:
344 drives = get_drives()
345
346 if args.output: 345 if args.output:
347 write_file(args.output, outbuf) 346 write_file(args.output, outbuf)
348 else: 347 if ext == "uf2" and not args.convert and not args.info:
348 drives = get_drives()
349 if len(drives) == 0: 349 if len(drives) == 0:
350 error("No drive to deploy.") 350 if args.wait:
351 for d in drives: 351 print("Waiting for drive to deploy...")
352 print("Flashing %s (%s)" % (d, board_id(d))) 352 while len(drives) == 0:
353 write_file(d + "/NEW.UF2", outbuf) 353 sleep(0.1)
354 drives = get_drives()
355 elif not args.output:
356 error("No drive to deploy.")
357 for d in drives:
358 print("Flashing %s (%s)" % (d, board_id(d)))
359 write_file(d + "/NEW.UF2", outbuf)
354 360
355 361
356if __name__ == "__main__": 362if __name__ == "__main__":
diff --git a/util/uf2families.json b/util/uf2families.json
index fafae82a60..c2140fe351 100644
--- a/util/uf2families.json
+++ b/util/uf2families.json
@@ -77,7 +77,7 @@
77 { 77 {
78 "id": "0x57755a57", 78 "id": "0x57755a57",
79 "short_name": "STM32F4", 79 "short_name": "STM32F4",
80 "description": "ST STM32F401" 80 "description": "ST STM32F4xx"
81 }, 81 },
82 { 82 {
83 "id": "0x5a18069b", 83 "id": "0x5a18069b",
@@ -188,5 +188,20 @@
188 "id": "0x9af03e33", 188 "id": "0x9af03e33",
189 "short_name": "GD32VF103", 189 "short_name": "GD32VF103",
190 "description": "GigaDevice GD32VF103" 190 "description": "GigaDevice GD32VF103"
191 },
192 {
193 "id": "0x4f6ace52",
194 "short_name": "CSK4",
195 "description": "LISTENAI CSK300x/400x"
196 },
197 {
198 "id": "0x6e7348a8",
199 "short_name": "CSK6",
200 "description": "LISTENAI CSK60xx"
201 },
202 {
203 "id": "0x11de784a",
204 "short_name": "M0SENSE",
205 "description": "M0SENSE BL702"
191 } 206 }
192] 207] \ No newline at end of file