@@ -9,9 +9,10 @@ import {
9
9
getUserDataDir ,
10
10
launcherConfig ,
11
11
} from '@nordicsemiconductor/pc-nrfconnect-shared' ;
12
- import type { NrfutilModules } from '@nordicsemiconductor/pc-nrfconnect-shared/ipc/MetaFiles' ;
13
- import { resolveModuleVersion } from '@nordicsemiconductor/pc-nrfconnect-shared/nrfutil/moduleVersion' ;
14
- import getSandbox from '@nordicsemiconductor/pc-nrfconnect-shared/nrfutil/sandbox' ;
12
+ import {
13
+ getJlinkCompatibility as getJlinkCompatibilityFromModuleVersion ,
14
+ prepareSandbox ,
15
+ } from '@nordicsemiconductor/pc-nrfconnect-shared/nrfutil' ;
15
16
import { memoize } from 'lodash' ;
16
17
import semver from 'semver' ;
17
18
@@ -21,10 +22,6 @@ import {
21
22
isWithdrawn ,
22
23
LaunchableApp ,
23
24
} from '../../ipc/apps' ;
24
- import {
25
- existingIsOlderThanExpected ,
26
- strippedVersionName ,
27
- } from './jlinkVersion' ;
28
25
import Link from './Link' ;
29
26
import minimalRequiredAppVersions from './minimalRequiredAppVersions' ;
30
27
@@ -169,36 +166,17 @@ const checkMinimalRequiredAppVersions: AppCompatibilityChecker = app => {
169
166
) ;
170
167
} ;
171
168
172
- const nrfutilDeviceToJLink = ( device : string ) => {
173
- // According to https://docs.nordicsemi.com/bundle/nrfutil/page/guides/installing.html#prerequisites
174
- if ( semver . lt ( device , '2.0.0' ) ) {
175
- return 'V7.80c' ;
176
- }
177
-
178
- if ( semver . lt ( device , '2.1.0' ) ) {
179
- return 'V7.88j' ;
180
- }
181
-
182
- if ( semver . lt ( device , '2.5.4' ) ) {
183
- return 'V7.94e' ;
184
- }
185
-
186
- return 'V7.94i' ;
187
- } ;
188
-
189
- const getJlinkVersionDependency = memoize (
190
- async ( nrfutilDeviceVersion : string ) => {
191
- const userDir = getUserDataDir ( ) ;
192
- const sandbox = await getSandbox (
193
- userDir ,
194
- 'device' ,
195
- nrfutilDeviceVersion
196
- ) ;
197
- const moduleVersion = await sandbox . getModuleVersion ( ) ;
169
+ const getJlinkCompatibility = memoize ( async ( nrfutilDeviceVersion : string ) => {
170
+ const userDir = getUserDataDir ( ) ;
171
+ const sandbox = await prepareSandbox (
172
+ userDir ,
173
+ 'device' ,
174
+ nrfutilDeviceVersion
175
+ ) ;
176
+ const moduleVersion = await sandbox . getModuleVersion ( ) ;
198
177
199
- return resolveModuleVersion ( 'JlinkARM' , moduleVersion . dependencies ) ;
200
- }
201
- ) ;
178
+ return getJlinkCompatibilityFromModuleVersion ( moduleVersion ) ;
179
+ } ) ;
202
180
203
181
export const checkJLinkRequirements : AppCompatibilityChecker = async (
204
182
app : LaunchableApp
@@ -207,80 +185,67 @@ export const checkJLinkRequirements: AppCompatibilityChecker = async (
207
185
return undecided ;
208
186
}
209
187
210
- const deviceVersion =
211
- // @ts -expect-error -- Needs to be added to Installed in shared as `nrfutil?: NrfutilModules;`. Then the typecast should also be removed.
212
- ( app . nrfutil as NrfutilModules | undefined ) ?. device ?. at ( 0 ) ;
188
+ const deviceVersion = app . nrfutil ?. device ?. at ( 0 ) ;
213
189
214
190
if ( ! deviceVersion ) {
215
191
return undecided ;
216
192
}
217
193
218
- const jlinkVersionDependency = await getJlinkVersionDependency (
219
- deviceVersion
220
- ) ;
221
- const noJlinkInstalled = jlinkVersionDependency ?. version == null ;
222
- if ( noJlinkInstalled ) {
223
- const requiredVersion = nrfutilDeviceToJLink ( deviceVersion ) ;
194
+ const jlinkCompatibility = await getJlinkCompatibility ( deviceVersion ) ;
195
+
196
+ if ( jlinkCompatibility . kind === 'No J-Link installed' ) {
197
+ const { requiredJlink } = jlinkCompatibility ;
224
198
225
199
return incompatible (
226
200
'Missing dependency' ,
227
- `Required SEGGER J-Link not found: expected version ${ requiredVersion } ` ,
201
+ `Required SEGGER J-Link not found: expected version V ${ requiredJlink } ` ,
228
202
< div className = "tw-flex tw-flex-col tw-gap-2" >
229
- < div > This app requires SEGGER J-Link { requiredVersion } .</ div >
203
+ < div > This app requires SEGGER J-Link V { requiredJlink } .</ div >
230
204
< div >
231
205
< Link href = "https://www.segger.com/downloads/jlink/" >
232
206
Download
233
207
</ Link > { ' ' }
234
208
and install the SEGGER J-Link Software and Documentation
235
- pack { requiredVersion } . Restart nRF Connect for Desktop
209
+ pack V { requiredJlink } . Restart nRF Connect for Desktop
236
210
afterwards.
237
211
</ div >
238
212
</ div > ,
239
213
{
240
214
warningKind : WarningKind . JLINK ,
241
215
app : app . name ,
242
216
nrfutilDevice : deviceVersion ,
243
- requiredJlink : requiredVersion ,
244
- actualJlink : 'none' ,
217
+ ...jlinkCompatibility ,
245
218
}
246
219
) ;
247
220
}
248
221
249
- if (
250
- jlinkVersionDependency . expectedVersion &&
251
- existingIsOlderThanExpected ( jlinkVersionDependency )
252
- ) {
253
- const expectedVersionNumber = strippedVersionName (
254
- jlinkVersionDependency . expectedVersion
255
- ) ;
256
- const actualVersionNumber = strippedVersionName ( jlinkVersionDependency ) ;
222
+ if ( jlinkCompatibility . kind === 'Outdated J-Link' ) {
223
+ const { actualJlink, requiredJlink } = jlinkCompatibility ;
257
224
258
225
return incompatible (
259
226
'Outdated dependency' ,
260
- `Untested version V${ actualVersionNumber } of SEGGER J-Link found: ` +
261
- `expected at least version V${ expectedVersionNumber } ` ,
227
+ `Untested version V${ actualJlink } of SEGGER J-Link found: ` +
228
+ `expected at least version V${ requiredJlink } ` ,
262
229
< div className = "tw-flex tw-flex-col tw-gap-2" >
263
230
< div >
264
- This app was tested with SEGGER J-Link V
265
- { expectedVersionNumber } but version V{ actualVersionNumber } { ' ' }
266
- was found on your system.
231
+ This app was tested with SEGGER J-Link V{ requiredJlink } but
232
+ version V{ actualJlink } was found on your system.
267
233
</ div >
268
234
< div > This app might not work as expected!</ div >
269
235
< div >
270
236
< Link href = "https://www.segger.com/downloads/jlink/" >
271
237
Download
272
238
</ Link > { ' ' }
273
239
and install the SEGGER J-Link Software and Documentation
274
- pack V{ expectedVersionNumber } . Restart nRF Connect for
275
- Desktop afterwards.
240
+ pack V{ requiredJlink } . Restart nRF Connect for Desktop
241
+ afterwards.
276
242
</ div >
277
243
</ div > ,
278
244
{
279
245
warningKind : WarningKind . JLINK ,
280
246
app : app . name ,
281
247
nrfutilDevice : deviceVersion ,
282
- requiredJlink : jlinkVersionDependency . expectedVersion . version ,
283
- actualJlink : jlinkVersionDependency . version ,
248
+ ...jlinkCompatibility ,
284
249
}
285
250
) ;
286
251
}
0 commit comments