mirror of
https://github.com/esphome/esphome-flasher.git
synced 2024-11-22 11:55:45 +01:00
Add logic to revert to 115200 upload rate if faster one fails (#16)
This commit is contained in:
parent
127731e221
commit
0220e98b8d
3
.gitignore
vendored
3
.gitignore
vendored
@ -104,3 +104,6 @@ venv.bak/
|
||||
.mypy_cache/
|
||||
|
||||
config/
|
||||
|
||||
.DS_Store
|
||||
/.idea/
|
||||
|
@ -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))
|
||||
|
||||
# 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,
|
||||
|
Loading…
Reference in New Issue
Block a user