diff options
| -rw-r--r-- | platforms/chibios/flash.mk | 10 | ||||
| -rwxr-xr-x | util/uf2conv.py | 44 | ||||
| -rw-r--r-- | util/uf2families.json | 19 |
3 files changed, 43 insertions, 30 deletions
diff --git a/platforms/chibios/flash.mk b/platforms/chibios/flash.mk index ac842e8d62..525f177f9e 100644 --- a/platforms/chibios/flash.mk +++ b/platforms/chibios/flash.mk | |||
| @@ -42,15 +42,7 @@ dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter | |||
| 42 | $(call EXEC_DFU_UTIL) | 42 | $(call EXEC_DFU_UTIL) |
| 43 | 43 | ||
| 44 | define EXEC_UF2_UTIL_DEPLOY | 44 | define EXEC_UF2_UTIL_DEPLOY |
| 45 | if ! $(UF2CONV) --deploy $(BUILD_DIR)/$(TARGET).uf2 2>/dev/null; then \ | 45 | $(UF2CONV) --wait --deploy $(BUILD_DIR)/$(TARGET).uf2 |
| 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 | ||
| 54 | endef | 46 | endef |
| 55 | 47 | ||
| 56 | # TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS | 48 | # TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS |
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 | |||
| 8 | import os.path | 8 | import os.path |
| 9 | import argparse | 9 | import argparse |
| 10 | import json | 10 | import json |
| 11 | from time import sleep | ||
| 11 | 12 | ||
| 12 | 13 | ||
| 13 | UF2_MAGIC_START0 = 0x0A324655 # "UF2\n" | 14 | UF2_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 | ||
| 356 | if __name__ == "__main__": | 362 | if __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 |
