@onekeyfe/hd-core 1.2.0-alpha.96 → 1.2.0-alpha.98
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/__tests__/firmware-update/device-update-bootloader.test.ts +8 -1
- package/__tests__/firmware-update/firmware-prepared-host-digest.test.ts +106 -2
- package/__tests__/firmware-update/firmware-prepared-resource-archive.test.ts +150 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +112 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +101 -0
- package/__tests__/firmware-update/firmware-update-prepared-resource-executors.test.ts +326 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +2 -2
- package/__tests__/protocol-v2.test.ts +131 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwarePreparedResourceArchive.d.ts +11 -0
- package/dist/api/firmware/FirmwarePreparedResourceArchive.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +6 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +359 -157
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +1 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +2 -2
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV2.ts +95 -72
- package/src/api/FirmwareUpdateV3.ts +74 -51
- package/src/api/FirmwareUpdateV4.ts +72 -7
- package/src/api/device/DeviceUpdateBootloader.ts +17 -12
- package/src/api/firmware/FirmwarePreparedResourceArchive.ts +207 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +2 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +70 -48
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +17 -0
- package/src/types/api/deviceUpdateBootloader.ts +1 -0
- package/src/types/api/firmwareUpdate.ts +2 -1
- package/src/types/api/firmwareUpdatePlan.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceUpdateBootloader.d.ts","sourceRoot":"","sources":["../../../src/types/api/deviceUpdateBootloader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,4BAA4B,GAAG;IACzC,YAAY,CAAC,EAAE,0BAA0B,CAAC;IAC1C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"deviceUpdateBootloader.d.ts","sourceRoot":"","sources":["../../../src/types/api/deviceUpdateBootloader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,4BAA4B,GAAG;IACzC,YAAY,CAAC,EAAE,0BAA0B,CAAC;IAC1C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,4BAA4B,GACpC,QAAQ,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -39,7 +39,7 @@ export interface FirmwareUpdateBinaryParams {
|
|
|
39
39
|
export interface FirmwareUpdateArtifactParams {
|
|
40
40
|
preparedPlan: FirmwareUpdatePreparedPlan;
|
|
41
41
|
hostBindingGeneration: number;
|
|
42
|
-
artifact
|
|
42
|
+
artifact?: FirmwareArtifactReference;
|
|
43
43
|
resourceEntries?: Array<{
|
|
44
44
|
entryName: string;
|
|
45
45
|
artifact: FirmwareArtifactReference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firmwareUpdate.d.ts","sourceRoot":"","sources":["../../../src/types/api/firmwareUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE/E,KAAK,WAAW,GAAG,UAAU,GAAG,KAAK,CAAC;AAEtC,MA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MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,CAAC,sBAAsB,CAAC,GACrC,QAAQ,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,CAAC,sBAAsB,CAAC,GACrC,QAAQ,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CAAC"}
|
|
@@ -10,8 +10,8 @@ export interface FirmwareUpdatePlanArtifact {
|
|
|
10
10
|
url: string;
|
|
11
11
|
container: 'raw' | 'zip';
|
|
12
12
|
logicalName?: string;
|
|
13
|
-
expectedSize
|
|
14
|
-
expectedSha256
|
|
13
|
+
expectedSize: number;
|
|
14
|
+
expectedSha256: string;
|
|
15
15
|
targetVersion?: string;
|
|
16
16
|
}
|
|
17
17
|
export interface FirmwareUpdatePlan {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firmwareUpdatePlan.d.ts","sourceRoot":"","sources":["../../../src/types/api/firmwareUpdatePlan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GACtC,UAAU,GACV,KAAK,GACL,YAAY,GACZ,UAAU,GACV,WAAW,GACX,gBAAgB,CAAC;AAErB,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,sBAAsB,CAAC;AAElG,MAAM,MAAM,6BAA6B,G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G,IAAI,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,aAAa,CAAC;IAC5B,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,CAAC;IAC7D,SAAS,EAAE,0BAA0B,EAAE,CAAC;IACxC,eAAe,EAAE,wBAAwB,EAAE,CAAC;CAC7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.98",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.98",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.98",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "10f2dcaecec17a629216c2402cc9ab8801987297"
|
|
48
48
|
}
|
|
@@ -29,10 +29,11 @@ import { DataManager } from '../data-manager';
|
|
|
29
29
|
import { DEVICE } from '../events';
|
|
30
30
|
import { type FirmwareByteSource, openFirmwareByteSource } from './firmware/FirmwareArtifactSource';
|
|
31
31
|
import { resolveFirmwareUpdateHostBinding } from './firmware/FirmwareHostBinding';
|
|
32
|
+
import { readVerifiedPreparedResourceArchive } from './firmware/FirmwarePreparedResourceArchive';
|
|
32
33
|
import {
|
|
33
34
|
assertFirmwareUpdatePreparedPlanBinding,
|
|
34
35
|
assertFirmwareUpdatePreparedPlanDeviceIdentity,
|
|
35
|
-
|
|
36
|
+
getFirmwareUpdatePreparedRawArtifact,
|
|
36
37
|
validateFirmwareUpdatePreparedPlan,
|
|
37
38
|
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
38
39
|
|
|
@@ -161,21 +162,17 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
161
162
|
{ name: 'firmwareType', type: 'string' },
|
|
162
163
|
]);
|
|
163
164
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
payload.binary !== undefined &&
|
|
167
|
-
'artifact' in payload &&
|
|
168
|
-
payload.artifact !== undefined
|
|
169
|
-
) {
|
|
165
|
+
const hasPreparedPlan = payload.preparedPlan !== undefined;
|
|
166
|
+
if (hasPreparedPlan && (payload.binary !== undefined || payload.version !== undefined)) {
|
|
170
167
|
throw ERRORS.TypedError(
|
|
171
168
|
HardwareErrorCode.CallMethodInvalidParameter,
|
|
172
|
-
'
|
|
169
|
+
'Prepared firmware plans cannot be combined with legacy firmware inputs'
|
|
173
170
|
);
|
|
174
171
|
}
|
|
175
|
-
if (
|
|
172
|
+
if (!hasPreparedPlan && payload.artifact !== undefined) {
|
|
176
173
|
throw ERRORS.TypedError(
|
|
177
174
|
HardwareErrorCode.CallMethodInvalidParameter,
|
|
178
|
-
'
|
|
175
|
+
'Firmware artifacts require a prepared plan'
|
|
179
176
|
);
|
|
180
177
|
}
|
|
181
178
|
|
|
@@ -192,7 +189,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
192
189
|
isUpdateBootloader: payload.isUpdateBootloader,
|
|
193
190
|
};
|
|
194
191
|
|
|
195
|
-
if ('version' in payload) {
|
|
192
|
+
if (!hasPreparedPlan && 'version' in payload) {
|
|
196
193
|
this.params = {
|
|
197
194
|
...this.params,
|
|
198
195
|
version: payload.version,
|
|
@@ -200,20 +197,25 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
200
197
|
};
|
|
201
198
|
}
|
|
202
199
|
|
|
203
|
-
if ('binary' in payload) {
|
|
200
|
+
if (!hasPreparedPlan && 'binary' in payload) {
|
|
204
201
|
this.params = {
|
|
205
202
|
...this.params,
|
|
206
203
|
binary: payload.binary,
|
|
207
204
|
};
|
|
208
205
|
}
|
|
209
206
|
|
|
210
|
-
if (
|
|
207
|
+
if (hasPreparedPlan) {
|
|
211
208
|
const preparedPlan = validateFirmwareUpdatePreparedPlan(payload.preparedPlan);
|
|
212
209
|
const hostBinding = resolveFirmwareUpdateHostBinding(
|
|
213
210
|
payload.hostBindingGeneration,
|
|
214
211
|
preparedPlan.preparedPlanDigest
|
|
215
212
|
);
|
|
216
213
|
const target = payload.isUpdateBootloader ? 'bootloader' : payload.updateType;
|
|
214
|
+
const plannedArtifact = getFirmwareUpdatePreparedRawArtifact({
|
|
215
|
+
preparedPlan,
|
|
216
|
+
target,
|
|
217
|
+
role: target,
|
|
218
|
+
}).artifact;
|
|
217
219
|
const resourceBindings = (payload.resourceEntries ?? []).map(
|
|
218
220
|
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
219
221
|
target: 'resource' as const,
|
|
@@ -225,15 +227,18 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
225
227
|
preparedPlan,
|
|
226
228
|
executor: 'v2',
|
|
227
229
|
platform: payload.platform,
|
|
228
|
-
scopeTargets: [
|
|
229
|
-
|
|
230
|
+
scopeTargets: [
|
|
231
|
+
target,
|
|
232
|
+
...(target === 'firmware' && resourceBindings.length ? (['resource'] as const) : []),
|
|
233
|
+
],
|
|
234
|
+
bindings: [{ target, artifact: payload.artifact ?? plannedArtifact }, ...resourceBindings],
|
|
230
235
|
});
|
|
231
236
|
this.params = {
|
|
232
237
|
...this.params,
|
|
233
238
|
preparedPlan,
|
|
234
|
-
artifact:
|
|
235
|
-
resourceEntries: payload.resourceEntries,
|
|
239
|
+
artifact: plannedArtifact,
|
|
236
240
|
artifactReader: hostBinding.artifactReader,
|
|
241
|
+
firmwareType: preparedPlan.firmwareType,
|
|
237
242
|
};
|
|
238
243
|
}
|
|
239
244
|
}
|
|
@@ -543,6 +548,18 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
543
548
|
}
|
|
544
549
|
};
|
|
545
550
|
|
|
551
|
+
const preparedResourceRequested =
|
|
552
|
+
!params.isUpdateBootloader &&
|
|
553
|
+
params.updateType === 'firmware' &&
|
|
554
|
+
(params.preparedPlan?.targetsToUpdate.includes('resource') ?? false);
|
|
555
|
+
if (preparedResourceRequested && device.isBootloader()) {
|
|
556
|
+
throw ERRORS.TypedError(
|
|
557
|
+
HardwareErrorCode.RuntimeError,
|
|
558
|
+
'Prepared firmware resources require the device application mode',
|
|
559
|
+
{ firmwareUpdateCode: 'FirmwareArtifactsNotPrepared', artifactName: 'resource' }
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
|
|
546
563
|
if (!device.isBootloader() && features) {
|
|
547
564
|
const serialNo = device.getCurrentSerialNo();
|
|
548
565
|
// should go to bootloader mode manually
|
|
@@ -553,72 +570,78 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
553
570
|
// All network-backed input must be ready before the first device mutation.
|
|
554
571
|
await acquireFirmwareSource();
|
|
555
572
|
|
|
556
|
-
//
|
|
557
|
-
if (
|
|
573
|
+
// PreparedPlan 资源只依赖获批 ZIP;live release 仅保留给非 prepared 旧流程。
|
|
574
|
+
if (preparedResourceRequested) {
|
|
575
|
+
if (!this.isSupportResourceUpdate(params.updateType)) {
|
|
576
|
+
throw ERRORS.TypedError(
|
|
577
|
+
HardwareErrorCode.RuntimeError,
|
|
578
|
+
'Prepared firmware resources are not supported by this device',
|
|
579
|
+
{ firmwareUpdateCode: 'FirmwareArtifactsNotPrepared', artifactName: 'resource' }
|
|
580
|
+
);
|
|
581
|
+
}
|
|
558
582
|
this.postTipMessage('CheckLatestUiResource');
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
583
|
+
this.postTipMessage('DownloadLatestUiResource');
|
|
584
|
+
const verifiedEntries = await readVerifiedPreparedResourceArchive({
|
|
585
|
+
preparedPlan: params.preparedPlan as FirmwareUpdatePreparedPlan,
|
|
586
|
+
reader: params.artifactReader,
|
|
563
587
|
});
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
source: FirmwareByteSource;
|
|
570
|
-
}> = [];
|
|
571
|
-
try {
|
|
572
|
-
for (const entry of params.resourceEntries) {
|
|
573
|
-
const resourceName = getFirmwareUpdateResourceName(entry.entryName);
|
|
574
|
-
const source = await openFirmwareByteSource({
|
|
575
|
-
artifact: entry.artifact,
|
|
576
|
-
reader: params.artifactReader,
|
|
577
|
-
});
|
|
578
|
-
if (!source) {
|
|
579
|
-
throw new Error('Firmware resource entry is not prepared');
|
|
580
|
-
}
|
|
581
|
-
sources.push({ entryName: resourceName, source });
|
|
582
|
-
}
|
|
583
|
-
await updateResourcesFromSources(
|
|
584
|
-
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
585
|
-
this.postMessage,
|
|
586
|
-
device,
|
|
587
|
-
sources.map(entry => ({
|
|
588
|
-
entryName: entry.entryName,
|
|
589
|
-
source: entry.source,
|
|
590
|
-
}))
|
|
591
|
-
);
|
|
592
|
-
} finally {
|
|
593
|
-
await Promise.all(
|
|
594
|
-
sources.map(entry => entry.source.close().catch(() => undefined))
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
598
|
-
} else {
|
|
599
|
-
if (
|
|
600
|
-
params.artifactReader ||
|
|
601
|
-
DataManager.getSettings('firmwareManifestMode') === 'external-only'
|
|
602
|
-
) {
|
|
588
|
+
const sources: Array<{ entryName: string; source: FirmwareByteSource }> = [];
|
|
589
|
+
try {
|
|
590
|
+
for (const entry of verifiedEntries) {
|
|
591
|
+
const source = await openFirmwareByteSource({ binary: entry.binary });
|
|
592
|
+
if (!source) {
|
|
603
593
|
throw ERRORS.TypedError(
|
|
604
594
|
HardwareErrorCode.RuntimeError,
|
|
605
|
-
|
|
595
|
+
`Firmware resource entry ${entry.entryName} is empty`,
|
|
606
596
|
{
|
|
607
|
-
firmwareUpdateCode: '
|
|
597
|
+
firmwareUpdateCode: 'FirmwareArtifactReceiptMismatch',
|
|
608
598
|
artifactName: 'resource',
|
|
609
599
|
}
|
|
610
600
|
);
|
|
611
601
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
602
|
+
sources.push({ entryName: entry.entryName, source });
|
|
603
|
+
}
|
|
604
|
+
await updateResourcesFromSources(
|
|
605
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
606
|
+
this.postMessage,
|
|
607
|
+
device,
|
|
608
|
+
sources
|
|
609
|
+
);
|
|
610
|
+
} finally {
|
|
611
|
+
await Promise.all(sources.map(entry => entry.source.close().catch(() => undefined)));
|
|
612
|
+
}
|
|
613
|
+
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
614
|
+
} else if (this.isSupportResourceUpdate(params.updateType)) {
|
|
615
|
+
this.postTipMessage('CheckLatestUiResource');
|
|
616
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
617
|
+
features,
|
|
618
|
+
forcedUpdateRes: params.forcedUpdateRes,
|
|
619
|
+
firmwareType,
|
|
620
|
+
});
|
|
621
|
+
if (resourceUrl) {
|
|
622
|
+
this.postTipMessage('DownloadLatestUiResource');
|
|
623
|
+
if (
|
|
624
|
+
params.artifactReader ||
|
|
625
|
+
DataManager.getSettings('firmwareManifestMode') === 'external-only'
|
|
626
|
+
) {
|
|
627
|
+
throw ERRORS.TypedError(
|
|
628
|
+
HardwareErrorCode.RuntimeError,
|
|
629
|
+
'Firmware resource must be prepared by the external firmware host',
|
|
630
|
+
{
|
|
631
|
+
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
632
|
+
artifactName: 'resource',
|
|
633
|
+
}
|
|
620
634
|
);
|
|
621
635
|
}
|
|
636
|
+
const resourceBinary: ArrayBuffer | Buffer = (await getSysResourceBinary(resourceUrl))
|
|
637
|
+
.binary;
|
|
638
|
+
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
639
|
+
await updateResources(
|
|
640
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
641
|
+
this.postMessage,
|
|
642
|
+
device,
|
|
643
|
+
resourceBinary
|
|
644
|
+
);
|
|
622
645
|
}
|
|
623
646
|
}
|
|
624
647
|
|
|
@@ -21,10 +21,11 @@ import { DEVICE } from '../events';
|
|
|
21
21
|
import { buildProtocolV1FeaturesPayload } from '../deviceProfile';
|
|
22
22
|
import { openFirmwareByteSource } from './firmware/FirmwareArtifactSource';
|
|
23
23
|
import { resolveFirmwareUpdateHostBinding } from './firmware/FirmwareHostBinding';
|
|
24
|
+
import { readVerifiedPreparedResourceArchive } from './firmware/FirmwarePreparedResourceArchive';
|
|
24
25
|
import {
|
|
25
26
|
assertFirmwareUpdatePreparedPlanBinding,
|
|
26
27
|
assertFirmwareUpdatePreparedPlanDeviceIdentity,
|
|
27
|
-
|
|
28
|
+
getFirmwareUpdatePreparedRawArtifact,
|
|
28
29
|
validateFirmwareUpdatePreparedPlan,
|
|
29
30
|
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
30
31
|
|
|
@@ -78,10 +79,16 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
78
79
|
{ name: 'firmwareType', type: 'string' },
|
|
79
80
|
{ name: 'platform', type: 'string' },
|
|
80
81
|
]);
|
|
81
|
-
const preparedPlan
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const hasPreparedPlan = payload.preparedPlan !== undefined;
|
|
83
|
+
if (!hasPreparedPlan && payload.artifacts !== undefined) {
|
|
84
|
+
throw ERRORS.TypedError(
|
|
85
|
+
HardwareErrorCode.CallMethodInvalidParameter,
|
|
86
|
+
'Firmware artifacts require a prepared plan'
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const preparedPlan = hasPreparedPlan
|
|
90
|
+
? validateFirmwareUpdatePreparedPlan(payload.preparedPlan)
|
|
91
|
+
: undefined;
|
|
85
92
|
const hasLegacyInputs = [
|
|
86
93
|
payload.bleVersion,
|
|
87
94
|
payload.bleBinary,
|
|
@@ -103,44 +110,60 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
103
110
|
preparedPlan.preparedPlanDigest
|
|
104
111
|
).artifactReader
|
|
105
112
|
: payload.artifactReader;
|
|
113
|
+
const preparedArtifacts: NonNullable<FirmwareUpdateV3Params['artifacts']> = {};
|
|
106
114
|
if (preparedPlan) {
|
|
115
|
+
const componentTargets = ['bootloader', 'firmware', 'ble'] as const;
|
|
116
|
+
const supportedTargets = new Set<string>([...componentTargets, 'resource']);
|
|
117
|
+
const unsupportedTarget = preparedPlan.targetsToUpdate.find(
|
|
118
|
+
target => !supportedTargets.has(target)
|
|
119
|
+
);
|
|
120
|
+
if (unsupportedTarget) {
|
|
121
|
+
throw ERRORS.TypedError(
|
|
122
|
+
HardwareErrorCode.RuntimeError,
|
|
123
|
+
`Firmware prepared plan target ${unsupportedTarget} is not supported by V3`,
|
|
124
|
+
{ firmwareUpdateCode: 'FirmwarePreparedPlanInvalid' }
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
for (const target of componentTargets) {
|
|
128
|
+
if (preparedPlan.targetsToUpdate.includes(target)) {
|
|
129
|
+
preparedArtifacts[target] = getFirmwareUpdatePreparedRawArtifact({
|
|
130
|
+
preparedPlan,
|
|
131
|
+
target,
|
|
132
|
+
role: target,
|
|
133
|
+
}).artifact;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const resourceBindings = (payload.artifacts?.resourceEntries ?? []).map(
|
|
137
|
+
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
138
|
+
target: 'resource' as const,
|
|
139
|
+
entryName: entry.entryName,
|
|
140
|
+
artifact: entry.artifact,
|
|
141
|
+
})
|
|
142
|
+
);
|
|
107
143
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
108
144
|
preparedPlan,
|
|
109
145
|
executor: 'v3',
|
|
110
146
|
platform: payload.platform,
|
|
111
|
-
scopeTargets: [
|
|
147
|
+
scopeTargets: [
|
|
148
|
+
'bootloader',
|
|
149
|
+
'firmware',
|
|
150
|
+
'ble',
|
|
151
|
+
...(resourceBindings.length ? (['resource'] as const) : []),
|
|
152
|
+
],
|
|
112
153
|
bindings: [
|
|
113
|
-
...(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
]
|
|
128
|
-
: []),
|
|
129
|
-
...(payload.artifacts?.ble
|
|
130
|
-
? [
|
|
131
|
-
{
|
|
132
|
-
target: 'ble' as const,
|
|
133
|
-
artifact: payload.artifacts.ble,
|
|
134
|
-
},
|
|
135
|
-
]
|
|
136
|
-
: []),
|
|
137
|
-
...(payload.artifacts?.resourceEntries ?? []).map(
|
|
138
|
-
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
139
|
-
target: 'resource' as const,
|
|
140
|
-
entryName: entry.entryName,
|
|
141
|
-
artifact: entry.artifact,
|
|
142
|
-
})
|
|
143
|
-
),
|
|
154
|
+
...componentTargets.flatMap(target => {
|
|
155
|
+
const plannedArtifact = preparedArtifacts[target];
|
|
156
|
+
const suppliedArtifact = payload.artifacts?.[target];
|
|
157
|
+
return plannedArtifact || suppliedArtifact
|
|
158
|
+
? [
|
|
159
|
+
{
|
|
160
|
+
target,
|
|
161
|
+
artifact: suppliedArtifact ?? (plannedArtifact as FirmwareArtifactReference),
|
|
162
|
+
},
|
|
163
|
+
]
|
|
164
|
+
: [];
|
|
165
|
+
}),
|
|
166
|
+
...resourceBindings,
|
|
144
167
|
],
|
|
145
168
|
});
|
|
146
169
|
}
|
|
@@ -158,7 +181,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
158
181
|
firmwareType: preparedPlan?.firmwareType ?? payload.firmwareType,
|
|
159
182
|
platform: payload.platform,
|
|
160
183
|
artifactReader,
|
|
161
|
-
artifacts:
|
|
184
|
+
artifacts: preparedPlan ? preparedArtifacts : undefined,
|
|
162
185
|
};
|
|
163
186
|
}
|
|
164
187
|
|
|
@@ -285,25 +308,25 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
285
308
|
}
|
|
286
309
|
|
|
287
310
|
private async prepareResourceInput(firmwareType: EFirmwareType) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
if (preparedEntries?.length) {
|
|
311
|
+
if (this.params.preparedPlan?.targetsToUpdate.includes('resource')) {
|
|
312
|
+
const verifiedEntries = await readVerifiedPreparedResourceArchive({
|
|
313
|
+
preparedPlan: this.params.preparedPlan,
|
|
314
|
+
reader: this.params.artifactReader,
|
|
315
|
+
});
|
|
296
316
|
const resourceEntries: Array<{ entryName: string; source: FirmwareByteSource }> = [];
|
|
297
|
-
for (const entry of
|
|
298
|
-
const
|
|
299
|
-
const source = await this.openArtifactSource(undefined, entry.artifact);
|
|
317
|
+
for (const entry of verifiedEntries) {
|
|
318
|
+
const source = await this.openArtifactSource(entry.binary, undefined);
|
|
300
319
|
if (!source) {
|
|
301
320
|
throw ERRORS.TypedError(
|
|
302
321
|
HardwareErrorCode.RuntimeError,
|
|
303
|
-
`Firmware resource entry ${entry.entryName} is
|
|
322
|
+
`Firmware resource entry ${entry.entryName} is empty`,
|
|
323
|
+
{
|
|
324
|
+
firmwareUpdateCode: 'FirmwareArtifactReceiptMismatch',
|
|
325
|
+
artifactName: 'resource',
|
|
326
|
+
}
|
|
304
327
|
);
|
|
305
328
|
}
|
|
306
|
-
resourceEntries.push({ entryName:
|
|
329
|
+
resourceEntries.push({ entryName: entry.entryName, source });
|
|
307
330
|
}
|
|
308
331
|
return {
|
|
309
332
|
resourceBinary: null,
|
|
@@ -299,12 +299,15 @@ const PROTOCOL_V2_FIRMWARE_STAGING_PATHS = new Set(
|
|
|
299
299
|
const PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH = 'vol0:/loaders/bootloader/boot_resource.okpkg';
|
|
300
300
|
const PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH = `${PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH}.staging`;
|
|
301
301
|
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
const isProtocolV2BootResourcePackagePath = (devicePath: string) =>
|
|
303
|
+
typeof devicePath === 'string' &&
|
|
304
|
+
devicePath.replace(/^vol0:(?!\/)/i, 'vol0:/').toLowerCase() ===
|
|
305
|
+
PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH;
|
|
306
|
+
|
|
307
|
+
const resolveProtocolV2ResourceWritePath = (devicePath: string) =>
|
|
308
|
+
isProtocolV2BootResourcePackagePath(devicePath)
|
|
305
309
|
? PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH
|
|
306
310
|
: devicePath;
|
|
307
|
-
};
|
|
308
311
|
|
|
309
312
|
const PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID = new Map<
|
|
310
313
|
number,
|
|
@@ -564,6 +567,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
564
567
|
|
|
565
568
|
private protocolV2ExecutionInLoader = false;
|
|
566
569
|
|
|
570
|
+
private protocolV2BootResourceStagingSafe = false;
|
|
571
|
+
|
|
567
572
|
private protocolV2CompletedTargetVersions = new Map<number, number>();
|
|
568
573
|
|
|
569
574
|
private protocolV2LatestFinalFeatures?: Features;
|
|
@@ -2114,6 +2119,21 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2114
2119
|
resourceSources: ProtocolV2ResourceBundleSource[];
|
|
2115
2120
|
}): ProtocolV2ExecutionPhase[] {
|
|
2116
2121
|
const phases: ProtocolV2ExecutionPhase[] = [];
|
|
2122
|
+
const bootResourceSources = resourceSources.filter(source =>
|
|
2123
|
+
isProtocolV2BootResourcePackagePath(source.devicePath)
|
|
2124
|
+
);
|
|
2125
|
+
const remainingResourceSources = resourceSources.filter(
|
|
2126
|
+
source => !isProtocolV2BootResourcePackagePath(source.devicePath)
|
|
2127
|
+
);
|
|
2128
|
+
// A previous interrupted run may have left a promotable staging file. Replace
|
|
2129
|
+
// it with the current approved package before any firmware-triggered reboot.
|
|
2130
|
+
if (bootResourceSources.length > 0) {
|
|
2131
|
+
phases.push({
|
|
2132
|
+
kind: 'resource-sync',
|
|
2133
|
+
installSources: [],
|
|
2134
|
+
resourceSources: bootResourceSources,
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2117
2137
|
const bootloaderSources = installSources.filter(source => source.kind === 'bootloader');
|
|
2118
2138
|
if (bootloaderSources.length > 0) {
|
|
2119
2139
|
phases.push(
|
|
@@ -2129,11 +2149,11 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2129
2149
|
}
|
|
2130
2150
|
);
|
|
2131
2151
|
}
|
|
2132
|
-
if (
|
|
2152
|
+
if (remainingResourceSources.length > 0) {
|
|
2133
2153
|
phases.push({
|
|
2134
2154
|
kind: 'resource-sync',
|
|
2135
2155
|
installSources: [],
|
|
2136
|
-
resourceSources,
|
|
2156
|
+
resourceSources: remainingResourceSources,
|
|
2137
2157
|
});
|
|
2138
2158
|
}
|
|
2139
2159
|
const componentSources = installSources.filter(source => source.kind !== 'bootloader');
|
|
@@ -2159,6 +2179,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2159
2179
|
installSources: ProtocolV2InstallSource[];
|
|
2160
2180
|
resourceSources: ProtocolV2ResourceBundleSource[];
|
|
2161
2181
|
}) {
|
|
2182
|
+
this.protocolV2BootResourceStagingSafe = false;
|
|
2162
2183
|
const phases = this.buildProtocolV2ExecutionPhases({
|
|
2163
2184
|
installSources,
|
|
2164
2185
|
resourceSources,
|
|
@@ -2169,9 +2190,17 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2169
2190
|
}
|
|
2170
2191
|
if (phase.kind === 'resource-sync') {
|
|
2171
2192
|
await this.enterProtocolV2BootloaderMode();
|
|
2193
|
+
if (
|
|
2194
|
+
!phase.resourceSources.some(source =>
|
|
2195
|
+
isProtocolV2BootResourcePackagePath(source.devicePath)
|
|
2196
|
+
)
|
|
2197
|
+
) {
|
|
2198
|
+
await this.ensureProtocolV2BootResourceStagingIsEmpty();
|
|
2199
|
+
}
|
|
2172
2200
|
await this.executeProtocolV2TransferPhase(phase);
|
|
2173
2201
|
} else if (phase.kind === 'bootloader-install' || phase.kind === 'component-install') {
|
|
2174
2202
|
await this.enterProtocolV2BootloaderMode();
|
|
2203
|
+
await this.ensureProtocolV2BootResourceStagingIsEmpty();
|
|
2175
2204
|
await this.executeProtocolV2TransferPhase(phase);
|
|
2176
2205
|
await this.exitProtocolV2BootloaderToNormal();
|
|
2177
2206
|
} else if (phase.kind === 'bootloader-verify') {
|
|
@@ -2185,6 +2214,35 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2185
2214
|
);
|
|
2186
2215
|
}
|
|
2187
2216
|
|
|
2217
|
+
private async ensureProtocolV2BootResourceStagingIsEmpty() {
|
|
2218
|
+
if (this.protocolV2BootResourceStagingSafe) return;
|
|
2219
|
+
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
2220
|
+
const query = () =>
|
|
2221
|
+
typedCall('FilesystemPathInfoQuery', 'FilesystemPathInfo', {
|
|
2222
|
+
path: PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH,
|
|
2223
|
+
});
|
|
2224
|
+
const current = await query();
|
|
2225
|
+
if (current.message?.exist) {
|
|
2226
|
+
if (current.message.directory) {
|
|
2227
|
+
throw ERRORS.TypedError(
|
|
2228
|
+
HardwareErrorCode.EmmcFileWriteFirmwareError,
|
|
2229
|
+
'Protocol V2 boot resource staging path is not a file'
|
|
2230
|
+
);
|
|
2231
|
+
}
|
|
2232
|
+
await typedCall('FilesystemFileDelete', 'Success', {
|
|
2233
|
+
path: PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH,
|
|
2234
|
+
});
|
|
2235
|
+
const remaining = await query();
|
|
2236
|
+
if (remaining.message?.exist) {
|
|
2237
|
+
throw ERRORS.TypedError(
|
|
2238
|
+
HardwareErrorCode.EmmcFileWriteFirmwareError,
|
|
2239
|
+
'Protocol V2 stale boot resource staging file could not be removed'
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
this.protocolV2BootResourceStagingSafe = true;
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2188
2246
|
private async executeProtocolV2SourceUpdate({
|
|
2189
2247
|
installSources,
|
|
2190
2248
|
resourceSources,
|
|
@@ -2238,7 +2296,11 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2238
2296
|
let totalSize = installSources.reduce((total, item) => total + item.source.size, 0);
|
|
2239
2297
|
const resourcesToSync: ProtocolV2ResourceBundleSource[] = [];
|
|
2240
2298
|
for (const resource of resourceSources) {
|
|
2241
|
-
|
|
2299
|
+
// Early boot promotes this mounted package's staging file. Always replace any
|
|
2300
|
+
// stale staging bytes with the artifact approved by the current PreparedPlan,
|
|
2301
|
+
// even when the mounted final file itself is already current.
|
|
2302
|
+
const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
|
|
2303
|
+
if (!requiresFreshStaging && (await this.isProtocolV2ResourceBundleUpToDate(resource))) {
|
|
2242
2304
|
Log.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
2243
2305
|
} else {
|
|
2244
2306
|
resourcesToSync.push(resource);
|
|
@@ -2259,6 +2321,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2259
2321
|
totalSize,
|
|
2260
2322
|
});
|
|
2261
2323
|
await this.verifyProtocolV2StagedFile(writePath, resource.source.size);
|
|
2324
|
+
if (isProtocolV2BootResourcePackagePath(resource.devicePath)) {
|
|
2325
|
+
this.protocolV2BootResourceStagingSafe = true;
|
|
2326
|
+
}
|
|
2262
2327
|
}
|
|
2263
2328
|
|
|
2264
2329
|
const stagedInstallTargets: Array<{ targetId: number; path: string }> = [];
|