1- #!/usr/local/opt/python/ bin/python2.7
1+ #!/usr/bin/env python
22#
33# ESP8266 & ESP32 ROM Bootloader Utility
44# Copyright (C) 2014-2016 Fredrik Ahlberg, Angus Gratton, Espressif Systems (Shanghai) PTE LTD, other contributors as noted.
3030import zlib
3131import shlex
3232
33- __version__ = "2.0"
33+ __version__ = "2.0.1 "
3434
3535MAX_UINT32 = 0xffffffff
3636MAX_UINT24 = 0xffffff
@@ -1265,6 +1265,13 @@ class ESP32FirmwareImage(BaseFirmwareImage):
12651265
12661266 ROM_LOADER = ESP32ROM
12671267
1268+ # 16 byte extended header contains WP pin number (byte), then 6 half-byte drive stength
1269+ # config fields, then 12 reserved bytes. None of this is exposed in esptool.py right now,
1270+ # but we need to set WP to 0xEE (disabled) to avoid problems when remapping SPI flash
1271+ # pins via efuse (for example on ESP32-D2WD).
1272+ EXTENDED_HEADER = [0xEE ] + ([0 ] * 15 )
1273+ EXTENDED_HEADER_STRUCT_FMT = "B" * 16
1274+
12681275 def __init__ (self , load_file = None ):
12691276 super (ESP32FirmwareImage , self ).__init__ ()
12701277 self .flash_mode = 0
@@ -1273,11 +1280,11 @@ def __init__(self, load_file=None):
12731280
12741281 if load_file is not None :
12751282 segments = self .load_common_header (load_file , ESPLoader .ESP_IMAGE_MAGIC )
1276- additional_header = list (struct .unpack ("B" * 16 , load_file .read (16 )))
1283+ additional_header = list (struct .unpack (self . EXTENDED_HEADER_STRUCT_FMT , load_file .read (16 )))
12771284
12781285 # check these bytes are unused
1279- if additional_header != [ 0 ] * 16 :
1280- print ("WARNING: ESP32 image header contains unknown flags. Possibly this image is from a newer version of esptool.py" )
1286+ if additional_header != self . EXTENDED_HEADER :
1287+ print ("WARNING: ESP32 image header contains unknown flags. Possibly this image is from a different version of esptool.py" )
12811288
12821289 for _ in range (segments ):
12831290 self .load_segment (load_file )
@@ -1301,7 +1308,7 @@ def save(self, filename):
13011308
13021309 # first 4 bytes of header are read by ROM bootloader for SPI
13031310 # config, but currently unused
1304- f .write (b' \x00 ' * 16 )
1311+ f .write (struct . pack ( self . EXTENDED_HEADER_STRUCT_FMT , * self . EXTENDED_HEADER ) )
13051312
13061313 checksum = ESPLoader .ESP_CHECKSUM_MAGIC
13071314 last_addr = None
0 commit comments