Merge upstream changes to uf2conv (#19993)
This commit is contained in:
parent
0a7f15964c
commit
be781927c1
3 changed files with 46 additions and 33 deletions
|
@ -42,15 +42,7 @@ dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
||||||
$(call EXEC_DFU_UTIL)
|
$(call EXEC_DFU_UTIL)
|
||||||
|
|
||||||
define EXEC_UF2_UTIL_DEPLOY
|
define EXEC_UF2_UTIL_DEPLOY
|
||||||
if ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; then \
|
$(UF2CONV) --wait --deploy $(BUILD_DIR)/$(TARGET).uf2
|
||||||
printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
|
|
||||||
sleep $(BOOTLOADER_RETRY_TIME) ;\
|
|
||||||
while ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; do \
|
|
||||||
printf "." ;\
|
|
||||||
sleep $(BOOTLOADER_RETRY_TIME) ;\
|
|
||||||
done ;\
|
|
||||||
printf "\n" ;\
|
|
||||||
fi
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
|
# TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
|
||||||
|
|
|
@ -8,6 +8,7 @@ import os
|
||||||
import os.path
|
import os.path
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
|
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
|
||||||
|
@ -276,23 +277,25 @@ def main():
|
||||||
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
|
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
|
||||||
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
|
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
|
||||||
help='input file (HEX, BIN or UF2)')
|
help='input file (HEX, BIN or UF2)')
|
||||||
parser.add_argument('-b' , '--base', dest='base', type=str,
|
parser.add_argument('-b', '--base', dest='base', type=str,
|
||||||
default="0x2000",
|
default="0x2000",
|
||||||
help='set base address of application for BIN format (default: 0x2000)')
|
help='set base address of application for BIN format (default: 0x2000)')
|
||||||
parser.add_argument('-o' , '--output', metavar="FILE", dest='output', type=str,
|
parser.add_argument('-f', '--family', dest='family', 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",
|
|
||||||
help='select a device path to flash')
|
|
||||||
parser.add_argument('-l' , '--list', action='store_true',
|
|
||||||
help='list connected devices')
|
|
||||||
parser.add_argument('-c' , '--convert', action='store_true',
|
|
||||||
help='do not flash, just convert')
|
|
||||||
parser.add_argument('-D' , '--deploy', action='store_true',
|
|
||||||
help='just flash, do not convert')
|
|
||||||
parser.add_argument('-f' , '--family', dest='family', type=str,
|
|
||||||
default="0x0",
|
default="0x0",
|
||||||
help='specify familyID - number or name (default: 0x0)')
|
help='specify familyID - number or name (default: 0x0)')
|
||||||
parser.add_argument('-C' , '--carray', action='store_true',
|
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",
|
||||||
|
help='select a device path to flash')
|
||||||
|
parser.add_argument('-l', '--list', action='store_true',
|
||||||
|
help='list connected devices')
|
||||||
|
parser.add_argument('-c', '--convert', action='store_true',
|
||||||
|
help='do not flash, just convert')
|
||||||
|
parser.add_argument('-D', '--deploy', action='store_true',
|
||||||
|
help='just flash, do not convert')
|
||||||
|
parser.add_argument('-w', '--wait', action='store_true',
|
||||||
|
help='wait for device to flash')
|
||||||
|
parser.add_argument('-C', '--carray', action='store_true',
|
||||||
help='convert binary file to a C array, not UF2')
|
help='convert binary file to a C array, not UF2')
|
||||||
parser.add_argument('-i', '--info', action='store_true',
|
parser.add_argument('-i', '--info', action='store_true',
|
||||||
help='display header information from UF2, do not convert')
|
help='display header information from UF2, do not convert')
|
||||||
|
@ -337,16 +340,19 @@ def main():
|
||||||
print("Converted to %s, output size: %d, start address: 0x%x" %
|
print("Converted to %s, output size: %d, start address: 0x%x" %
|
||||||
(ext, len(outbuf), appstartaddr))
|
(ext, len(outbuf), appstartaddr))
|
||||||
if args.convert or ext != "uf2":
|
if args.convert or ext != "uf2":
|
||||||
drives = []
|
|
||||||
if args.output == None:
|
if args.output == None:
|
||||||
args.output = "flash." + ext
|
args.output = "flash." + ext
|
||||||
else:
|
|
||||||
drives = get_drives()
|
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
write_file(args.output, outbuf)
|
write_file(args.output, outbuf)
|
||||||
else:
|
if ext == "uf2" and not args.convert and not args.info:
|
||||||
|
drives = get_drives()
|
||||||
if len(drives) == 0:
|
if len(drives) == 0:
|
||||||
|
if args.wait:
|
||||||
|
print("Waiting for drive to deploy...")
|
||||||
|
while len(drives) == 0:
|
||||||
|
sleep(0.1)
|
||||||
|
drives = get_drives()
|
||||||
|
elif not args.output:
|
||||||
error("No drive to deploy.")
|
error("No drive to deploy.")
|
||||||
for d in drives:
|
for d in drives:
|
||||||
print("Flashing %s (%s)" % (d, board_id(d)))
|
print("Flashing %s (%s)" % (d, board_id(d)))
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
{
|
{
|
||||||
"id": "0x57755a57",
|
"id": "0x57755a57",
|
||||||
"short_name": "STM32F4",
|
"short_name": "STM32F4",
|
||||||
"description": "ST STM32F401"
|
"description": "ST STM32F4xx"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "0x5a18069b",
|
"id": "0x5a18069b",
|
||||||
|
@ -188,5 +188,20 @@
|
||||||
"id": "0x9af03e33",
|
"id": "0x9af03e33",
|
||||||
"short_name": "GD32VF103",
|
"short_name": "GD32VF103",
|
||||||
"description": "GigaDevice GD32VF103"
|
"description": "GigaDevice GD32VF103"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0x4f6ace52",
|
||||||
|
"short_name": "CSK4",
|
||||||
|
"description": "LISTENAI CSK300x/400x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0x6e7348a8",
|
||||||
|
"short_name": "CSK6",
|
||||||
|
"description": "LISTENAI CSK60xx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0x11de784a",
|
||||||
|
"short_name": "M0SENSE",
|
||||||
|
"description": "M0SENSE BL702"
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
Reference in a new issue