@nordicsemiconductor/nrf-jlink-js 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export type { Update as JLinkUpdate } from './shared/update';
2
2
  export { downloadAndInstallJLink, downloadAndSaveJLink } from './jlink';
3
3
  export { getJLinkState, type JLinkState } from './operations/getJLinkState';
4
4
  export { installJLink } from './operations/installJLink';
5
+ export { getHostFirmwareVersions, isDebugProbeFirmwareUpdateAvailable, } from './operations/debugProbeFirmwares';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.installJLink = exports.getJLinkState = exports.downloadAndSaveJLink = exports.downloadAndInstallJLink = void 0;
8
+ exports.isDebugProbeFirmwareUpdateAvailable = exports.getHostFirmwareVersions = exports.installJLink = exports.getJLinkState = exports.downloadAndSaveJLink = exports.downloadAndInstallJLink = void 0;
9
9
  var jlink_1 = require("./jlink");
10
10
  Object.defineProperty(exports, "downloadAndInstallJLink", { enumerable: true, get: function () { return jlink_1.downloadAndInstallJLink; } });
11
11
  Object.defineProperty(exports, "downloadAndSaveJLink", { enumerable: true, get: function () { return jlink_1.downloadAndSaveJLink; } });
@@ -13,3 +13,6 @@ var getJLinkState_1 = require("./operations/getJLinkState");
13
13
  Object.defineProperty(exports, "getJLinkState", { enumerable: true, get: function () { return getJLinkState_1.getJLinkState; } });
14
14
  var installJLink_1 = require("./operations/installJLink");
15
15
  Object.defineProperty(exports, "installJLink", { enumerable: true, get: function () { return installJLink_1.installJLink; } });
16
+ var debugProbeFirmwares_1 = require("./operations/debugProbeFirmwares");
17
+ Object.defineProperty(exports, "getHostFirmwareVersions", { enumerable: true, get: function () { return debugProbeFirmwares_1.getHostFirmwareVersions; } });
18
+ Object.defineProperty(exports, "isDebugProbeFirmwareUpdateAvailable", { enumerable: true, get: function () { return debugProbeFirmwares_1.isDebugProbeFirmwareUpdateAvailable; } });
@@ -0,0 +1,24 @@
1
+ interface HostFirmwareInfo {
2
+ filePath: string;
3
+ compiledOn: Date;
4
+ }
5
+ interface HostFirmwares {
6
+ [key: string]: HostFirmwareInfo;
7
+ }
8
+ /**
9
+ * Reads the debug probe firmware files in the given JLink directory and returns
10
+ * a map of their IDs and compilation dates.
11
+ */
12
+ export declare const getHostFirmwareVersions: (jlinkDir: string) => HostFirmwares;
13
+ /**
14
+ * Returns whether a debug probe firmware update is available for the given device
15
+ * based on the host firmware versions.
16
+ *
17
+ * @param jlinkObFirmwareVersion The connected debug probe firmware version as returned by
18
+ * `nrfutil --json --skip-overhead device device-info --serial-number ${serialNumber}`
19
+ * @param hostFirmwares The host firmware versions as returned by `getHostFirmwareVersions`
20
+ * @returns `true` if an update is available, `false` if not, or `undefined` if the
21
+ * information is insufficient to determine this.
22
+ */
23
+ export declare const isDebugProbeFirmwareUpdateAvailable: (jlinkObFirmwareVersion: string, hostFirmwares: HostFirmwares) => boolean | undefined;
24
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Nordic Semiconductor ASA
4
+ *
5
+ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.isDebugProbeFirmwareUpdateAvailable = exports.getHostFirmwareVersions = void 0;
9
+ var node_fs_1 = require("node:fs");
10
+ var node_path_1 = require("node:path");
11
+ /**
12
+ * Reads the debug probe firmware files in the given JLink directory and returns
13
+ * a map of their IDs and compilation dates.
14
+ */
15
+ var getHostFirmwareVersions = function (jlinkDir) {
16
+ var buffer = Buffer.alloc(64);
17
+ return Object.fromEntries((0, node_fs_1.readdirSync)((0, node_path_1.join)(jlinkDir, 'Firmwares'))
18
+ .map(function (file) {
19
+ var filePath = (0, node_path_1.join)(jlinkDir, 'Firmwares', file);
20
+ var fd = (0, node_fs_1.openSync)(filePath, 'r');
21
+ (0, node_fs_1.readSync)(fd, buffer, 0, buffer.length, 0);
22
+ var _a = buffer
23
+ .toString()
24
+ .split('\0')[0]
25
+ .split(' compiled '), id = _a[0], dateStr = _a[1];
26
+ (0, node_fs_1.closeSync)(fd);
27
+ return id && dateStr
28
+ ? [
29
+ id,
30
+ {
31
+ filePath: filePath,
32
+ compiledOn: new Date(dateStr),
33
+ },
34
+ ]
35
+ : undefined;
36
+ })
37
+ .filter(function (v) { return v !== undefined; }));
38
+ };
39
+ exports.getHostFirmwareVersions = getHostFirmwareVersions;
40
+ /**
41
+ * Returns whether a debug probe firmware update is available for the given device
42
+ * based on the host firmware versions.
43
+ *
44
+ * @param jlinkObFirmwareVersion The connected debug probe firmware version as returned by
45
+ * `nrfutil --json --skip-overhead device device-info --serial-number ${serialNumber}`
46
+ * @param hostFirmwares The host firmware versions as returned by `getHostFirmwareVersions`
47
+ * @returns `true` if an update is available, `false` if not, or `undefined` if the
48
+ * information is insufficient to determine this.
49
+ */
50
+ var isDebugProbeFirmwareUpdateAvailable = function (jlinkObFirmwareVersion, hostFirmwares) {
51
+ var _a;
52
+ var _b = jlinkObFirmwareVersion.split(' compiled '), deviceObFirmwareId = _b[0], deviceObFirmwareDateStr = _b[1];
53
+ if (!deviceObFirmwareId || !deviceObFirmwareDateStr) {
54
+ // No date info in firmware version
55
+ return;
56
+ }
57
+ var hostFwDate = (_a = hostFirmwares[deviceObFirmwareId]) === null || _a === void 0 ? void 0 : _a.compiledOn;
58
+ if (!hostFwDate) {
59
+ // No matching firmware found
60
+ return;
61
+ }
62
+ // Return true if host firmware is newer indicating an update is available
63
+ return hostFwDate > new Date(deviceObFirmwareDateStr);
64
+ };
65
+ exports.isDebugProbeFirmwareUpdateAvailable = isDebugProbeFirmwareUpdateAvailable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/nrf-jlink-js",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "main": "dist",
5
5
  "types": "dist",
6
6
  "files": [