| Line 420... |
Line 420... |
| 420 |
raise ArgumentError("The baseaddress of the specified emBIOS application is out of range of the user memory range on the device. Are you sure that this application is compatible with your device?")
|
420 |
raise ArgumentError("The baseaddress of the specified emBIOS application is out of range of the user memory range on the device. Are you sure that this application is compatible with your device?")
|
| 421 |
self.write(baseaddr, app)
|
421 |
self.write(baseaddr, app)
|
| 422 |
self.execimage(baseaddr)
|
422 |
self.execimage(baseaddr)
|
| 423 |
return Bunch(baseaddr=baseaddr, name=name)
|
423 |
return Bunch(baseaddr=baseaddr, name=name)
|
| 424 |
|
424 |
|
| 425 |
|
- |
|
| 426 |
def bootflashread(self, memaddr, flashaddr, size):
|
425 |
def bootflashread(self, memaddr, flashaddr, size):
|
| 427 |
""" Copies the data in the bootflash at 'flashaddr' of the specified size
|
426 |
""" Copies the data in the bootflash at 'flashaddr' of the specified size
|
| 428 |
to the memory at addr 'memaddr'
|
427 |
to the memory at addr 'memaddr'
|
| 429 |
"""
|
428 |
"""
|
| 430 |
return self.lib.monitorcommand(struct.pack("IIII", 22, memaddr, flashaddr, size), "III", (None, None, None))
|
429 |
return self.lib.monitorcommand(struct.pack("IIII", 22, memaddr, flashaddr, size), "III", (None, None, None))
|
| Line 435... |
Line 434... |
| 435 |
"""
|
434 |
"""
|
| 436 |
return self.lib.monitorcommand(struct.pack("IIII", 23, memaddr, flashaddr, size), "III", (None, None, None))
|
435 |
return self.lib.monitorcommand(struct.pack("IIII", 23, memaddr, flashaddr, size), "III", (None, None, None))
|
| 437 |
|
436 |
|
| 438 |
def execfirmware(self, addr):
|
437 |
def execfirmware(self, addr):
|
| 439 |
""" Executes the firmware at 'addr' and passes all control to it. """
|
438 |
""" Executes the firmware at 'addr' and passes all control to it. """
|
| 440 |
return self.lib.monitorcommand(struct.pack("IIII", 24, addr, 0, 0), "III", (None, None, None))
|
439 |
return self.lib.monitorcommand(struct.pack("IIII", 24, addr, 0, 0))
|
| 441 |
|
440 |
|
| 442 |
def aesencrypt(self, addr, size, keyindex):
|
441 |
def aesencrypt(self, addr, size, keyindex):
|
| 443 |
""" Encrypts the buffer at 'addr' with the specified size
|
442 |
""" Encrypts the buffer at 'addr' with the specified size
|
| 444 |
with the hardware AES key index 'keyindex'
|
443 |
with the hardware AES key index 'keyindex'
|
| 445 |
"""
|
444 |
"""
|
| Line 492... |
Line 491... |
| 492 |
def connect(self):
|
491 |
def connect(self):
|
| 493 |
self.dev = Dev(self.idVendor, self.idProduct)
|
492 |
self.dev = Dev(self.idVendor, self.idProduct)
|
| 494 |
self.connected = True
|
493 |
self.connected = True
|
| 495 |
|
494 |
|
| 496 |
def monitorcommand(self, cmd, rcvdatatypes=None, rcvstruct=None):
|
495 |
def monitorcommand(self, cmd, rcvdatatypes=None, rcvstruct=None):
|
| 497 |
self.dev.cout(cmd)
|
496 |
writelen = self.dev.cout(cmd)
|
| 498 |
if rcvdatatypes:
|
497 |
if rcvdatatypes:
|
| 499 |
rcvdatatypes = "I" + rcvdatatypes # add the response
|
498 |
rcvdatatypes = "I" + rcvdatatypes # add the response
|
| 500 |
data = self.dev.cin(struct.calcsize(rcvdatatypes))
|
499 |
data = self.dev.cin(struct.calcsize(rcvdatatypes))
|
| 501 |
data = struct.unpack(rcvdatatypes, data)
|
500 |
data = struct.unpack(rcvdatatypes, data)
|
| 502 |
response = data[0]
|
501 |
response = data[0]
|
| Line 515... |
Line 514... |
| 515 |
raise DeviceError("The device does not support this command.")
|
514 |
raise DeviceError("The device does not support this command.")
|
| 516 |
elif libembiosdata.responsecodes[response] == "invalid":
|
515 |
elif libembiosdata.responsecodes[response] == "invalid":
|
| 517 |
raise DeviceError("Invalid command! This should NOT happen!")
|
516 |
raise DeviceError("Invalid command! This should NOT happen!")
|
| 518 |
elif libembiosdata.responsecodes[response] == "busy":
|
517 |
elif libembiosdata.responsecodes[response] == "busy":
|
| 519 |
raise DeviceError("Device busy")
|
518 |
raise DeviceError("Device busy")
|
| - |
|
519 |
else:
|
| - |
|
520 |
return writelen
|
| 520 |
|
521 |
|
| 521 |
|
522 |
|
| 522 |
class Dev(object):
|
523 |
class Dev(object):
|
| 523 |
def __init__(self, idVendor, idProduct):
|
524 |
def __init__(self, idVendor, idProduct):
|
| 524 |
self.idVendor = idVendor
|
525 |
self.idVendor = idVendor
|