From f7a0ab09bf75e6f1edc5aee437f418da5e984ad7 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Fri, 9 Mar 2018 17:47:13 -0800 Subject: [PATCH] pedal usbflash works --- board/pedal/Makefile | 6 +++++- python/__init__.py | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/board/pedal/Makefile b/board/pedal/Makefile index 47431d9ed..b1a7e5861 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 215fe733e..79a33fa9f 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -170,7 +170,7 @@ class Panda(object): 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 @@ class Panda(object): 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 @@ class Panda(object): 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 @@ class Panda(object): # reset print("flash: resetting") - self.reset() + self.reset(reconnect=reconnect) def recover(self): self.reset(enter_bootloader=True)