]> granicus.if.org Git - esp-idf/commitdiff
esptool: Add new options to reset before/after, detect flash size
authorAngus Gratton <angus@espressif.com>
Tue, 20 Dec 2016 07:02:47 +0000 (18:02 +1100)
committerAngus Gratton <angus@espressif.com>
Fri, 30 Dec 2016 03:19:46 +0000 (14:19 +1100)
components/bootloader/Makefile.projbuild
components/esptool_py/Kconfig.projbuild
components/esptool_py/Makefile.projbuild
components/esptool_py/esptool

index 35be94e4a39b5630b33999c22d4af50001349aa0..9e7b17b65fc7cda5d6cf80d9dfa9998115e78c68 100644 (file)
@@ -50,11 +50,14 @@ else ifdef CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
 
 # One time flashing requires user to run esptool.py command themselves,
 # and warning is printed about inability to reflash.
+#
+# The flashing command is deliberately printed without an auto-reset
+# step, so the device doesn't immediately reset to flash itself.
 
 bootloader: $(BOOTLOADER_BIN)
        @echo $(SEPARATOR)
        @echo "Bootloader built. One-time flash command is:"
-       @echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
+       @echo "$(subst hard_reset,no_reset,$(ESPTOOLPY_WRITE_FLASH)) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
        @echo $(SEPARATOR)
        @echo "* IMPORTANT: After first boot, BOOTLOADER CANNOT BE RE-FLASHED on same device"
 
index 8bab51225eb3506252f2bd69346d6fa1a9efb6be..dd2077cbb3f37b0b8c6f5bf993c6d8184ec69d8a 100644 (file)
@@ -121,4 +121,61 @@ config ESPTOOLPY_FLASHSIZE
        default "8MB" if ESPTOOLPY_FLASHSIZE_8MB
        default "16MB" if ESPTOOLPY_FLASHSIZE_16MB
 
+config ESPTOOLPY_FLASHSIZE_DETECT
+    bool "Detect flash size when flashing bootloader"
+    default y
+    help
+        If this option is set, 'make flash' targets will automatically detect
+        the flash size and update the bootloader image when flashing.
+
+choice ESPTOOLPY_BEFORE
+    prompt "Before flashing"
+    default ESPTOOLPY_BEFORE_RESET
+    help
+        Configure whether esptool.py should reset the ESP32 before flashing.
+
+        Automatic resetting depends on the RTS & DTR signals being
+        wired from the serial port to the ESP32. Most USB development
+        boards do this internally.
+
+        The "Reset with ESP32R0 Windows workaround" option works
+        around an automatic reset bug in hardware, when using Windows
+        with some development boards. This fix only works if you're
+        using a silicon revision 0 ESP32.
+
+config ESPTOOLPY_BEFORE_RESET
+    bool "Reset to bootloader"
+config ESPTOOLPY_BEFORE_NORESET
+    bool "No reset"
+config ESPTOOLPY_BEFORE_ESP32R0
+    bool "Reset with ESP32R0 Windows workaround"
+endchoice
+
+config ESPTOOLPY_BEFORE
+    string
+    default "default_reset" if ESPTOOLPY_BEFORE_RESET
+    default "no_reset" if ESPTOOLPY_BEFORE_NORESET
+    default "esp32r0" if ESPTOOLPY_BEFORE_ESP32R0
+
+choice ESPTOOLPY_AFTER
+    prompt "After flashing"
+    default ESPTOOLPY_AFTER_RESET
+    help
+        Configure whether esptool.py should reset the ESP32 after flashing.
+
+        Automatic resetting depends on the RTS & DTR signals being
+        wired from the serial port to the ESP32. Most USB development
+        boards do this internally.
+
+config ESPTOOLPY_AFTER_RESET
+    bool "Reset after flashing"
+config ESPTOOLPY_AFTER_NORESET
+    bool "Stay in bootloader"
+endchoice
+
+config ESPTOOLPY_AFTER
+    string
+    default "hard_reset" if ESPTOOLPY_AFTER_RESET
+    default "no_reset" if ESPTOOLPY_AFTER_NORESET
+
 endmenu
index b5992a4d963cf9c7c1f24b651404dfa73a8c1bd1..88b5894731a65e3f39278e439572debd0674bf44 100644 (file)
@@ -13,7 +13,7 @@ PYTHON ?= $(call dequote,$(CONFIG_PYTHON))
 #
 ESPTOOLPY_SRC := $(COMPONENT_PATH)/esptool/esptool.py
 ESPTOOLPY := $(PYTHON) $(ESPTOOLPY_SRC) --chip esp32
-ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD)
+ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER)
 
 # Supporting esptool command line tools
 ESPEFUSEPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espefuse.py
@@ -21,10 +21,15 @@ ESPSECUREPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espsecure.py
 export ESPSECUREPY  # is used in bootloader_support component
 
 ESPTOOL_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size $(ESPFLASHSIZE)
+ifdef CONFIG_ESPTOOLPY_FLASHSIZE_DETECT
+ESPTOOL_WRITE_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size detect
+else
+ESPTOOL_WRITE_FLASH_OPTIONS := $(ESPTOOL_FLASH_OPTIONS)
+endif
 
 ESPTOOL_ELF2IMAGE_OPTIONS :=
 
-ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z) $(ESPTOOL_FLASH_OPTIONS)
+ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z) $(ESPTOOL_WRITE_FLASH_OPTIONS)
 
 ESPTOOL_ALL_FLASH_ARGS += $(CONFIG_APP_OFFSET) $(APP_BIN)
 
index adc914b91ac6d2cfd1ace56307b4374eb9439e14..fe69994270e2a450aad3e94a409b58460b1a214f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit adc914b91ac6d2cfd1ace56307b4374eb9439e14
+Subproject commit fe69994270e2a450aad3e94a409b58460b1a214f