aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/flash_usb.py
diff options
context:
space:
mode:
authorArksine <arksine.code@gmail.com>2020-04-24 14:29:56 -0400
committerKevinOConnor <kevin@koconnor.net>2020-05-28 14:44:51 -0400
commit05efccc874f34bf16dbc925946c5bbd06cd2d968 (patch)
tree05587f828c5a87f3cf801ccce740ee4dccf4b585 /scripts/flash_usb.py
parent4b9b705b992dd7f919b397b48fa4fcded2a89a3c (diff)
downloadkutter-05efccc874f34bf16dbc925946c5bbd06cd2d968.tar.gz
kutter-05efccc874f34bf16dbc925946c5bbd06cd2d968.tar.xz
kutter-05efccc874f34bf16dbc925946c5bbd06cd2d968.zip
stm32f1: Add support for HID Bootloader
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Diffstat (limited to 'scripts/flash_usb.py')
-rwxr-xr-xscripts/flash_usb.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/scripts/flash_usb.py b/scripts/flash_usb.py
index bead418c..7a02da45 100755
--- a/scripts/flash_usb.py
+++ b/scripts/flash_usb.py
@@ -113,6 +113,25 @@ def flash_dfuutil(device, binfile, extra_flags=[], sudo=True):
pathname = wait_path(devpath)
call_dfuutil(["-p", buspath] + extra_flags, binfile, sudo)
+def call_hidflash(binfile, sudo):
+ args = ["lib/hidflash/hid-flash", binfile]
+ if sudo:
+ args.insert(0, "sudo")
+ sys.stderr.write(" ".join(args) + '\n\n')
+ res = subprocess.call(args)
+ if res != 0:
+ raise error("Error running hid-flash")
+
+# Flash via call to hid-flash
+def flash_hidflash(device, binfile, sudo=True):
+ hexfmt_r = re.compile(r"^[a-fA-F0-9]{4}:[a-fA-F0-9]{4}$")
+ if hexfmt_r.match(device.strip()):
+ call_hidflash(binfile, sudo)
+ return
+ buspath, devpath = translate_serial_to_usb_path(device)
+ enter_bootloader(device)
+ pathname = wait_path(devpath)
+ call_hidflash(binfile, sudo)
######################################################################
# Device specific helpers
@@ -174,6 +193,8 @@ Failed to flash to %s: %s
If the device is already in bootloader mode it can be flashed with the
following command:
make flash FLASH_DEVICE=1eaf:0003
+ OR
+ make flash FLASH_DEVICE=1209:beba
If attempting to flash via 3.3V serial, then use:
make serialflash FLASH_DEVICE=%s
@@ -182,7 +203,11 @@ If attempting to flash via 3.3V serial, then use:
def flash_stm32f1(options, binfile):
try:
- flash_dfuutil(options.device, binfile, ["-R", "-a", "2"], options.sudo)
+ if options.start == 0x8000800:
+ flash_hidflash(options.device, binfile, options.sudo)
+ else:
+ flash_dfuutil(options.device, binfile, ["-R", "-a", "2"],
+ options.sudo)
except error as e:
sys.stderr.write(STM32F1_HELP % (
options.device, str(e), options.device))