@nordicsemiconductor/nrf-jlink-js 0.13.0 → 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;
|
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
*
|
|
5
5
|
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
6
6
|
*/
|
|
7
|
+
var __assign = (this && this.__assign) || function () {
|
|
8
|
+
__assign = Object.assign || function(t) {
|
|
9
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
+
s = arguments[i];
|
|
11
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
12
|
+
t[p] = s[p];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
return __assign.apply(this, arguments);
|
|
17
|
+
};
|
|
7
18
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
19
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
20
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -147,6 +158,11 @@ var isValidVersion = function (installedVersion, expectedVersion) {
|
|
|
147
158
|
return semver_1.default.gte(convertToSemverVersion(installedVersion), convertToSemverVersion(expectedVersion));
|
|
148
159
|
};
|
|
149
160
|
exports.isValidVersion = isValidVersion;
|
|
161
|
+
var getEnv = function () {
|
|
162
|
+
if (process.platform !== 'darwin')
|
|
163
|
+
return undefined;
|
|
164
|
+
return __assign(__assign({}, process.env), { PATH: "".concat(process.env.PATH, ":/usr/local/bin") });
|
|
165
|
+
};
|
|
150
166
|
var getInstalledJLinkVersion = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
167
|
var env_1, scriptFile, output, versionRegExp, match, e_1;
|
|
152
168
|
var _a;
|
|
@@ -158,7 +174,9 @@ var getInstalledJLinkVersion = function () { return __awaiter(void 0, void 0, vo
|
|
|
158
174
|
case 1:
|
|
159
175
|
_b.trys.push([1, 3, 4, 5]);
|
|
160
176
|
scriptFile = __addDisposableResource(env_1, (0, fs_2.createTemporaryScriptFile)('Exit'), false);
|
|
161
|
-
return [4 /*yield*/, (0, util_1.promisify)(child_process_1.exec)("".concat(getJLinkExePath(), " -CommandFile ").concat(scriptFile.filePath)
|
|
177
|
+
return [4 /*yield*/, (0, util_1.promisify)(child_process_1.exec)("".concat(getJLinkExePath(), " -CommandFile ").concat(scriptFile.filePath), {
|
|
178
|
+
env: getEnv()
|
|
179
|
+
}).catch(function (e) { return e; })];
|
|
162
180
|
case 2:
|
|
163
181
|
output = _b.sent();
|
|
164
182
|
versionRegExp = /^SEGGER J-Link Commander V([0-9a-z.]+) .*$/m;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordicsemiconductor/nrf-jlink-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"main": "dist",
|
|
5
5
|
"types": "dist",
|
|
6
6
|
"files": [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"semver": "^7.7.2"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
+
"prepare": "npm run build",
|
|
13
14
|
"build": "tsc",
|
|
14
15
|
"upload-jlink": "ts-node scripts/upload-jlink.ts"
|
|
15
16
|
},
|