From 550c7a44460b5085a62e075c69b387843b24505a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 22 Aug 2016 18:31:44 +0800 Subject: [PATCH 1/2] esptool.py: Set higher baud rates on ESP32 --- bin/esptool.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/esptool.py b/bin/esptool.py index 345fb2fd9..284d9e95d 100755 --- a/bin/esptool.py +++ b/bin/esptool.py @@ -196,6 +196,10 @@ class ESPROM(object): else: # otherwise, just return the 'val' field which comes from the reply header (this is used by read_reg) return val + def flush_input(self): + self._port.flushInput() + self._slip_reader = slip_reader(self._port) + def sync(self): """ Perform a connection test """ self.command(ESPROM.ESP_SYNC, '\x07\x07\x12\x20' + 32 * '\x55') @@ -223,8 +227,7 @@ class ESPROM(object): last_exception = None for _ in xrange(4): try: - self._port.flushInput() - self._slip_reader = slip_reader(self._port) + self.flush_input() self._port.flushOutput() self.sync() self._port.timeout = 5 @@ -377,6 +380,9 @@ class ESP8266ROM(ESPROM): '4MB-c1':0x60, '4MB-c2':0x70} + def change_baud(self, baud): + pass # no change baud command on ESP8266 ROM + def chip_id(self): """ Read Chip ID from OTP ROM - see http://esp8266-re.foogod.com/wiki/System_get_chip_id_%28IoT_RTOS_SDK_0.9.9%29 """ id0 = self.read_reg(self.ESP_OTP_MAC0) @@ -523,13 +529,13 @@ class ESP32ROM(ESP31ROM): # the MD5 command is special ( return self.check_command('calculate md5sum', self.ESP_SPI_FLASH_MD5, struct.pack(' Date: Mon, 22 Aug 2016 18:43:47 +0800 Subject: [PATCH 2/2] esptool.py & Makefile: Fix compressed upload support (enabled by default) --- components/bootloader/Makefile.projbuild | 2 +- components/esptool_py/Makefile.projbuild | 7 ++++--- make/project.mk | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/bootloader/Makefile.projbuild b/components/bootloader/Makefile.projbuild index 073112feb..c80878d42 100644 --- a/components/bootloader/Makefile.projbuild +++ b/components/bootloader/Makefile.projbuild @@ -33,7 +33,7 @@ clean: bootloader-clean bootloader: $(BOOTLOADER_BIN) @echo "Bootloader built. Default flash command is:" - @echo "$(ESPTOOLPY_SERIAL) write_flash 0x1000 $(BOOTLOADER_BIN)" + @echo "$(ESPTOOLPY_WRITE_FLASH) 0x1000 $(BOOTLOADER_BIN)" all_binaries: $(BOOTLOADER_BIN) diff --git a/components/esptool_py/Makefile.projbuild b/components/esptool_py/Makefile.projbuild index c9000076f..576e526d5 100644 --- a/components/esptool_py/Makefile.projbuild +++ b/components/esptool_py/Makefile.projbuild @@ -12,7 +12,8 @@ PYTHON ?= $(call dequote,$(CONFIG_PYTHON)) ESPTOOLPY := $(PYTHON) $(IDF_PATH)/bin/esptool.py --chip esp32 ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD) -APP_FLASH_COMMAND=$(ESPTOOLPY_SERIAL) write_flash $(CONFIG_APP_OFFSET) $(APP_BIN) +ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z) + ESPTOOL_ALL_FLASH_ARGS += $(CONFIG_APP_OFFSET) $(APP_BIN) $(APP_BIN): $(APP_ELF) @@ -20,7 +21,7 @@ $(APP_BIN): $(APP_ELF) flash: all_binaries @echo "Flashing project app to $(CONFIG_APP_OFFSET)..." - $(Q) $(ESPTOOLPY_SERIAL) write_flash $(ESPTOOL_ALL_FLASH_ARGS) + $(Q) $(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS) app-flash: $(APP_BIN) - $(Q) $(APP_FLASH_COMMAND) + $(Q) $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN) diff --git a/make/project.mk b/make/project.mk index dd557e48a..bfc9a2f7f 100644 --- a/make/project.mk +++ b/make/project.mk @@ -13,7 +13,7 @@ .PHONY: build-components menuconfig all build clean all_binaries all: all_binaries # other components will add dependencies to 'all_binaries' @echo "To flash all build output, run 'make flash' or:" - @echo $(ESPTOOLPY_SERIAL) write_flash $(ESPTOOL_ALL_FLASH_ARGS) + @echo $(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS) # (the reason all_binaries is used instead of 'all' is so that the flash target # can build everything without triggering the per-component "to flash..." @@ -174,7 +174,7 @@ $(APP_ELF): $(addsuffix -build,$(notdir $(COMPONENT_PATHS_BUILDABLE))) # component's Makefile.projbuild app: $(APP_BIN) @echo "App built. Default flash app command is:" - @echo $(APP_FLASH_COMMAND) # APP_FLASH_COMMAND is set in esptool_py's Makefile.projbuild + @echo $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN) all_binaries: $(APP_BIN)