Exemple #1
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.")
Exemple #2
0
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.")
Exemple #3
0
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.")