Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ETX flashing #97

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions python/ETXinitPassthrough.py

This file was deleted.

7 changes: 2 additions & 5 deletions python/binary_flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from os.path import dirname

import UnifiedConfiguration
import ETXinitPassthrough
import serials_find
import upload_via_esp8266_backpack

Expand Down Expand Up @@ -73,9 +72,8 @@ def upload_esp8266_uart(args):
def upload_esp8266_etx(args):
if args.port == None:
args.port = serials_find.get_serial_port()
ETXinitPassthrough.etx_passthrough_init(args.port, 460800)
try:
esptool.main(['--passthrough', '--chip', 'esp8266', '--port', args.port, '--baud', '460800', '--before', 'no_reset', '--after', 'hard_reset', 'write_flash', '0x0000', args.file.name])
esptool.main(['--passthrough', '--chip', 'esp8266', '--port', args.port, '--baud', '460800', '--before', 'etx', '--after', 'hard_reset', 'write_flash', '0x0000', args.file.name])
except:
return ElrsUploadResult.ErrorGeneral
return ElrsUploadResult.Success
Expand All @@ -102,10 +100,9 @@ def upload_esp32_uart(args):
def upload_esp32_etx(args):
if args.port == None:
args.port = serials_find.get_serial_port()
ETXinitPassthrough.etx_passthrough_init(args.port, 460800)
try:
dir = os.path.dirname(args.file.name)
esptool.main(['--passthrough', '--chip', 'esp32', '--port', args.port, '--baud', '460800', '--before', 'no_reset', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', '0x1000', os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
esptool.main(['--passthrough', '--chip', 'esp32', '--port', args.port, '--baud', '460800', '--before', 'etx', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', '0x1000', os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
except:
return ElrsUploadResult.ErrorGeneral
return ElrsUploadResult.Success
Expand Down
3 changes: 0 additions & 3 deletions python/build_env_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import shutil
import upload_via_esp8266_backpack
import esp_compress
import ETXinitPassthrough
import UnifiedConfiguration

platform = env.get('PIOPLATFORM', '')
Expand All @@ -27,8 +26,6 @@ def copy_bootfile(source, target, env):
if "_WIFI" in target_name:
env.Replace(UPLOAD_PROTOCOL="custom")
env.Replace(UPLOADCMD=upload_via_esp8266_backpack.on_upload)
if "_ETX" in target_name:
env.AddPreAction("upload", ETXinitPassthrough.init_passthrough)

elif platform in ['espressif32']:
if "_WIFI" in target_name:
Expand Down
2 changes: 1 addition & 1 deletion python/external/esptool/esptool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def main(argv=None, esp=None):
parser.add_argument(
"--before",
help="What to do before connecting to the chip",
choices=["default_reset", "usb_reset", "no_reset", "no_reset_no_sync", "passthru"],
choices=["default_reset", "usb_reset", "no_reset", "no_reset_no_sync", "passthru", "etx"],
default=os.environ.get("ESPTOOL_BEFORE", "default_reset"),
)

Expand Down
15 changes: 15 additions & 0 deletions python/external/esptool/esptool/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,21 @@ def bootloader_reset(self, usb_jtag_serial=False, extra_delay=False, mode="defau
time.sleep(0.2)
self._setDTR(False) # IO0=HIGH, done
time.sleep(0.1)
elif mode == 'etx':
self._port.flush()
self._port.write(b"set rfmod 0 power off\n")
time.sleep(0.1)
self._port.write(b"set pulses 0\n")
time.sleep(0.5)
self._port.write(b"set rfmod 0 power on\n")
time.sleep(2.5)
self._port.write(b"set rfmod 0 bootpin 1\n")
time.sleep(0.1)
self._port.write(b"set rfmod 0 bootpin 0\n")
time.sleep(0.1)
cmd = "serialpassthrough rfmod 0 %s" % self._port.baudrate
self._port.write(cmd.encode("utf-8"))
self._port.write(b'\n')
elif mode != 'no_reset':
self._setDTR(False) # IO0=HIGH
self._setRTS(True) # EN=LOW, chip in reset
Expand Down
2 changes: 1 addition & 1 deletion targets/txbp_esp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ upload_resetmethod = nodemcu
[env:ESP_TX_Backpack_via_ETX]
extends = env:ESP_TX_Backpack_via_UART
upload_speed = 460800
upload_command = python "$PROJECT_DIR/python/external/esptool/esptool.py" --passthrough -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp8266 --before no_reset --after soft_reset write_flash 0x0000 "$SOURCE"
upload_command = python "$PROJECT_DIR/python/external/esptool/esptool.py" --passthrough -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp8266 --before etx --after soft_reset write_flash 0x0000 "$SOURCE"

[env:ESP_TX_Backpack_via_WIFI]
extends = env:ESP_TX_Backpack_via_UART
Expand Down