Coder Social home page Coder Social logo

larrytsai1980 / pc-nrf-dfu-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nordicsemiconductor/pc-nrf-dfu-js

0.0 2.0 0.0 961 KB

Javascript implementation of Nordic's DFU protocol, over serial or BLE.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 99.22% HTML 0.78%

pc-nrf-dfu-js's Introduction

nRF DFU

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 'nrf-device-setup';

// 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

pc-nrf-dfu-js's People

Contributors

chunfantasy avatar ivansanchez avatar bencefr avatar mrodem avatar lats1980 avatar larrytsai1980 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.