import serial import sys if len(sys.argv) != 2: print("Usage: python reboot_to_bootloader.py ") sys.exit(1) port = sys.argv[1] try: ser = serial.Serial(port, 1200) ser.close() # Closing the port triggers the reboot to BOOTSEL mode print(f"Rebooted {port} to BOOTSEL mode") except Exception as e: print(f"Error: {e}") sys.exit(1)