1
0
Fork 0

Update uf2conv.py script

This commit is contained in:
Drashna Jael're 2024-08-07 08:29:51 -07:00
parent 9ae48fa1fb
commit c686c5a2e1
Signed by: drashna
GPG key ID: DBA1FD3A860D1B11

View file

@ -1,5 +1,4 @@
#!/usr/bin/env python3
# yapf: disable
import sys
import struct
import subprocess
@ -151,15 +150,10 @@ class Block:
flags = 0x0
if familyid:
flags |= 0x2000
if devicetype:
flags |= 0x8000
hd = struct.pack("<IIIIIIII",
UF2_MAGIC_START0, UF2_MAGIC_START1,
flags, self.addr, 256, blockno, numblocks, familyid)
hd += self.bytes[0:256]
if devicetype:
hd += bytearray(b'\x08\x29\xa7\xc8')
hd += bytearray(devicetype.to_bytes(4, 'little'))
while len(hd) < 512 - 4:
hd += b"\x00"
hd += struct.pack("<I", UF2_MAGIC_END)
@ -287,8 +281,6 @@ def main():
parser.add_argument('-f', '--family', dest='family', type=str,
default="0x0",
help='specify familyID - number or name (default: 0x0)')
parser.add_argument('-t' , '--device-type', dest='devicetype', type=str,
help='specify deviceTypeID extension tag - number')
parser.add_argument('-o', '--output', metavar="FILE", dest='output', type=str,
help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible')
parser.add_argument('-d', '--device', dest="device_path",
@ -318,9 +310,6 @@ def main():
except ValueError:
error("Family ID needs to be a number or one of: " + ", ".join(families.keys()))
global devicetype
devicetype = int(args.devicetype, 0) if args.devicetype else None
if args.list:
list_drives()
else: