mirror of https://github.com/Desuuuu/klipper.git
flash_usb: Try to make the bossac atsam reboot logic more stable
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
d3f6dad853
commit
a5aede52cb
|
@ -54,16 +54,18 @@ def flash_bossac(device, binfile, extra_flags=[]):
|
||||||
if os.path.exists(ttyname) and not os.path.exists(pathname):
|
if os.path.exists(ttyname) and not os.path.exists(pathname):
|
||||||
pathname = ttyname
|
pathname = ttyname
|
||||||
baseargs = ["lib/bossac/bin/bossac", "-U", "-p", pathname]
|
baseargs = ["lib/bossac/bin/bossac", "-U", "-p", pathname]
|
||||||
args = baseargs + extra_flags + ["-w", binfile, "-v", "-b"]
|
args = baseargs + extra_flags + ["-w", binfile, "-v"]
|
||||||
sys.stderr.write(" ".join(args) + '\n\n')
|
sys.stderr.write(" ".join(args) + '\n\n')
|
||||||
res = subprocess.call(args)
|
res = subprocess.call(args)
|
||||||
if res != 0:
|
if res != 0:
|
||||||
raise error("Error running bossac")
|
raise error("Error running bossac")
|
||||||
if "-R" not in extra_flags:
|
if "-R" not in extra_flags:
|
||||||
time.sleep(0.500)
|
|
||||||
args = baseargs + ["-b", "-R"]
|
args = baseargs + ["-b", "-R"]
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||||
|
if "-b" not in extra_flags:
|
||||||
|
time.sleep(1.)
|
||||||
|
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -90,7 +92,15 @@ def flash_dfuutil(device, binfile, extra_flags=[]):
|
||||||
# Device specific helpers
|
# Device specific helpers
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def flash_atsam(options, binfile):
|
def flash_atsam3(options, binfile):
|
||||||
|
try:
|
||||||
|
flash_bossac(options.device, binfile, ["-e", "-b"])
|
||||||
|
except error as e:
|
||||||
|
sys.stderr.write("Failed to flash to %s: %s\n" % (
|
||||||
|
options.device, str(e)))
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
def flash_atsam4(options, binfile):
|
||||||
try:
|
try:
|
||||||
flash_bossac(options.device, binfile, ["-e"])
|
flash_bossac(options.device, binfile, ["-e"])
|
||||||
except error as e:
|
except error as e:
|
||||||
|
@ -99,7 +109,7 @@ def flash_atsam(options, binfile):
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def flash_atsamd(options, binfile):
|
def flash_atsamd(options, binfile):
|
||||||
extra_flags = ["--offset=" + options.offset, "-R"]
|
extra_flags = ["--offset=" + options.offset, "-b", "-R"]
|
||||||
try:
|
try:
|
||||||
flash_bossac(options.device, binfile, extra_flags)
|
flash_bossac(options.device, binfile, extra_flags)
|
||||||
except error as e:
|
except error as e:
|
||||||
|
@ -153,7 +163,7 @@ def flash_stm32f1(options, binfile):
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
MCUTYPES = {
|
MCUTYPES = {
|
||||||
'atsam': flash_atsam, 'atsamd': flash_atsamd,
|
'atsam3': flash_atsam3, 'atsam4': flash_atsam4, 'atsamd': flash_atsamd,
|
||||||
'lpc176x': flash_lpc176x, 'stm32f1': flash_stm32f1
|
'lpc176x': flash_lpc176x, 'stm32f1': flash_stm32f1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@ lib/bossac/bin/bossac:
|
||||||
@echo " Building bossac"
|
@echo " Building bossac"
|
||||||
$(Q)make -C lib/bossac bin/bossac
|
$(Q)make -C lib/bossac bin/bossac
|
||||||
|
|
||||||
|
FLASH_TYPE-$(CONFIG_MACH_SAM3X) := atsam3
|
||||||
|
FLASH_TYPE-$(CONFIG_MACH_SAM4) := atsam4
|
||||||
|
|
||||||
flash: $(OUT)klipper.bin lib/bossac/bin/bossac
|
flash: $(OUT)klipper.bin lib/bossac/bin/bossac
|
||||||
@echo " Flashing $< to $(FLASH_DEVICE)"
|
@echo " Flashing $< to $(FLASH_DEVICE)"
|
||||||
$(Q)$(PYTHON) ./scripts/flash_usb.py -t atsam -d "$(FLASH_DEVICE)" $(OUT)klipper.bin
|
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(FLASH_TYPE-y) -d "$(FLASH_DEVICE)" $(OUT)klipper.bin
|
||||||
|
|
Loading…
Reference in New Issue