diff --git a/openthread_border_router/rootfs/usr/local/bin/migrate_otbr_settings.py b/openthread_border_router/rootfs/usr/local/bin/migrate_otbr_settings.py index c31043ce0..4a9315a00 100755 --- a/openthread_border_router/rootfs/usr/local/bin/migrate_otbr_settings.py +++ b/openthread_border_router/rootfs/usr/local/bin/migrate_otbr_settings.py @@ -152,14 +152,10 @@ async def main() -> None: if flow_control == "none": flow_control = None - # First, read the hardware address of the new adapter - hwaddr = await get_adapter_hardware_addr( - port=args.adapter, - baudrate=args.baudrate, - flow_control=flow_control, - ) - - # Then, look at existing settings + # First, look at existing settings before touching the adapter. + # If there is nothing to migrate, skip the adapter connection entirely. + # This avoids a TimeoutError / AssertionError on dongles that reset their + # USB connection in response to a Spinel RESET (issue #4475). all_settings = [] for settings_path in args.data_dir.glob("*.data"): @@ -184,6 +180,13 @@ async def main() -> None: print("No existing settings files found, skipping") return + # Only connect to the adapter if there are settings files that need migrating + hwaddr = await get_adapter_hardware_addr( + port=args.adapter, + baudrate=args.baudrate, + flow_control=flow_control, + ) + most_recent_settings_info = sorted(all_settings, reverse=True)[0] most_recent_settings_path = most_recent_settings_info[1] most_recent_settings = most_recent_settings_info[2]