FirmwareUpdater

FirmwareUpdater

Class that performs firmware update using pc-nrfjprog-js.

Constructor

new FirmwareUpdater(programmer)

Initialize the firmware updater with a programmer instance. The programmer instance could be pc-nrfjprog-js or any other instance that implements the read, getDeviceInfo, and program functions.
Deprecated:
  • This class is being replaced by the nrf-device-setup npm module, which supports firmware updates with both nrfjprog and serial DFU.
Source:
Parameters:
Name Type Description
programmer Object The programmer instance, e.g. pc-nrfjprog-js.

Methods

(static) getBaudRate(family, platformopt) → {number}

Get the baud rate that is supported for the given family and platform.
Source:
Parameters:
Name Type Attributes Description
family number The devkit family: 0 = nrf51, 1 = nrf52.
platform String <optional>
Optional value that can be one of 'win32', 'linux', 'darwin'. Will use the detected platform if not provided.
Throws:
Throws error if unsupported family or platform.
Type
Error
Returns:
Type:
number
Baud rate.

(static) getFirmwarePath(family, platformopt) → {string}

Get path to the latest firmware file for the given family and platform.
Source:
Parameters:
Name Type Attributes Description
family number The devkit family: 0 = nrf51, 1 = nrf52.
platform String <optional>
Optional value that can be one of 'win32', 'linux', 'darwin'. Will use the detected platform if not provided.
Throws:
Throws error if unsupported family or platform.
Type
Error
Returns:
Type:
string
Absolute path to firmware file.

(static) getFirmwareString(family, platformopt) → {string}

Get the latest firmware hex as a string.
Source:
Parameters:
Name Type Attributes Description
family number The devkit family: 0 = nrf51, 1 = nrf52.
platform String <optional>
Optional value that can be one of 'win32', 'linux', 'darwin'. Will use the detected platform if not provided.
Throws:
Throws error if unsupported family or platform.
Type
Error
Returns:
Type:
string
Firmware hex string.

(static) getLatestVersion(family, platformopt) → {string}

Get the latest connectivity firmware version for the given family and platform.
Source:
Parameters:
Name Type Attributes Description
family number The devkit family: 0 = nrf51, 1 = nrf52.
platform String <optional>
Optional value that can be one of 'win32', 'linux', 'darwin'. Will use the detected platform if not provided.
Throws:
Throws error if unsupported family or platform.
Type
Error
Returns:
Type:
string
The latest 'major.minor.patch' version.

(static) parseVersionStruct(versionStruct) → {Object}

Parse the version info struct that can be found in the connectivity firmware. See the connectivity firmware patch in pc-ble-driver/hex/sd_api_v* for details.
Source:
Parameters:
Name Type Description
versionStruct Array.<number> Array of integers from the firmware.
Returns:
Type:
Object
Parsed version info struct as an object.

getVersionInfo(serialNumber, callback) → {void}

Get version info from the firmware for the given serial number. If no connectivity firmware is present, then the returned object will only contain isUpdateRequired = true. This will also be true if the version is not the latest, or if the baud rate is not supported.
  • {boolean} isUpdateRequired: True if firmware needs to be updated.
  • {string} version: The 'major.minor.patch' version for the firmware.
  • {number} sdBleApiVersion: The SoftDevice version.
  • {number} transportType: Transport type, 1 = UART_HCI.
  • {number} baudRate: UART transport baud rate.
Source:
Parameters:
Name Type Description
serialNumber number The serial number to get version info for.
callback function Signature: (err, versionInfo) => {}.
Returns:
Type:
void

update(serialNumber, callback) → {void}

Program the given serial number with the latest connectivity firmware. The new version info object (ref. getVersionInfo) is returned through the callback.
Source:
See:
  • getVersionInfo
Parameters:
Name Type Description
serialNumber number The serial number to program.
callback function Signature: (err, versionInfo) => {}.
Returns:
Type:
void