Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Add logic to revert to 115200 upload rate if faster one fails (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter authored Jul 13, 2020
1 parent 127731e commit 0220e98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ venv.bak/
.mypy_cache/

config/

.DS_Store
/.idea/
16 changes: 15 additions & 1 deletion esphomeflasher/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,28 @@ 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:
stub_chip.change_baud(args.upload_baud_rate)
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,
Expand Down

0 comments on commit 0220e98

Please # to comment.