diff --git a/board/pedal/Makefile b/board/pedal/Makefile index 47431d9ed13a41..b1a7e5861f17dc 100644 --- a/board/pedal/Makefile +++ b/board/pedal/Makefile @@ -18,7 +18,11 @@ DFU_UTIL = "dfu-util" CERT = ../../certs/debug CFLAGS += "-DALLOW_DEBUG" -all: obj/bootstub.bin obj/$(PROJ_NAME).bin +usbflash: obj/$(PROJ_NAME).bin + ../../tests/pedal/enter_canloader.py + PYTHONPATH=../../ python -c "from python import Panda; p = Panda(); assert(p.bootstub); p.flash('obj/$(PROJ_NAME).bin', reconnect=False)" + +recover: obj/bootstub.bin obj/$(PROJ_NAME).bin $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin diff --git a/python/__init__.py b/python/__init__.py index 215fe733e99015..79a33fa9faad46 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -170,7 +170,7 @@ def connect(self, claim=True, wait=False): assert(self._handle != None) print("connected") - def reset(self, enter_bootstub=False, enter_bootloader=False): + def reset(self, enter_bootstub=False, enter_bootloader=False, reconnect=True): # reset try: if enter_bootloader: @@ -184,6 +184,8 @@ def reset(self, enter_bootstub=False, enter_bootloader=False): pass if not enter_bootloader: self.close() + if reconnect == False: + return time.sleep(1.0) success = False # wait up to 15 seconds @@ -203,7 +205,7 @@ def reset(self, enter_bootstub=False, enter_bootloader=False): if not success: raise Exception("reset failed") - def flash(self, fn=None, code=None): + def flash(self, fn=None, code=None, reconnect=True): if not self.bootstub: self.reset(enter_bootstub=True) assert(self.bootstub) @@ -247,7 +249,7 @@ def flash(self, fn=None, code=None): # reset print("flash: resetting") - self.reset() + self.reset(reconnect=reconnect) def recover(self): self.reset(enter_bootloader=True)