Erase flash in 512 byte blocks

This is the IAP flash memory block size, and the BSL apparently
expects erase to be done aligned to 512 byte.
This commit is contained in:
Grigori Goronzy
2014-01-13 12:18:08 +01:00
parent 9fd960f45a
commit b3230814a8
2 changed files with 6 additions and 2 deletions

View File

@ -1260,8 +1260,8 @@ class Stc12Protocol:
Erase the flash memory with a block-erase command.
"""
blks = (erase_size + 255) // 256
size = (flash_size + 255) // 256
blks = ((erase_size + 511) // 512) * 2
size = ((flash_size + 511) // 512) * 2
print("Erasing %d blocks: " % blks, end="")
sys.stdout.flush()
packet = bytes([0x84, 0xff, 0x00, blks, 0x00, 0x00, size,