Add logic to revert to 115200 upload rate if faster one fails (#16)

This commit is contained in:
Otto Winter 2020-07-13 23:19:36 +02:00 committed by GitHub
parent 127731e221
commit 0220e98b8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

3
.gitignore vendored
View File

@ -104,3 +104,6 @@ venv.bak/
.mypy_cache/
config/
.DS_Store
/.idea/

View File

@ -112,6 +112,7 @@ def run_esphomeflasher(argv):
print(" - MAC Address: {}".format(info.mac))
stub_chip = chip_run_stub(chip)
flash_size = None
if args.upload_baud_rate != 115200:
try:
@ -119,7 +120,20 @@ def run_esphomeflasher(argv):
except esptool.FatalError as err:
raise EsphomeflasherError("Error changing ESP upload baud rate: {}".format(err))
flash_size = detect_flash_size(stub_chip)
# Check if the higher baud rate works
try:
flash_size = detect_flash_size(stub_chip)
except esptool.FatalError as err:
# Go back to old baud rate by recreating chip instance
print("Chip does not support baud rate {}, changing to 115200".format(args.upload_baud_Rate))
stub_chip._port.close()
chip = detect_chip(port, args.esp8266, args.esp32)
stub_chip = chip_run_stub(chip)
if flash_size is None:
flash_size = detect_flash_size(stub_chip)
print(" - Flash Size: {}".format(flash_size))
mock_args = configure_write_flash_args(info, firmware, flash_size,