Skip to content

Commit be78192

Browse files
authored
Merge upstream changes to uf2conv (qmk#19993)
1 parent 0a7f159 commit be78192

File tree

3 files changed

+43
-30
lines changed

3 files changed

+43
-30
lines changed

platforms/chibios/flash.mk

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,7 @@ dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
4242
$(call EXEC_DFU_UTIL)
4343

4444
define EXEC_UF2_UTIL_DEPLOY
45-
if ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; then \
46-
printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
47-
sleep $(BOOTLOADER_RETRY_TIME) ;\
48-
while ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; do \
49-
printf "." ;\
50-
sleep $(BOOTLOADER_RETRY_TIME) ;\
51-
done ;\
52-
printf "\n" ;\
53-
fi
45+
$(UF2CONV) --wait --deploy $(BUILD_DIR)/$(TARGET).uf2
5446
endef
5547

5648
# TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS

util/uf2conv.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os.path
99
import argparse
1010
import json
11+
from time import sleep
1112

1213

1314
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
@@ -276,23 +277,25 @@ def error(msg):
276277
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
277278
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
278279
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,
280281
default="0x2000",
281282
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,
283287
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",
285289
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',
287291
help='list connected devices')
288-
parser.add_argument('-c' , '--convert', action='store_true',
292+
parser.add_argument('-c', '--convert', action='store_true',
289293
help='do not flash, just convert')
290-
parser.add_argument('-D' , '--deploy', action='store_true',
294+
parser.add_argument('-D', '--deploy', action='store_true',
291295
help='just flash, do not convert')
292-
parser.add_argument('-f' , '--family', dest='family', type=str,
293-
default="0x0",
294-
help='specify familyID - number or name (default: 0x0)')
295-
parser.add_argument('-C' , '--carray', action='store_true',
296+
parser.add_argument('-w', '--wait', action='store_true',
297+
help='wait for device to flash')
298+
parser.add_argument('-C', '--carray', action='store_true',
296299
help='convert binary file to a C array, not UF2')
297300
parser.add_argument('-i', '--info', action='store_true',
298301
help='display header information from UF2, do not convert')
@@ -337,20 +340,23 @@ def error(msg):
337340
print("Converted to %s, output size: %d, start address: 0x%x" %
338341
(ext, len(outbuf), appstartaddr))
339342
if args.convert or ext != "uf2":
340-
drives = []
341343
if args.output == None:
342344
args.output = "flash." + ext
343-
else:
344-
drives = get_drives()
345-
346345
if args.output:
347346
write_file(args.output, outbuf)
348-
else:
347+
if ext == "uf2" and not args.convert and not args.info:
348+
drives = get_drives()
349349
if len(drives) == 0:
350-
error("No drive to deploy.")
351-
for d in drives:
352-
print("Flashing %s (%s)" % (d, board_id(d)))
353-
write_file(d + "/NEW.UF2", outbuf)
350+
if args.wait:
351+
print("Waiting for drive to deploy...")
352+
while len(drives) == 0:
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)
354360

355361

356362
if __name__ == "__main__":

util/uf2families.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
{
7878
"id": "0x57755a57",
7979
"short_name": "STM32F4",
80-
"description": "ST STM32F401"
80+
"description": "ST STM32F4xx"
8181
},
8282
{
8383
"id": "0x5a18069b",
@@ -188,5 +188,20 @@
188188
"id": "0x9af03e33",
189189
"short_name": "GD32VF103",
190190
"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"
191206
}
192-
]
207+
]

0 commit comments

Comments
 (0)