mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
Update firmware to v3.0.0a11
Also take advantage of new helper functions in firmware package.
This commit is contained in:
committed by
David Lechner
parent
71ad9c1b1b
commit
4ee50072a0
+1
-2
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@blueprintjs/core": "^3.30.1",
|
||||
"@pybricks/firmware": "3.1.0",
|
||||
"@pybricks/firmware": "4.1.0",
|
||||
"@pybricks/mpy-cross-v5": "^1.1.0",
|
||||
"@shopify/react-i18n": "^5.0.0",
|
||||
"@testing-library/jest-dom": "^5.8.0",
|
||||
@@ -22,7 +22,6 @@
|
||||
"@types/zen-push": "^0.1.1",
|
||||
"ace-builds": "^1.4.11",
|
||||
"file-saver": "^2.0.2",
|
||||
"jszip": "^3.5.0",
|
||||
"node-sass": "^4.14.1",
|
||||
"react": "^16.13.1",
|
||||
"react-ace": "^9.1.3",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2020 The Pybricks Authors
|
||||
|
||||
import { FirmwareMetadata, FirmwareReader, HubType } from '@pybricks/firmware';
|
||||
import cityHubZip from '@pybricks/firmware/build/cityhub.zip';
|
||||
import moveHubZip from '@pybricks/firmware/build/movehub.zip';
|
||||
import technicHubZip from '@pybricks/firmware/build/technichub.zip';
|
||||
import JSZip from 'jszip';
|
||||
import {
|
||||
Effect,
|
||||
all,
|
||||
@@ -58,7 +58,7 @@ import {
|
||||
compile,
|
||||
} from '../actions/mpy';
|
||||
import * as notification from '../actions/notification';
|
||||
import { HubType, MaxProgramFlashSize } from '../protocols/lwp3-bootloader';
|
||||
import { MaxProgramFlashSize } from '../protocols/lwp3-bootloader';
|
||||
import { fmod, sumComplement32 } from '../utils/math';
|
||||
|
||||
const firmwareZipMap = new Map<HubType, string>([
|
||||
@@ -98,17 +98,6 @@ function waitForResponse(type: BootloaderResponseActionType, timeout = 500): Eff
|
||||
return race([take(type), take(BootloaderResponseActionType.Error), delay(timeout)]);
|
||||
}
|
||||
|
||||
interface FirmwareMetadata {
|
||||
'metadata-version': string;
|
||||
'firmware-version': string;
|
||||
'device-id': HubType;
|
||||
'checksum-type': 'sum' | 'crc32';
|
||||
'mpy-abi-version': number;
|
||||
'mpy-cross-options': string[];
|
||||
'user-mpy-offset': number;
|
||||
'max-firmware-size': number;
|
||||
}
|
||||
|
||||
function* firmwareIterator(data: DataView, maxSize: number): Generator<number> {
|
||||
// read each 32-bit word of the firmware
|
||||
for (let i = 0; i < data.byteLength; i += 4) {
|
||||
@@ -127,29 +116,11 @@ function* firmwareIterator(data: DataView, maxSize: number): Generator<number> {
|
||||
function* loadFirmware(
|
||||
data: ArrayBuffer,
|
||||
): Generator<unknown, { firmware: Uint8Array; deviceId: HubType }> {
|
||||
const zip = (yield call(() => JSZip.loadAsync(data))) as JSZip;
|
||||
const reader = (yield call(() => FirmwareReader.load(data))) as FirmwareReader;
|
||||
|
||||
const firmwareBaseFile = zip.file('firmware-base.bin');
|
||||
if (firmwareBaseFile === null) {
|
||||
throw Error('Missing firmware-base.bin');
|
||||
}
|
||||
const firmwareBase = (yield call(() =>
|
||||
firmwareBaseFile.async('uint8array'),
|
||||
)) as Uint8Array;
|
||||
|
||||
const metadataFile = zip.file('firmware.metadata.json');
|
||||
if (metadataFile === null) {
|
||||
throw Error('Missing firmware.metadata.json');
|
||||
}
|
||||
const metadata = JSON.parse(
|
||||
(yield call(() => metadataFile.async('text'))) as string,
|
||||
) as FirmwareMetadata;
|
||||
|
||||
const mainFile = zip.file('main.py');
|
||||
if (mainFile === null) {
|
||||
throw Error('Missing main.py');
|
||||
}
|
||||
const main = (yield call(() => mainFile.async('text'))) as string;
|
||||
const firmwareBase = (yield call(() => reader.readFirmwareBase())) as Uint8Array;
|
||||
const metadata = (yield call(() => reader.readMetadata())) as FirmwareMetadata;
|
||||
const main = (yield call(() => reader.readMainPy())) as string;
|
||||
|
||||
if (metadata['mpy-abi-version'] !== 5) {
|
||||
throw Error(
|
||||
|
||||
@@ -1458,10 +1458,12 @@
|
||||
schema-utils "^2.6.5"
|
||||
source-map "^0.7.3"
|
||||
|
||||
"@pybricks/firmware@3.1.0":
|
||||
version "3.1.0"
|
||||
resolved "https://npm.pkg.github.com/download/@pybricks/firmware/3.1.0/9b3abdac044428108bed6d1acf1fe2e95266181026b8e28a3e4ffc8a5f4fa2e2#35abf937a7dc2d88cc73857da363a298a17453c6"
|
||||
integrity sha512-aST/+8KZtejAhy2t/oGG16QaajT8RziHUDy3Li67dlIRuYA43xlKcTbTJAegCGJm3rpXlkcCEms5+yxP5+Krag==
|
||||
"@pybricks/firmware@4.1.0":
|
||||
version "4.1.0"
|
||||
resolved "https://npm.pkg.github.com/download/@pybricks/firmware/4.1.0/a4c0914750afa8aee656dd3a771b22e4da75607f0201ded148fb6bbf3f017ed1#3deb1772c469c48944c4fc022f7322b0fb3102f9"
|
||||
integrity sha512-aQ46+X86J7GHqO2wwgq02lDhvV4WZJWGOrfuOZJfH3ss4bdErhBJaIwZ7zjVxI2DrWlrbMwjGEA6H/b9NholFQ==
|
||||
dependencies:
|
||||
jszip "^3.5.0"
|
||||
|
||||
"@pybricks/mpy-cross-v5@^1.1.0":
|
||||
version "1.1.0"
|
||||
|
||||
Reference in New Issue
Block a user