Fix code/eeprom overflow and overlap handling
This commit is contained in:
parent
ba8d26059c
commit
320faa00f2
@ -1575,11 +1575,11 @@ class StcGal:
|
|||||||
bindata = opts.code_binary.read()
|
bindata = opts.code_binary.read()
|
||||||
|
|
||||||
# warn if it overflows
|
# warn if it overflows
|
||||||
|
if len(bindata) > code_size:
|
||||||
|
print("WARNING: code_binary overflows into eeprom segment!", file=sys.stderr)
|
||||||
if len(bindata) > (code_size + ee_size):
|
if len(bindata) > (code_size + ee_size):
|
||||||
print("WARNING: code_binary truncated!", file=sys.stderr)
|
print("WARNING: code_binary truncated!", file=sys.stderr)
|
||||||
bindata = bindata[0:code_size + ee_size]
|
bindata = bindata[0:code_size + ee_size]
|
||||||
elif len(bindata) > code_size:
|
|
||||||
print("WARNING: code_binary overflows into eeprom segment!", file=sys.stderr)
|
|
||||||
|
|
||||||
# add eeprom data if supplied
|
# add eeprom data if supplied
|
||||||
if opts.eeprom_binary:
|
if opts.eeprom_binary:
|
||||||
@ -1589,6 +1589,9 @@ class StcGal:
|
|||||||
eedata = eedata[0:ee_size]
|
eedata = eedata[0:ee_size]
|
||||||
if len(bindata) < code_size:
|
if len(bindata) < code_size:
|
||||||
bindata += bytes(code_size - len(bindata))
|
bindata += bytes(code_size - len(bindata))
|
||||||
|
elif len(bindata) > code_size:
|
||||||
|
print("WARNING: eeprom_binary overlaps code_binary", file=sys.stderr)
|
||||||
|
bindata = bindata[0:code_size]
|
||||||
bindata += eedata
|
bindata += eedata
|
||||||
|
|
||||||
# pad to 256 byte boundary
|
# pad to 256 byte boundary
|
||||||
|
Loading…
Reference in New Issue
Block a user