forked from Archive/PX4-Autopilot
Support for Rev 5 of Bootloader
This commit is contained in:
parent
73e26804da
commit
923a43b67f
|
@ -148,6 +148,7 @@ class uploader(object):
|
||||||
OK = b'\x10'
|
OK = b'\x10'
|
||||||
FAILED = b'\x11'
|
FAILED = b'\x11'
|
||||||
INVALID = b'\x13' # rev3+
|
INVALID = b'\x13' # rev3+
|
||||||
|
BAD_SILICON_REV = b'\x14' # rev5+
|
||||||
|
|
||||||
# command bytes
|
# command bytes
|
||||||
NOP = b'\x00' # guaranteed to be discarded by the bootloader
|
NOP = b'\x00' # guaranteed to be discarded by the bootloader
|
||||||
|
@ -162,11 +163,14 @@ class uploader(object):
|
||||||
GET_SN = b'\x2b' # rev4+ , get a word from SN area
|
GET_SN = b'\x2b' # rev4+ , get a word from SN area
|
||||||
GET_CHIP = b'\x2c' # rev5+ , get chip version
|
GET_CHIP = b'\x2c' # rev5+ , get chip version
|
||||||
SET_BOOT_DELAY = b'\x2d' # rev5+ , set boot delay
|
SET_BOOT_DELAY = b'\x2d' # rev5+ , set boot delay
|
||||||
|
GET_CHIP_DES = b'\x2e' # rev5+ , get chip description in ASCII
|
||||||
|
MAX_DES_LENGTH = 20
|
||||||
|
|
||||||
REBOOT = b'\x30'
|
REBOOT = b'\x30'
|
||||||
|
|
||||||
INFO_BL_REV = b'\x01' # bootloader protocol revision
|
INFO_BL_REV = b'\x01' # bootloader protocol revision
|
||||||
BL_REV_MIN = 2 # minimum supported bootloader protocol
|
BL_REV_MIN = 2 # minimum supported bootloader protocol
|
||||||
BL_REV_MAX = 4 # maximum supported bootloader protocol
|
BL_REV_MAX = 5 # maximum supported bootloader protocol
|
||||||
INFO_BOARD_ID = b'\x02' # board type
|
INFO_BOARD_ID = b'\x02' # board type
|
||||||
INFO_BOARD_REV = b'\x03' # board revision
|
INFO_BOARD_REV = b'\x03' # board revision
|
||||||
INFO_FLASH_SIZE = b'\x04' # max firmware size in bytes
|
INFO_FLASH_SIZE = b'\x04' # max firmware size in bytes
|
||||||
|
@ -235,12 +239,16 @@ class uploader(object):
|
||||||
if (self.__recv() != self.INSYNC):
|
if (self.__recv() != self.INSYNC):
|
||||||
#print("unexpected 0x%x instead of INSYNC" % ord(c))
|
#print("unexpected 0x%x instead of INSYNC" % ord(c))
|
||||||
return False;
|
return False;
|
||||||
|
c = self.__recv()
|
||||||
if (self.__recv() != self.OK):
|
if (c == self.BAD_SILICON_REV):
|
||||||
|
raise NotImplementedError()
|
||||||
|
if (c != self.OK):
|
||||||
#print("unexpected 0x%x instead of OK" % ord(c))
|
#print("unexpected 0x%x instead of OK" % ord(c))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
except NotImplementedError:
|
||||||
|
raise RuntimeError("Programing not supported for this version of silicon!\n See https://pixhawk.org/help/errata")
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
#timeout, no response yet
|
#timeout, no response yet
|
||||||
return False
|
return False
|
||||||
|
@ -274,6 +282,14 @@ class uploader(object):
|
||||||
value = self.__recv_int()
|
value = self.__recv_int()
|
||||||
self.__getSync()
|
self.__getSync()
|
||||||
return value
|
return value
|
||||||
|
# send the GET_CHIP command
|
||||||
|
def __getCHIPDes(self):
|
||||||
|
self.__send(uploader.GET_CHIP_DES + uploader.EOC)
|
||||||
|
length = self.__recv_int()
|
||||||
|
value = self.__recv(length)
|
||||||
|
self.__getSync()
|
||||||
|
peices = value.split(",")
|
||||||
|
return peices
|
||||||
|
|
||||||
def __drawProgressBar(self, label, progress, maxVal):
|
def __drawProgressBar(self, label, progress, maxVal):
|
||||||
if maxVal < progress:
|
if maxVal < progress:
|
||||||
|
@ -467,6 +483,12 @@ class uploader(object):
|
||||||
print(binascii.hexlify(x).decode('Latin-1'), end='') # show user
|
print(binascii.hexlify(x).decode('Latin-1'), end='') # show user
|
||||||
print('')
|
print('')
|
||||||
print("chip: %08x" % self.__getCHIP())
|
print("chip: %08x" % self.__getCHIP())
|
||||||
|
if (self.bl_rev >= 5):
|
||||||
|
des = self.__getCHIPDes()
|
||||||
|
if (len(des) == 2):
|
||||||
|
print("family: %s" % des[0])
|
||||||
|
print("revision: %s" % des[1])
|
||||||
|
print("flash %d" % self.fw_maxsize)
|
||||||
except Exception:
|
except Exception:
|
||||||
# ignore bad character encodings
|
# ignore bad character encodings
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue