npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pc-nrf-dfu-js

v0.2.12

Published

JS implementation of the nRF DFU protocol

Downloads

39

Readme

nRF DFU

Build Status License

pc-nrf-dfu-js is a Javascript module which provides DFU (Device Firmware Upgrade) via USB CDC ACM transport for Nordic devices.

This module is primarily used by the nRF Connect framework and nRF Device Setup.

The following devices are supported:

  • USB SDFU:
    • PCA10056 nRF52840 Development Kit
    • PCA10059 nRF52840 Dongle

Installation

$ npm install pc-nrf-dfu-js

Dependency requirements

USB SDFU devices

Windows

In order to access Nordic USB devices on Windows, specific device drivers must be installed. The device drivers are automatically installed by the nRF Connect installer, starting from version 2.4. The drivers can also be found here.

Linux

Linux requires correct permissions to access these devices. For this purpose please install udev rules from nrf-udev repository, follow instructions there.

Usage

import { DfuUpdates, DfuTransportSerial, DfuOperation } from 'pc-nrf-dfu-js';

// Create DfuUpdates
const updates = await DfuUpdates.fromZipFilePath(firmwarePath);

// Create DfuTransportSerial
const serialTransport = new DfuTransportSerial(port, 16);

// Create DfuOperation
const dfu = new nrfDfu.DfuOperation(updates, serialTransport);

// Start dfu
dfu.start(true)
    .then(() => {
        ...
    })
    .catch(() => {
        ...
    });

USB SDFU

PCA10059 is a nRF52840 dongle which does not have a JLink debugger, so the USB device that the operating system sees depends on the firmware that is currently running on the Nordic chip.

This can be either a bootloader or an application firmware.

Bootloader mode

The pre-programmed bootloader provides a USB device with vendor ID 0x1915 and product ID 0x521f. This device has a USB CDC ACM (serialport) interface which handles the DFU operation. In case you need to manually trigger the bootloader, press the RESET button on the dongle.

Application mode

The dongle will be in application mode if it is plugged in and is programmed with a valid application. It will also switch to application mode after a successful DFU operation.

In application mode the USB device visible to the OS depends on the application firmware. For further documentation please refer to the Nordic SDK.

In application mode it is expected that the visible USB device to the OS has a DFU trigger interface. This interface provides a semver string which identifies the application firmware currently running. If the semver doesn't match the expected value, the device will be reset into bootloader mode.

Changing between bootloader and application also implies that the USB device is detached and attached, so there is an underlying functionality based on nrf-device-lister which looks for the newly attached USB device and tries to match by its serialNumber.

Development

Build

The project is using rollup.js, so the following command is needed to run the build: npm run rollup

Test

The project comes with automated integration tests in the test directory. In order to run the test, nRF52840 development kit must be attached to the PC on CDC ACM port or nRF52840 dongle must be attached to the PC. The environment variable DFU_SERIAL_NUMBER needs to be set to specify a certain nRF52840 dongle. Or if it is not specified, then the first found nRF52840 dongle by SerialPort will be used for the test. Otherwise, the test will fail.

To run the tests:

npm test