Skip to content

Commit

Permalink
Upgrade to esptool 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstoer committed Jul 15, 2017
1 parent b26b0b2 commit 55d3169
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions esptool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/opt/python/bin/python2.7
#!/usr/bin/env python
#
# ESP8266 & ESP32 ROM Bootloader Utility
# Copyright (C) 2014-2016 Fredrik Ahlberg, Angus Gratton, Espressif Systems (Shanghai) PTE LTD, other contributors as noted.
Expand Down Expand Up @@ -30,7 +30,7 @@
import zlib
import shlex

__version__ = "2.0"
__version__ = "2.0.1"

MAX_UINT32 = 0xffffffff
MAX_UINT24 = 0xffffff
Expand Down Expand Up @@ -1265,6 +1265,13 @@ class ESP32FirmwareImage(BaseFirmwareImage):

ROM_LOADER = ESP32ROM

# 16 byte extended header contains WP pin number (byte), then 6 half-byte drive stength
# config fields, then 12 reserved bytes. None of this is exposed in esptool.py right now,
# but we need to set WP to 0xEE (disabled) to avoid problems when remapping SPI flash
# pins via efuse (for example on ESP32-D2WD).
EXTENDED_HEADER = [0xEE] + ([0] * 15)
EXTENDED_HEADER_STRUCT_FMT = "B" * 16

def __init__(self, load_file=None):
super(ESP32FirmwareImage, self).__init__()
self.flash_mode = 0
Expand All @@ -1273,11 +1280,11 @@ def __init__(self, load_file=None):

if load_file is not None:
segments = self.load_common_header(load_file, ESPLoader.ESP_IMAGE_MAGIC)
additional_header = list(struct.unpack("B" * 16, load_file.read(16)))
additional_header = list(struct.unpack(self.EXTENDED_HEADER_STRUCT_FMT, load_file.read(16)))

# check these bytes are unused
if additional_header != [0] * 16:
print("WARNING: ESP32 image header contains unknown flags. Possibly this image is from a newer version of esptool.py")
if additional_header != self.EXTENDED_HEADER:
print("WARNING: ESP32 image header contains unknown flags. Possibly this image is from a different version of esptool.py")

for _ in range(segments):
self.load_segment(load_file)
Expand All @@ -1301,7 +1308,7 @@ def save(self, filename):

# first 4 bytes of header are read by ROM bootloader for SPI
# config, but currently unused
f.write(b'\x00' * 16)
f.write(struct.pack(self.EXTENDED_HEADER_STRUCT_FMT, *self.EXTENDED_HEADER))

checksum = ESPLoader.ESP_CHECKSUM_MAGIC
last_addr = None
Expand Down

0 comments on commit 55d3169

Please sign in to comment.