fix(write_flash): Fix --erase-all option

Closes https://github.com/espressif/esptool/issues/805
This commit is contained in:
radim.karnis
2022-12-06 13:51:57 +01:00
committed by Radim Karniš
parent 4d501009c9
commit d0af65f1cb
2 changed files with 7 additions and 0 deletions

View File

@@ -334,6 +334,8 @@ def write_flash(esp, args):
image = LoadFirmwareImage(esp.CHIP_NAME, argfile)
except (FatalError, struct.error, RuntimeError):
continue
finally:
argfile.seek(0) # LoadFirmwareImage changes the file handle position
if image.chip_id != esp.IMAGE_CHIP_ID:
raise FatalError(
f"{argfile.name} is not an {esp.CHIP_NAME} image. "

View File

@@ -513,6 +513,11 @@ class TestFlashing(EsptoolTestCase):
assert "or higher (this chip is revision" in output
assert "Use --force to flash anyway." in output
def test_erase_before_write(self):
output = self.run_esptool("write_flash --erase-all 0x0 images/one_kb.bin")
assert "Chip erase completed successfully" in output
assert "Hash of data verified" in output
class TestFlashSizes(EsptoolTestCase):
def test_high_offset(self):