Skip to content

Commit

Permalink
fix(esp32-c2): Enable flashing in secure download mode
Browse files Browse the repository at this point in the history
Closes #895
  • Loading branch information
radimkarnis committed Jul 18, 2023
1 parent 9b95de8 commit e862e10
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion esptool/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def write_flash(esp, args):
flash_end = flash_size_bytes(
detect_flash_size(esp) if args.flash_size == "keep" else args.flash_size
)
if flash_end is not None: # Secure download mode
if flash_end is not None: # Not in secure download mode
for address, argfile in args.addr_filename:
argfile.seek(0, os.SEEK_END)
if address + argfile.tell() > flash_end:
Expand Down
2 changes: 1 addition & 1 deletion esptool/targets/esp32c2.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def change_baud(self, baud):

def _post_connect(self):
# ESP32C2 ECO0 is no longer supported by the flasher stub
if self.get_chip_revision() == 0:
if not self.secure_download_mode and self.get_chip_revision() == 0:
self.stub_is_disabled = True
self.IS_STUB = False

Expand Down
2 changes: 2 additions & 0 deletions esptool/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def flash_size_bytes(size):
"""Given a flash size of the type passed in args.flash_size
(ie 512KB or 1MB) then return the size in bytes.
"""
if size is None:
return None
if "MB" in size:
return int(size[: size.index("MB")]) * 1024 * 1024
elif "KB" in size:
Expand Down

0 comments on commit e862e10

Please sign in to comment.