more reliability for flashing, print bootstub version

This commit is contained in:
Firmware Batman 2017-08-22 09:30:44 -07:00
parent cf03f7ceb1
commit 2fa8fc4dde
1 changed files with 15 additions and 1 deletions

View File

@ -155,8 +155,16 @@ class Panda(object):
except Exception: except Exception:
pass pass
if not enter_bootloader: if not enter_bootloader:
self.close()
time.sleep(1.0) time.sleep(1.0)
self.connect() try:
self.connect()
except Exception:
# retry after 5 seconds
print("connecting to bootstub is taking a while...")
time.sleep(5.0)
self.connect()
def flash(self, fn=None): def flash(self, fn=None):
if not self.bootstub: if not self.bootstub:
@ -172,6 +180,9 @@ class Panda(object):
with open(fn) as f: with open(fn) as f:
dat = f.read() dat = f.read()
# get version
print("flash: version is "+self.get_version())
# confirm flasher is present # confirm flasher is present
fr = self._handle.controlRead(Panda.REQUEST_IN, 0xb0, 0, 0, 0xc) fr = self._handle.controlRead(Panda.REQUEST_IN, 0xb0, 0, 0, 0xc)
assert fr[4:8] == "\xde\xad\xd0\x0d" assert fr[4:8] == "\xde\xad\xd0\x0d"
@ -247,6 +258,9 @@ class Panda(object):
print(e) print(e)
pass pass
def get_version(self):
return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40)
def get_serial(self): def get_serial(self):
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20) dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20)
hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4] hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4]