fix(CH9102F): Suggest to install new serial drivers if writing to RAM fails

This commit is contained in:
radim.karnis
2023-06-06 16:04:05 +02:00
committed by Radim Karniš
parent d98464706b
commit f4b59141e8
2 changed files with 17 additions and 3 deletions

View File

@@ -713,7 +713,16 @@ def main(argv=None, esp=None):
)
args.no_stub = True
else:
esp = esp.run_stub()
try:
esp = esp.run_stub()
except Exception:
# The CH9102 bridge (PID: 0x55D4) can have issues on MacOS
if sys.platform == "darwin" and esp._get_pid() == 0x55D4:
print(
"\nNote: If issues persist, "
"try installing the WCH USB-to-Serial MacOS driver."
)
raise
if args.override_vddsdio:
esp.override_vddsdio(args.override_vddsdio)

View File

@@ -295,6 +295,7 @@ class ESPLoader(object):
"flash_id": None,
"chip_id": None,
"uart_no": None,
"usb_pid": None,
}
if isinstance(port, str):
@@ -475,6 +476,9 @@ class ESPLoader(object):
self.sync_stub_detected &= val == 0
def _get_pid(self):
if self.cache["usb_pid"] is not None:
return self.cache["usb_pid"]
if list_ports is None:
print(
"\nListing all serial ports is currently not available. "
@@ -502,10 +506,11 @@ class ESPLoader(object):
ports = list_ports.comports()
for p in ports:
if p.device in active_ports:
self.cache["usb_pid"] = p.pid
return p.pid
print(
"\nFailed to get PID of a device on {}, "
"using standard reset sequence.".format(active_port)
f"\nFailed to get PID of a device on {active_port}, "
"using standard reset sequence."
)
def _connect_attempt(self, reset_strategy, mode="default_reset"):