From 3c03159ca8bd62200c979805a526b8486d3d5b3c Mon Sep 17 00:00:00 2001 From: Paul Kendall Date: Tue, 3 May 2022 07:44:25 +1200 Subject: [PATCH] Passthrough flashing (#66) * DUPLETX & HM target with UART passthrough flashing * Beef up the passthrough speed --- python/esptool-3.0/esptool.py | 19 +++++++++++++++++-- targets/dupletx_tx.ini | 5 +++++ targets/happymodel_tx.ini | 5 +++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/python/esptool-3.0/esptool.py b/python/esptool-3.0/esptool.py index 99fee40..6f1fdea 100644 --- a/python/esptool-3.0/esptool.py +++ b/python/esptool-3.0/esptool.py @@ -473,7 +473,22 @@ def _connect_attempt(self, mode='default_reset', esp32r0_delay=False): # # DTR & RTS are active low signals, # ie True = pin @ 0V, False = pin @ VCC. - if mode != 'no_reset': + if mode == 'passthru': + self._setDTR(False) # IO0=HIGH + # self._setRTS(True) # EN=LOW, chip in reset + time.sleep(0.1) + # if esp32r0_delay: + # # Some chips are more likely to trigger the esp32r0 + # # watchdog reset silicon bug if they're held with EN=LOW + # # for a longer period + # time.sleep(1.2) + self._setRTS(False) # EN=HIGH, chip out of reset + time.sleep(4.0) # Wait for firmware to start + self._setDTR(True) # IO0=LOW + time.sleep(0.2) + self._setDTR(False) # IO0=HIGH, done + time.sleep(0.2) + elif mode != 'no_reset': self._setDTR(False) # IO0=HIGH self._setRTS(True) # EN=LOW, chip in reset time.sleep(0.1) @@ -3284,7 +3299,7 @@ def main(custom_commandline=None): parser.add_argument( '--before', help='What to do before connecting to the chip', - choices=['default_reset', 'no_reset', 'no_reset_no_sync'], + choices=['default_reset', 'no_reset', 'no_reset_no_sync', 'passthru'], default=os.environ.get('ESPTOOL_BEFORE', 'default_reset')) parser.add_argument( diff --git a/targets/dupletx_tx.ini b/targets/dupletx_tx.ini index 8fe4d51..1f6d961 100644 --- a/targets/dupletx_tx.ini +++ b/targets/dupletx_tx.ini @@ -17,3 +17,8 @@ extends = env:DUPLETX_TX_Backpack_via_UART [env:DUPLETX_TX_Backpack_via_WIFI] extends = env:DUPLETX_TX_Backpack_via_UART + +[env:DUPLETX_TX_Backpack_via_PASSTHRU] +extends = env:DUPLETX_TX_Backpack_via_UART +upload_speed = 230400 +upload_command = python "$PROJECT_DIR/python/esptool-3.0/esptool.py" -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp8266 --before passthru --after soft_reset write_flash 0x0000 "$SOURCE" diff --git a/targets/happymodel_tx.ini b/targets/happymodel_tx.ini index fd68200..40548df 100644 --- a/targets/happymodel_tx.ini +++ b/targets/happymodel_tx.ini @@ -12,3 +12,8 @@ build_flags = [env:HappyModel_TX_Backpack_via_WIFI] extends = env:HappyModel_TX_Backpack_via_UART + +[env:HappyModel_TX_Backpack_via_PASSTHRU] +extends = env:HappyModel_TX_Backpack_via_UART +upload_speed = 230400 +upload_command = python "$PROJECT_DIR/python/esptool-3.0/esptool.py" -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp8266 --before passthru --after soft_reset write_flash 0x0000 "$SOURCE"