def do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, ping): if flow_control is None: flow_control = DfuTransportSerial.DEFAULT_FLOW_CONTROL if packet_receipt_notification is None: packet_receipt_notification = DfuTransportSerial.DEFAULT_PRN if baud_rate is None: baud_rate = DfuTransportSerial.DEFAULT_BAUD_RATE if ping is None: ping = False logger.info("Using board at serial port: {}".format(port)) serial_backend = DfuTransportSerial(com_port=str(port), baud_rate=baud_rate, flow_control=flow_control, prn=packet_receipt_notification, do_ping=ping) serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path = package, dfu_transport = serial_backend, connect_delay = connect_delay) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def serial(package, port, flow_control, packet_receipt_notification, baud_rate): """Perform a Device Firmware Update on a device with a bootloader that supports serial DFU.""" #raise NotImplementedException('Serial transport currently is not supported') """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU.""" if port is None: click.echo("Please specify serial port.") return if flow_control is None: flow_control = DfuTransportSerial.DEFAULT_FLOW_CONTROL if packet_receipt_notification is None: packet_receipt_notification = DfuTransportSerial.DEFAULT_PRN if baud_rate is None: baud_rate = DfuTransportSerial.DEFAULT_BAUD_RATE logger.info("Using board at serial port: {}".format(port)) serial_backend = DfuTransportSerial(com_port=str(port), baud_rate=baud_rate, flow_control=flow_control, prn=packet_receipt_notification) serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path=package, dfu_transport=serial_backend) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def ble(package, conn_ic_id, port, connect_delay, name, address, jlink_snr, flash_connectivity): """ Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU. This requires a second nRF device, connected to this computer, with connectivity firmware loaded. The connectivity device will perform the DFU procedure onto the target device. """ ble_driver_init(conn_ic_id) if name is None and address is None: name = 'DfuTarg' click.echo( "No target selected. Default device name: {} is used.".format( name)) if port is None and jlink_snr is not None: port = get_port_by_snr(jlink_snr) elif port is None: port = enumerate_ports() if port is None: click.echo( "\nNo Segger USB CDC ports found, please connect your board.") return if flash_connectivity: flasher = Flasher(serial_port=port, snr=jlink_snr) if flasher.fw_check(): click.echo("Board already flashed with connectivity firmware.") else: click.echo("Flashing connectivity firmware...") flasher.fw_flash() click.echo("Connectivity firmware flashed.") flasher.reset() time.sleep(1) logger.info("Using connectivity board at serial port: {}".format(port)) ble_backend = DfuTransportBle(serial_port=str(port), target_device_name=str(name), target_device_addr=str(address)) ble_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path=package, dfu_transport=ble_backend, connect_delay=connect_delay) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, ping, timeout, dfuStart=None): if flow_control is None: flow_control = DfuTransportSerial.DEFAULT_FLOW_CONTROL if packet_receipt_notification is None: packet_receipt_notification = DfuTransportSerial.DEFAULT_PRN if baud_rate is None: baud_rate = DfuTransportSerial.DEFAULT_BAUD_RATE if ping is None: ping = False if port is None: raise Exception("Please specify port!") if timeout is None: timeout = DfuTransportSerial.DEFAULT_TIMEOUT logger.info( "Using board at serial port: {0}, flow_control: {1}, baud_rate: {2}, ping: {3}" .format(port, flow_control, baud_rate, ping)) serial_backend = DfuTransportSerial(com_port=str(port), baud_rate=baud_rate, flow_control=flow_control, prn=packet_receipt_notification, do_ping=ping, timeout=timeout) serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) if dfuStart: logger.info('Enterring DFU mode ...') send_text_message(str(port), baud_rate, dfuStart, flow_control) logger.info('Done') dfu = Dfu(zip_file_path=package, dfu_transport=serial_backend, connect_delay=connect_delay) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() logger.info("Device programmed.")
def whisper(package, device): whisper_backend = DfuTransportWhisper(device) whisper_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path = package, dfu_transport = whisper_backend, connect_delay = 0) logger.info("Updating {} nRF with {}".format(device, package)) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def ble(package, conn_ic_id, port, name, address, jlink_snr, flash_connectivity): ble_driver_init(conn_ic_id) """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU.""" if name is None and address is None: name = 'DfuTarg' click.echo("No target selected. Default device name: {} is used.".format(name)) if port is None and jlink_snr is not None: click.echo("Please specify also serial port.") return elif port is None: port = enumerate_ports() if port is None: click.echo("\nNo Segger USB CDC ports found, please connect your board.") return if flash_connectivity: flasher = Flasher(serial_port=port, snr = jlink_snr) if flasher.fw_check(): click.echo("Board already flashed with connectivity firmware.") else: click.echo("Flashing connectivity firmware...") flasher.fw_flash() click.echo("Connectivity firmware flashed.") flasher.reset() time.sleep(1) logger.info("Using connectivity board at serial port: {}".format(port)) ble_backend = DfuTransportBle(serial_port=str(port), target_device_name=str(name), target_device_addr=str(address)) ble_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path = package, dfu_transport = ble_backend) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def serial(package, port): """Perform a Device Firmware Update on a device with a bootloader that supports serial DFU.""" #raise NotImplementedException('Serial transport currently is not supported') """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU.""" if port is None: click.echo("Please specify serial port.") return logger.info("Using board at serial port: {}".format(port)) serial_backend = DfuTransportSerial(com_port=str(port)) serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path = package, dfu_transport = serial_backend) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def serial(package, port): """Perform a Device Firmware Update on a device with a bootloader that supports serial DFU.""" #raise NotImplementedException('Serial transport currently is not supported') """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU.""" if port is None: click.echo("Please specify serial port.") return logger.info("Using board at serial port: {}".format(port)) serial_backend = DfuTransportSerial(com_port=str(port)) serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path = package, dfu_transport = serial_backend) if logger.getEffectiveLevel() > logging.INFO: with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() else: dfu.dfu_send_images() click.echo("Device programmed.")
def ble(package, port, name, address, jlink_snr, flash_connectivity): """Perform a Device Firmware Update on a device with a bootloader that supports BLE DFU.""" if name is None and address is None: name = 'DfuTarg' click.echo("No target selected. Default device name: {} is used.".format(name)) if port is None and jlink_snr is not None: click.echo("Please specify also serial port.") return elif port is None: port = enumerate_ports() if flash_connectivity: flasher = Flasher(serial_port=port, snr = jlink_snr) if flasher.fw_check(): click.echo("Connectivity already flashed with firmware.") else: click.echo("Flashing connectivity ") flasher.fw_flash() click.echo("Connectivity flashed") flasher.reset() time.sleep(1) ble_backend = DfuTransportBle(serial_port=str(port), target_device_name=str(name), target_device_addr=str(address)) ble_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress) dfu = Dfu(zip_file_path = package, dfu_transport = ble_backend) with click.progressbar(length=dfu.dfu_get_total_size()) as bar: global global_bar global_bar = bar dfu.dfu_send_images() click.echo("Device programmed.")