コード例 #1
0
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.")
コード例 #2
0
ファイル: __main__.py プロジェクト: deanfu1997/AR_Dean_2021
def serial(package, port, baudrate, flowcontrol, singlebank, touch):
    """Program a device with bootloader that support serial DFU"""
    serial_backend = DfuTransportSerial(port, baudrate, flowcontrol, singlebank, touch)
    serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress)
    dfu = Dfu(package, dfu_transport=serial_backend)

    click.echo("Upgrading target on {1} with DFU package {0}. Flow control is {2}, {3} bank, Touch {4}"
               .format(package, port, "enabled" if flowcontrol else "disabled", "Single" if singlebank else "Dual", touch if touch > 0 else "disabled"))

    try:
        dfu.dfu_send_images()

    except Exception as e:
        click.echo("")
        click.echo("Failed to upgrade target. Error is: {0}".format(e))
        traceback.print_exc(file=sys.stdout)
        click.echo("")
        click.echo("Possible causes:")
        click.echo("- Selected Bootloader version does not match the one on Bluefruit device.")
        click.echo("    Please upgrade the Bootloader or select correct version in Tools->Bootloader.")
        click.echo("- Baud rate must be 115200, Flow control must be off.")
        click.echo("- Target is not in DFU mode. Ground DFU pin and RESET and release both to enter DFU mode.")

        return False

    click.echo("Device programmed.")

    return True
コード例 #3
0
ファイル: __main__.py プロジェクト: eXeP/fyssasensori
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.")
コード例 #4
0
def serial(package, port, baudrate, flowcontrol):
    """Program a device with bootloader that support serial DFU"""
    serial_backend = DfuTransportSerial(port, baudrate, flowcontrol)
    serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress)
    dfu = Dfu(package, dfu_transport=serial_backend)

    click.echo("Upgrading target on {1} with DFU package {0}. Flow control is {2}."
               .format(package, port, "enabled" if flowcontrol else "disabled"))

    try:
        with click.progressbar(length=100) as bar:
            global global_bar
            global_bar = bar
            dfu.dfu_send_images()

    except Exception as e:
        click.echo("")
        click.echo("Failed to upgrade target. Error is: {0}".format(e.message))
        click.echo("")
        click.echo("Possible causes:")
        click.echo("- bootloader, SoftDevice or application on target "
                   "does not match the requirements in the DFU package.")
        click.echo("- baud rate or flow control is not the same as in the target bootloader.")
        click.echo("- target is not in DFU mode. If using the SDK examples, "
                   "press Button 4 and RESET and release both to enter DFU mode.")

        return False

    click.echo("Device programmed.")

    return True
コード例 #5
0
ファイル: __main__.py プロジェクト: johnttaylor/colony.apps
def serial(package, port, baudrate, flowcontrol):
    """Program a device with bootloader that support serial DFU"""
    serial_backend = DfuTransportSerial(port, baudrate, flowcontrol)
    serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, update_progress)
    dfu = Dfu(package, dfu_transport=serial_backend)

    click.echo("Upgrading target on {1} with DFU package {0}. Flow control is {2}."
               .format(package, port, "enabled" if flowcontrol else "disabled"))

    try:
        dfu.dfu_send_images()

    except Exception as e:
        click.echo("")
        click.echo("Failed to upgrade target. Error is: {0}".format(e.message))
        click.echo("")
        click.echo("Possible causes:")
        click.echo("- Bootloader, SoftDevice or Application on target "
                   "does not match the requirements in the DFU package.")
        click.echo("- Baud rate must be 115200, Flow control must be off.")
        click.echo("- Target is not in DFU mode. Ground DFU pin and RESET and release both to enter DFU mode.")

        return False

    click.echo("Device programmed.")

    return True
コード例 #6
0
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.")
コード例 #7
0
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.")
コード例 #8
0
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.")
コード例 #9
0
def do_network(package, outgoing_ip, sock):
    logger.info("Doing network ")

    udp_backend = DfuTransportUDP(outgoing_ip,
                                  sock,
                                  flow_control=False,
                                  prn=0,
                                  do_ping=True,
                                  timeout=1.0)

    udp_backend.register_events_callback(DfuEvent.PROGRESS_EVENT,
                                         update_progress)

    dfu = Dfu(zip_file_path=package,
              dfu_transport=udp_backend,
              connect_delay=3)
    dfu.dfu_send_images()
    """     if logger.getEffectiveLevel() > logging.INFO:
コード例 #10
0
ファイル: __main__.py プロジェクト: hakonfam/pc-nrfutil
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.")
コード例 #11
0
ファイル: __main__.py プロジェクト: james-cobb/TTNode
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.")
コード例 #12
0
ファイル: __main__.py プロジェクト: hakonfam/pc-nrfutil
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.")
コード例 #13
0
ファイル: __main__.py プロジェクト: Jeoy5460/pc-nrfutil
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.")