Skip to content

Commit

Permalink
Merge pull request #266 from espressif/fix/respect_sdkconfig_items_wh…
Browse files Browse the repository at this point in the history
…ile_erase_flash
  • Loading branch information
hfudev authored Mar 1, 2024
2 parents 491a429 + 71c602d commit 28a52c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 15 additions & 2 deletions pytest-embedded-idf/pytest_embedded_idf/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,24 @@ def load_ram(self) -> None:
def _force_flag(self):
if self.esp_flash_force:
return ['--force']
config = self.app.sdkconfig
if any((config.get('SECURE_FLASH_ENC_ENABLED', False), config.get('SECURE_BOOT', False))):

if any(
(
self.app.sdkconfig.get('SECURE_FLASH_ENC_ENABLED', False),
self.app.sdkconfig.get('SECURE_BOOT', False),
)
):
return ['--force']

return []

@EspSerial.use_esptool()
def erase_flash(self, force: bool = False):
if self._force_flag() or force:
super().erase_flash(force=True)
else:
super().erase_flash()

@EspSerial.use_esptool()
def flash(self) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ def hard_reset(self):
self.esp.hard_reset()

@use_esptool()
def erase_flash(self):
def erase_flash(self, force: bool = False) -> None:
"""Erase the complete flash"""
logging.info('Erasing the flash')
options = ['erase_flash']
if self.esp_flash_force:

if force or self.esp_flash_force:
options.append('--force')

esptool.main(options, esp=self.esp)
Expand Down

0 comments on commit 28a52c8

Please sign in to comment.