@nordicsemiconductor/pc-nrfconnect-shared 189.0.0 → 191.0.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/Changelog.md +24 -0
- package/ipc/MetaFiles.ts +1 -4
- package/ipc/apps.ts +2 -1
- package/nrfutil/device/logLibVersions.ts +37 -22
- package/nrfutil/index.ts +2 -1
- package/nrfutil/jlinkVersion.test.ts +323 -0
- package/nrfutil/jlinkVersion.ts +144 -0
- package/nrfutil/moduleVersion.ts +17 -31
- package/nrfutil/modules.ts +1 -6
- package/nrfutil/sandbox.ts +1 -0
- package/nrfutil/sandboxTypes.ts +19 -59
- package/nrfutil/version.ts +54 -0
- package/package.json +1 -1
- package/scripts/nordic-publish.js +12 -12
- package/src/Device/deviceInfo/deviceInfo.ts +3 -0
- package/src/utils/systemReport.ts +3 -6
- package/typings/generated/ipc/MetaFiles.d.ts +1 -1
- package/typings/generated/ipc/MetaFiles.d.ts.map +1 -1
- package/typings/generated/ipc/apps.d.ts +2 -1
- package/typings/generated/ipc/apps.d.ts.map +1 -1
- package/typings/generated/ipc/schema/packageJson.d.ts +15 -15
- package/typings/generated/nrfutil/device/logLibVersions.d.ts.map +1 -1
- package/typings/generated/nrfutil/index.d.ts +2 -1
- package/typings/generated/nrfutil/index.d.ts.map +1 -1
- package/typings/generated/nrfutil/jlinkVersion.d.ts +24 -0
- package/typings/generated/nrfutil/jlinkVersion.d.ts.map +1 -0
- package/typings/generated/nrfutil/jlinkVersion.test.d.ts +2 -0
- package/typings/generated/nrfutil/jlinkVersion.test.d.ts.map +1 -0
- package/typings/generated/nrfutil/moduleVersion.d.ts +4 -4
- package/typings/generated/nrfutil/moduleVersion.d.ts.map +1 -1
- package/typings/generated/nrfutil/modules.d.ts.map +1 -1
- package/typings/generated/nrfutil/sandbox.d.ts.map +1 -1
- package/typings/generated/nrfutil/sandboxTypes.d.ts +14 -46
- package/typings/generated/nrfutil/sandboxTypes.d.ts.map +1 -1
- package/typings/generated/nrfutil/version.d.ts +27 -0
- package/typings/generated/nrfutil/version.d.ts.map +1 -0
- package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts.map +1 -1
- package/typings/generated/src/utils/packageJson.d.ts +2 -2
- package/typings/generated/src/utils/systemReport.d.ts.map +1 -1
package/Changelog.md
CHANGED
|
@@ -7,6 +7,30 @@ This project does _not_ adhere to
|
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
|
|
8
8
|
every new version is a new major version.
|
|
9
9
|
|
|
10
|
+
## 191.0.0 - 2024-11-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Function `getJlinkCompatibility`.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- nrfutil: The core gets upgraded before installing a command.
|
|
19
|
+
- nrfutil: The `version` properties of dependencies are now optional,
|
|
20
|
+
reflecting the behaviour since `nrfutil-device` v2.7.0.
|
|
21
|
+
- Warning for J-Link versions: Only inform (not warn) if the installed version
|
|
22
|
+
is newer than the tested version. Updated the text for all cases.
|
|
23
|
+
|
|
24
|
+
### Removed
|
|
25
|
+
|
|
26
|
+
- Export of internal type `SemanticVersion`.
|
|
27
|
+
|
|
28
|
+
## 190.0.0 - 2024-11-06
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Added `Thingy91:X` to known devices.
|
|
33
|
+
|
|
10
34
|
## 189.0.0 - 2024-10-18
|
|
11
35
|
|
|
12
36
|
### Added
|
package/ipc/MetaFiles.ts
CHANGED
|
@@ -54,9 +54,6 @@ const nrfutilModuleVersion = semver;
|
|
|
54
54
|
export type NrfutilModuleName = z.infer<typeof nrfutilModuleName>;
|
|
55
55
|
export type NrfutilModuleVersion = z.infer<typeof nrfutilModuleVersion>;
|
|
56
56
|
|
|
57
|
-
export const nrfModules = z.record(
|
|
58
|
-
nrfutilModuleName,
|
|
59
|
-
nrfutilModuleVersion.array().nonempty()
|
|
60
|
-
);
|
|
57
|
+
export const nrfModules = z.record(nrfutilModuleName, z.tuple([semver]));
|
|
61
58
|
|
|
62
59
|
export type NrfutilModules = z.infer<typeof nrfModules>;
|
package/ipc/apps.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { handle, invoke } from './infrastructure/rendererToMain';
|
|
8
|
-
import { AppVersions, UrlString } from './MetaFiles';
|
|
8
|
+
import type { AppVersions, NrfutilModules, UrlString } from './MetaFiles';
|
|
9
9
|
import { LOCAL, Source, SourceName } from './sources';
|
|
10
10
|
|
|
11
11
|
export interface AppSpec {
|
|
@@ -33,6 +33,7 @@ interface Installed {
|
|
|
33
33
|
engineVersion?: string;
|
|
34
34
|
repositoryUrl?: UrlString;
|
|
35
35
|
html?: string;
|
|
36
|
+
nrfutil?: NrfutilModules;
|
|
36
37
|
installed: {
|
|
37
38
|
publishTimestamp?: string;
|
|
38
39
|
path: string;
|
|
@@ -8,21 +8,23 @@ import { spawn } from 'child_process';
|
|
|
8
8
|
import os from 'os';
|
|
9
9
|
|
|
10
10
|
import describeError from '../../src/logging/describeError';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
getExpectedVersion,
|
|
14
|
-
resolveModuleVersion,
|
|
15
|
-
} from '../moduleVersion';
|
|
11
|
+
import { getJlinkCompatibility } from '../jlinkVersion';
|
|
12
|
+
import { describeVersion, findDependency } from '../moduleVersion';
|
|
16
13
|
import { getNrfutilLogger } from '../nrfutilLogger';
|
|
17
|
-
import type {
|
|
14
|
+
import type { Dependency, ModuleVersion } from '../sandboxTypes';
|
|
18
15
|
|
|
19
|
-
const log = (
|
|
16
|
+
const log = (
|
|
17
|
+
description: string,
|
|
18
|
+
dependencyOrVersion?: Dependency | string
|
|
19
|
+
) => {
|
|
20
20
|
const logger = getNrfutilLogger();
|
|
21
|
-
if (
|
|
21
|
+
if (dependencyOrVersion == null) {
|
|
22
22
|
logger?.warn(`Unable to detect version of ${description}.`);
|
|
23
23
|
} else {
|
|
24
24
|
logger?.info(
|
|
25
|
-
`Using ${description} version: ${describeVersion(
|
|
25
|
+
`Using ${description} version: ${describeVersion(
|
|
26
|
+
dependencyOrVersion
|
|
27
|
+
)}`
|
|
26
28
|
);
|
|
27
29
|
}
|
|
28
30
|
};
|
|
@@ -75,24 +77,37 @@ export default async (moduleVersion: ModuleVersion) => {
|
|
|
75
77
|
const dependencies = moduleVersion.dependencies;
|
|
76
78
|
|
|
77
79
|
log('nrfutil-device', moduleVersion.version);
|
|
78
|
-
log('nrf-device-lib',
|
|
79
|
-
log('nrfjprog DLL',
|
|
80
|
-
log('JLink',
|
|
80
|
+
log('nrf-device-lib', findDependency('nrfdl', dependencies));
|
|
81
|
+
log('nrfjprog DLL', findDependency('jprog', dependencies));
|
|
82
|
+
log('JLink', findDependency('JlinkARM', dependencies));
|
|
81
83
|
|
|
82
|
-
const
|
|
84
|
+
const jlinkCompatibility = getJlinkCompatibility(moduleVersion);
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (!result.isExpectedVersion) {
|
|
86
|
+
switch (jlinkCompatibility.kind) {
|
|
87
|
+
case 'No J-Link installed':
|
|
87
88
|
logger?.warn(
|
|
88
|
-
`
|
|
89
|
+
`SEGGER J-Link is not installed. ` +
|
|
90
|
+
`Install at least version ${jlinkCompatibility.requiredJlink} ` +
|
|
91
|
+
`from https://www.segger.com/downloads/jlink`
|
|
89
92
|
);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
break;
|
|
94
|
+
case 'Outdated J-Link':
|
|
95
|
+
logger?.warn(
|
|
96
|
+
`Outdated SEGGER J-Link. Your version of SEGGER J-Link (${jlinkCompatibility.actualJlink}) ` +
|
|
97
|
+
`is older than the one this app was tested with (${jlinkCompatibility.requiredJlink}). ` +
|
|
98
|
+
`Install the newer version from https://www.segger.com/downloads/jlink`
|
|
99
|
+
);
|
|
100
|
+
break;
|
|
101
|
+
case 'Newer J-Link is used':
|
|
102
|
+
logger?.info(
|
|
103
|
+
`Your version of SEGGER J-Link (${jlinkCompatibility.actualJlink}) ` +
|
|
104
|
+
`is newer than the one this app was tested with (${jlinkCompatibility.requiredJlink}). ` +
|
|
105
|
+
`The tested version is not required, and your J-Link version will most likely work fine.` +
|
|
106
|
+
` If you get issues related to J-Link with your devices, use the tested version.`
|
|
107
|
+
);
|
|
108
|
+
break;
|
|
95
109
|
}
|
|
110
|
+
|
|
96
111
|
if (
|
|
97
112
|
process.platform === 'darwin' &&
|
|
98
113
|
os.cpus()[0].model.includes('Apple')
|
package/nrfutil/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
export { default as prepareSandbox } from './sandbox';
|
|
8
8
|
export { NrfutilSandbox } from './sandbox';
|
|
9
|
-
export type { Progress
|
|
9
|
+
export type { Progress } from './sandboxTypes';
|
|
10
10
|
export { getNrfutilLogger, setNrfutilLogger } from './nrfutilLogger';
|
|
11
11
|
export {
|
|
12
12
|
getModule,
|
|
@@ -14,3 +14,4 @@ export {
|
|
|
14
14
|
setVerboseLogging,
|
|
15
15
|
getAllModuleVersions,
|
|
16
16
|
} from './modules';
|
|
17
|
+
export { getJlinkCompatibility } from './jlinkVersion';
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
convertToSemver,
|
|
9
|
+
existingIsOlderThanExpected,
|
|
10
|
+
getJlinkCompatibility,
|
|
11
|
+
hasExpectedVersionFormat,
|
|
12
|
+
strippedVersionName,
|
|
13
|
+
} from './jlinkVersion';
|
|
14
|
+
import type { Dependency, ModuleVersion } from './sandboxTypes';
|
|
15
|
+
|
|
16
|
+
// Note: In this test the space at the end of 'JLink_V7.96 ' or '7.96 ' is
|
|
17
|
+
// intentional because it is also reported like that by nrfutil.
|
|
18
|
+
|
|
19
|
+
test('strippedVersionName', () => {
|
|
20
|
+
expect(
|
|
21
|
+
strippedVersionName({
|
|
22
|
+
version: '7.94i',
|
|
23
|
+
versionFormat: 'string',
|
|
24
|
+
})
|
|
25
|
+
).toBe('7.94i');
|
|
26
|
+
expect(
|
|
27
|
+
strippedVersionName({
|
|
28
|
+
version: '7.96 ',
|
|
29
|
+
versionFormat: 'string',
|
|
30
|
+
})
|
|
31
|
+
).toBe('7.96');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('expectedFormat', () => {
|
|
35
|
+
it('fails if the version format is not string', () => {
|
|
36
|
+
expect(
|
|
37
|
+
hasExpectedVersionFormat(
|
|
38
|
+
{
|
|
39
|
+
version: 18,
|
|
40
|
+
versionFormat: 'incremental',
|
|
41
|
+
},
|
|
42
|
+
false
|
|
43
|
+
)
|
|
44
|
+
).toBe(false);
|
|
45
|
+
|
|
46
|
+
expect(
|
|
47
|
+
hasExpectedVersionFormat(
|
|
48
|
+
{
|
|
49
|
+
version: { major: 1, minor: 2, patch: 3 },
|
|
50
|
+
versionFormat: 'semantic',
|
|
51
|
+
},
|
|
52
|
+
false
|
|
53
|
+
)
|
|
54
|
+
).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('fails if the content is unexpected', () => {
|
|
58
|
+
const noJlinkPrefix = {
|
|
59
|
+
version: '7.94i',
|
|
60
|
+
versionFormat: 'string',
|
|
61
|
+
} as const;
|
|
62
|
+
expect(hasExpectedVersionFormat(noJlinkPrefix, false)).toBe(false);
|
|
63
|
+
|
|
64
|
+
const wrongCasing = {
|
|
65
|
+
version: 'jlink_v7.96',
|
|
66
|
+
versionFormat: 'string',
|
|
67
|
+
} as const;
|
|
68
|
+
expect(hasExpectedVersionFormat(wrongCasing, false)).toBe(false);
|
|
69
|
+
|
|
70
|
+
const unexpectedPostfix = {
|
|
71
|
+
version: 'JLink_V7.96-beta',
|
|
72
|
+
versionFormat: 'string',
|
|
73
|
+
} as const;
|
|
74
|
+
expect(hasExpectedVersionFormat(unexpectedPostfix, false)).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('succeeds for expected content', () => {
|
|
78
|
+
expect(
|
|
79
|
+
hasExpectedVersionFormat(
|
|
80
|
+
{
|
|
81
|
+
version: 'JLink_V7.94i',
|
|
82
|
+
versionFormat: 'string',
|
|
83
|
+
},
|
|
84
|
+
false
|
|
85
|
+
)
|
|
86
|
+
).toBe(true);
|
|
87
|
+
expect(
|
|
88
|
+
hasExpectedVersionFormat(
|
|
89
|
+
{
|
|
90
|
+
version: 'JLink_V7.96 ',
|
|
91
|
+
versionFormat: 'string',
|
|
92
|
+
},
|
|
93
|
+
false
|
|
94
|
+
)
|
|
95
|
+
).toBe(true);
|
|
96
|
+
expect(
|
|
97
|
+
hasExpectedVersionFormat(
|
|
98
|
+
{
|
|
99
|
+
version: 'JLink_V8.10',
|
|
100
|
+
versionFormat: 'string',
|
|
101
|
+
},
|
|
102
|
+
false
|
|
103
|
+
)
|
|
104
|
+
).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('convertToSemver', () => {
|
|
109
|
+
expect(
|
|
110
|
+
convertToSemver({ version: 'JLink_V7.94', versionFormat: 'string' })
|
|
111
|
+
).toBe('7.94.0');
|
|
112
|
+
expect(
|
|
113
|
+
convertToSemver({ version: 'JLink_V7.96 ', versionFormat: 'string' })
|
|
114
|
+
).toBe('7.96.0');
|
|
115
|
+
expect(
|
|
116
|
+
convertToSemver({ version: 'JLink_V7.98a', versionFormat: 'string' })
|
|
117
|
+
).toBe('7.98.1');
|
|
118
|
+
expect(
|
|
119
|
+
convertToSemver({ version: 'JLink_V8.10b', versionFormat: 'string' })
|
|
120
|
+
).toBe('8.10.2');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('existingIsOlderThanExpected', () => {
|
|
124
|
+
const version794i = {
|
|
125
|
+
version: 'JLink_V7.94i',
|
|
126
|
+
versionFormat: 'string',
|
|
127
|
+
} as const;
|
|
128
|
+
const version794k = {
|
|
129
|
+
version: 'JLink_V7.94k',
|
|
130
|
+
versionFormat: 'string',
|
|
131
|
+
} as const;
|
|
132
|
+
const version796 = {
|
|
133
|
+
version: 'JLink_V7.96 ',
|
|
134
|
+
versionFormat: 'string',
|
|
135
|
+
} as const;
|
|
136
|
+
const version810b = {
|
|
137
|
+
version: 'JLink_V8.10b',
|
|
138
|
+
versionFormat: 'string',
|
|
139
|
+
} as const;
|
|
140
|
+
|
|
141
|
+
it('is false if no expected is specified', () => {
|
|
142
|
+
expect(
|
|
143
|
+
existingIsOlderThanExpected({ ...version794i, name: 'JlinkARM' })
|
|
144
|
+
).toBe(false);
|
|
145
|
+
});
|
|
146
|
+
it('is false if the actual is equal the expected', () => {
|
|
147
|
+
expect(
|
|
148
|
+
existingIsOlderThanExpected({
|
|
149
|
+
...version794i,
|
|
150
|
+
name: 'JlinkARM',
|
|
151
|
+
expectedVersion: version794i,
|
|
152
|
+
})
|
|
153
|
+
).toBe(false);
|
|
154
|
+
});
|
|
155
|
+
it('is false if the actual is newer than the expected', () => {
|
|
156
|
+
expect(
|
|
157
|
+
existingIsOlderThanExpected({
|
|
158
|
+
...version794k,
|
|
159
|
+
name: 'JlinkARM',
|
|
160
|
+
expectedVersion: version794i,
|
|
161
|
+
})
|
|
162
|
+
).toBe(false);
|
|
163
|
+
expect(
|
|
164
|
+
existingIsOlderThanExpected({
|
|
165
|
+
...version796,
|
|
166
|
+
name: 'JlinkARM',
|
|
167
|
+
expectedVersion: version794i,
|
|
168
|
+
})
|
|
169
|
+
).toBe(false);
|
|
170
|
+
expect(
|
|
171
|
+
existingIsOlderThanExpected({
|
|
172
|
+
...version810b,
|
|
173
|
+
name: 'JlinkARM',
|
|
174
|
+
expectedVersion: version794i,
|
|
175
|
+
})
|
|
176
|
+
).toBe(false);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('is true if the actual is older than the expected', () => {
|
|
180
|
+
expect(
|
|
181
|
+
existingIsOlderThanExpected({
|
|
182
|
+
...version794i,
|
|
183
|
+
name: 'JlinkARM',
|
|
184
|
+
expectedVersion: version794k,
|
|
185
|
+
})
|
|
186
|
+
).toBe(true);
|
|
187
|
+
expect(
|
|
188
|
+
existingIsOlderThanExpected({
|
|
189
|
+
...version794i,
|
|
190
|
+
name: 'JlinkARM',
|
|
191
|
+
expectedVersion: version796,
|
|
192
|
+
})
|
|
193
|
+
).toBe(true);
|
|
194
|
+
expect(
|
|
195
|
+
existingIsOlderThanExpected({
|
|
196
|
+
...version794i,
|
|
197
|
+
name: 'JlinkARM',
|
|
198
|
+
expectedVersion: version810b,
|
|
199
|
+
})
|
|
200
|
+
).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
describe('getJlinkCompatibility', () => {
|
|
205
|
+
const createModuleVersion = (
|
|
206
|
+
...dependencies: Dependency[]
|
|
207
|
+
): ModuleVersion => ({
|
|
208
|
+
classification: 'nrf-external',
|
|
209
|
+
name: 'nrfutil-device',
|
|
210
|
+
version: '2.5.0',
|
|
211
|
+
build_timestamp: '',
|
|
212
|
+
commit_date: '',
|
|
213
|
+
commit_hash: '',
|
|
214
|
+
dependencies: [
|
|
215
|
+
{
|
|
216
|
+
classification: 'nrf-external',
|
|
217
|
+
name: 'nrfdl',
|
|
218
|
+
versionFormat: 'semantic',
|
|
219
|
+
version: {
|
|
220
|
+
major: 0,
|
|
221
|
+
minor: 17,
|
|
222
|
+
patch: 38,
|
|
223
|
+
},
|
|
224
|
+
dependencies,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
host: '',
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it(`Reports no installed J-Link for for module versions reported by nrfutil-device before v2.7`, () => {
|
|
231
|
+
expect(getJlinkCompatibility(createModuleVersion())).toEqual({
|
|
232
|
+
kind: 'No J-Link installed',
|
|
233
|
+
requiredJlink: '7.94e',
|
|
234
|
+
actualJlink: 'none',
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it(`Reports no installed J-Link for for module versions reported by nrfutil-device since v2.7`, () => {
|
|
239
|
+
expect(
|
|
240
|
+
getJlinkCompatibility(
|
|
241
|
+
createModuleVersion({
|
|
242
|
+
name: 'JlinkARM',
|
|
243
|
+
expectedVersion: {
|
|
244
|
+
versionFormat: 'string',
|
|
245
|
+
version: 'JLink_V8.10f',
|
|
246
|
+
},
|
|
247
|
+
})
|
|
248
|
+
)
|
|
249
|
+
).toEqual({
|
|
250
|
+
kind: 'No J-Link installed',
|
|
251
|
+
requiredJlink: '8.10f',
|
|
252
|
+
actualJlink: 'none',
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it(`Reports an outdated J-Link version`, () => {
|
|
257
|
+
expect(
|
|
258
|
+
getJlinkCompatibility(
|
|
259
|
+
createModuleVersion({
|
|
260
|
+
name: 'JlinkARM',
|
|
261
|
+
version: 'JLink_V7.94e',
|
|
262
|
+
versionFormat: 'string',
|
|
263
|
+
expectedVersion: {
|
|
264
|
+
version: 'JLink_V7.94i',
|
|
265
|
+
versionFormat: 'string',
|
|
266
|
+
},
|
|
267
|
+
})
|
|
268
|
+
)
|
|
269
|
+
).toEqual({
|
|
270
|
+
kind: 'Outdated J-Link',
|
|
271
|
+
requiredJlink: '7.94i',
|
|
272
|
+
actualJlink: '7.94e',
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it(`Reports a newer J-Link version is used`, () => {
|
|
277
|
+
expect(
|
|
278
|
+
getJlinkCompatibility(
|
|
279
|
+
createModuleVersion({
|
|
280
|
+
name: 'JlinkARM',
|
|
281
|
+
version: 'JLink_V8.10f',
|
|
282
|
+
versionFormat: 'string',
|
|
283
|
+
expectedVersion: {
|
|
284
|
+
version: 'JLink_V7.94i',
|
|
285
|
+
versionFormat: 'string',
|
|
286
|
+
},
|
|
287
|
+
})
|
|
288
|
+
)
|
|
289
|
+
).toEqual({
|
|
290
|
+
kind: 'Newer J-Link is used',
|
|
291
|
+
requiredJlink: '7.94i',
|
|
292
|
+
actualJlink: '8.10f',
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it(`Reports the tested J-Link version is used`, () => {
|
|
297
|
+
expect(
|
|
298
|
+
getJlinkCompatibility(
|
|
299
|
+
createModuleVersion({
|
|
300
|
+
name: 'JlinkARM',
|
|
301
|
+
version: 'JLink_V7.94i',
|
|
302
|
+
versionFormat: 'string',
|
|
303
|
+
expectedVersion: {
|
|
304
|
+
version: 'JLink_V7.94i',
|
|
305
|
+
versionFormat: 'string',
|
|
306
|
+
},
|
|
307
|
+
})
|
|
308
|
+
)
|
|
309
|
+
).toEqual({ kind: 'Tested J-Link is used' });
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it(`Reports the tested J-Link version is used by specifying no expected version`, () => {
|
|
313
|
+
expect(
|
|
314
|
+
getJlinkCompatibility(
|
|
315
|
+
createModuleVersion({
|
|
316
|
+
name: 'JlinkARM',
|
|
317
|
+
version: 'JLink_V7.94i',
|
|
318
|
+
versionFormat: 'string',
|
|
319
|
+
})
|
|
320
|
+
)
|
|
321
|
+
).toEqual({ kind: 'Tested J-Link is used' });
|
|
322
|
+
});
|
|
323
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import semver from 'semver';
|
|
8
|
+
|
|
9
|
+
import { findDependency } from './moduleVersion';
|
|
10
|
+
import {
|
|
11
|
+
type Dependency,
|
|
12
|
+
hasVersion,
|
|
13
|
+
type ModuleVersion,
|
|
14
|
+
} from './sandboxTypes';
|
|
15
|
+
import {
|
|
16
|
+
type DiscriminatedVersion,
|
|
17
|
+
isStringVersion,
|
|
18
|
+
versionToString,
|
|
19
|
+
} from './version';
|
|
20
|
+
|
|
21
|
+
export const strippedVersionName = (version: DiscriminatedVersion) =>
|
|
22
|
+
versionToString(version).trim().replace('JLink_V', '');
|
|
23
|
+
|
|
24
|
+
export const hasExpectedVersionFormat = (
|
|
25
|
+
dependency: Dependency | DiscriminatedVersion,
|
|
26
|
+
logFailure = true
|
|
27
|
+
): dependency is DiscriminatedVersion => {
|
|
28
|
+
if (!hasVersion(dependency)) return false;
|
|
29
|
+
|
|
30
|
+
const jlinkVersionRegex = /^JLink_V\d+\.\d+[a-z]?$/;
|
|
31
|
+
const result =
|
|
32
|
+
isStringVersion(dependency) &&
|
|
33
|
+
versionToString(dependency).trim().match(jlinkVersionRegex) != null;
|
|
34
|
+
|
|
35
|
+
if (!result && logFailure) {
|
|
36
|
+
console.error(
|
|
37
|
+
`The J-Link version was not reported in the expected format. ` +
|
|
38
|
+
`Format: ${dependency.versionFormat}, ` +
|
|
39
|
+
`version: ${JSON.stringify(dependency)}, `
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const convertToSemver = (version: DiscriminatedVersion) => {
|
|
47
|
+
const [, majorMinor, patchLetter] =
|
|
48
|
+
strippedVersionName(version).match(/(\d\.\d+)(.)?/) ?? [];
|
|
49
|
+
|
|
50
|
+
const patch = patchLetter
|
|
51
|
+
? patchLetter.charCodeAt(0) - 'a'.charCodeAt(0) + 1
|
|
52
|
+
: 0;
|
|
53
|
+
|
|
54
|
+
return `${majorMinor}.${patch}`;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const existingIsOlderThanExpected = (
|
|
58
|
+
jlinkVersionDependency: Dependency
|
|
59
|
+
) => {
|
|
60
|
+
if (
|
|
61
|
+
jlinkVersionDependency.expectedVersion == null ||
|
|
62
|
+
!hasExpectedVersionFormat(jlinkVersionDependency) ||
|
|
63
|
+
!hasExpectedVersionFormat(jlinkVersionDependency.expectedVersion)
|
|
64
|
+
)
|
|
65
|
+
return false;
|
|
66
|
+
|
|
67
|
+
return semver.lt(
|
|
68
|
+
convertToSemver(jlinkVersionDependency),
|
|
69
|
+
convertToSemver(jlinkVersionDependency.expectedVersion)
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const nrfutilDeviceToJLink = (nrfutilDeviceVersion: string) => {
|
|
74
|
+
// According to https://docs.nordicsemi.com/bundle/nrfutil/page/guides/installing.html#prerequisites
|
|
75
|
+
if (semver.lt(nrfutilDeviceVersion, '2.0.0')) {
|
|
76
|
+
return '7.80c';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (semver.lt(nrfutilDeviceVersion, '2.1.0')) {
|
|
80
|
+
return '7.88j';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (semver.lt(nrfutilDeviceVersion, '2.5.4')) {
|
|
84
|
+
return '7.94e';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return '7.94i';
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const getJlinkCompatibility = (moduleVersion: ModuleVersion) => {
|
|
91
|
+
const jlinkVersionDependency = findDependency(
|
|
92
|
+
'JlinkARM',
|
|
93
|
+
moduleVersion.dependencies
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (!hasVersion(jlinkVersionDependency)) {
|
|
97
|
+
const requiredVersion =
|
|
98
|
+
jlinkVersionDependency?.expectedVersion != null
|
|
99
|
+
? strippedVersionName(jlinkVersionDependency.expectedVersion)
|
|
100
|
+
: nrfutilDeviceToJLink(moduleVersion.version);
|
|
101
|
+
return {
|
|
102
|
+
kind: 'No J-Link installed',
|
|
103
|
+
requiredJlink: requiredVersion,
|
|
104
|
+
actualJlink: 'none',
|
|
105
|
+
} as const;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (
|
|
109
|
+
jlinkVersionDependency.expectedVersion &&
|
|
110
|
+
existingIsOlderThanExpected(jlinkVersionDependency)
|
|
111
|
+
) {
|
|
112
|
+
const requiredJlink = strippedVersionName(
|
|
113
|
+
jlinkVersionDependency.expectedVersion
|
|
114
|
+
);
|
|
115
|
+
const actualJlink = strippedVersionName(jlinkVersionDependency);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
kind: 'Outdated J-Link',
|
|
119
|
+
requiredJlink,
|
|
120
|
+
actualJlink,
|
|
121
|
+
} as const;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
jlinkVersionDependency.expectedVersion == null ||
|
|
126
|
+
jlinkVersionDependency.version ===
|
|
127
|
+
jlinkVersionDependency.expectedVersion.version
|
|
128
|
+
) {
|
|
129
|
+
return {
|
|
130
|
+
kind: 'Tested J-Link is used',
|
|
131
|
+
} as const;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const requiredJlink = strippedVersionName(
|
|
135
|
+
jlinkVersionDependency.expectedVersion
|
|
136
|
+
);
|
|
137
|
+
const actualJlink = strippedVersionName(jlinkVersionDependency);
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
kind: 'Newer J-Link is used',
|
|
141
|
+
requiredJlink,
|
|
142
|
+
actualJlink,
|
|
143
|
+
} as const;
|
|
144
|
+
};
|