stc15: erase EEPROM flash when needed

If option eeprom_erase_enabled is False, we need to signal to the BSL
to explicitly erase EEPROM flash when needed.

Addresses #59.
This commit is contained in:
Grigori Goronzy 2021-01-09 02:16:27 +01:00
parent 482e6b139f
commit 187aa9a3cf

View File

@ -1464,11 +1464,15 @@ class Stc15Protocol(Stc15AProtocol):
Note that this protocol always seems to erase everything. Note that this protocol always seems to erase everything.
""" """
# XXX: how does partial erase work?
print("Erasing flash: ", end="") print("Erasing flash: ", end="")
sys.stdout.flush() sys.stdout.flush()
packet = bytes([0x03, 0x00]) packet = bytes([0x03])
if erase_size <= flash_size:
# erase flash only
packet += bytes([0x00])
else:
# erase flash and eeprom
packet += bytes([0x01])
if self.bsl_version >= 0x72: if self.bsl_version >= 0x72:
packet += bytes([0x00, 0x5a, 0xa5]) packet += bytes([0x00, 0x5a, 0xa5])
self.write_packet(packet) self.write_packet(packet)