Fix MCU firmware loading
This commit is contained in:
parent
09d04da1d8
commit
1946b6351e
|
@ -22,12 +22,13 @@ import struct
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
class HexLoader:
|
class HexLoader:
|
||||||
def __init__(self, card, cla=0xF0, secure=False, key=None):
|
def __init__(self, card, cla=0xF0, secure=False, key=None, relative=True):
|
||||||
self.card = card
|
self.card = card
|
||||||
self.cla = cla
|
self.cla = cla
|
||||||
self.secure = secure
|
self.secure = secure
|
||||||
self.key = key
|
self.key = key
|
||||||
self.iv = "\x00" * 16;
|
self.iv = "\x00" * 16;
|
||||||
|
self.relative = relative
|
||||||
|
|
||||||
def crc16(self, data):
|
def crc16(self, data):
|
||||||
TABLE_CRC16_CCITT = [
|
TABLE_CRC16_CCITT = [
|
||||||
|
@ -132,7 +133,7 @@ class HexLoader:
|
||||||
|
|
||||||
def load(self, erase_u8, max_length_per_apdu, hexAreas, bootaddr):
|
def load(self, erase_u8, max_length_per_apdu, hexAreas, bootaddr):
|
||||||
initialAddress = 0
|
initialAddress = 0
|
||||||
if len(hexAreas) <> 0:
|
if (len(hexAreas) <> 0) and self.relative:
|
||||||
initialAddress = hexAreas[0].getStart()
|
initialAddress = hexAreas[0].getStart()
|
||||||
sha256 = hashlib.new('sha256')
|
sha256 = hashlib.new('sha256')
|
||||||
for area in hexAreas:
|
for area in hexAreas:
|
||||||
|
@ -162,7 +163,7 @@ class HexLoader:
|
||||||
|
|
||||||
def run(self, hexAreas, bootaddr):
|
def run(self, hexAreas, bootaddr):
|
||||||
initialAddress = 0
|
initialAddress = 0
|
||||||
if len(hexAreas) <> 0:
|
if (len(hexAreas) <> 0) and self.relative:
|
||||||
initialAddress = hexAreas[0].getStart()
|
initialAddress = hexAreas[0].getStart()
|
||||||
self.boot(bootaddr - initialAddress)
|
self.boot(bootaddr - initialAddress)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue