Skip to content

Commit 4469e17

Browse files
committed
firmware/sagas: add check for new SPIKE Prime bootloader version
1 parent 8db1a27 commit 4469e17

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
// Copyright (c) 2025-2026 The Pybricks Authors
3+
4+
import { Intent } from '@blueprintjs/core';
5+
import { Error } from '@blueprintjs/icons';
6+
import React from 'react';
7+
import type { CreateToast } from '../../toasterTypes';
8+
import { useI18n } from './i18n';
9+
10+
const UnsupportedDfuHub: React.FunctionComponent = () => {
11+
const i18n = useI18n();
12+
return (
13+
<>
14+
<p>{i18n.translate('unsupportedDfuHub.message')}</p>
15+
</>
16+
);
17+
};
18+
19+
export const unsupportedDfuHub: CreateToast = (onAction) => ({
20+
message: <UnsupportedDfuHub />,
21+
icon: <Error />,
22+
intent: Intent.DANGER,
23+
onDismiss: () => onAction('dismiss'),
24+
});

src/firmware/alerts/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2022-2025 The Pybricks Authors
2+
// Copyright (c) 2022-2026 The Pybricks Authors
33

44
import { dfuError } from './DfuError';
55
import { flashProgress } from './FlashProgress';
@@ -8,6 +8,7 @@ import { noDfuInterface } from './NoDfuInterface';
88
import { noWebHid } from './NoWebHid';
99
import { noWebUsb } from './NoWebUsb';
1010
import { releaseButton } from './ReleaseButton';
11+
import { unsupportedDfuHub } from './UnsupportedDfuHub';
1112

1213
export default {
1314
dfuError,
@@ -17,4 +18,5 @@ export default {
1718
noWebHid,
1819
noWebUsb,
1920
releaseButton,
21+
unsupportedDfuHub,
2022
};

src/firmware/alerts/translations/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
"installUsbDriverButton": "Install USB Driver",
2323
"configureUdevRulesButton": "Configure udev rules"
2424
},
25+
"unsupportedDfuHub": {
26+
"message": "This hub has different internal electronics and requires a different firmware. Pybricks does not support this yet. We are working on it!"
27+
},
2528
"noDfuInterface": {
2629
"message": "This is very unusual. The USB device did not contain the expected interface."
2730
},

src/firmware/sagas.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2025 The Pybricks Authors
2+
// Copyright (c) 2020-2026 The Pybricks Authors
33

44
import {
55
FirmwareReader,
@@ -754,6 +754,15 @@ function* handleFlashUsbDfu(action: ReturnType<typeof firmwareFlashUsbDfu>): Gen
754754
return;
755755
}
756756

757+
if (
758+
device.productId === LegoUsbProductId.SpikePrimeBootloader &&
759+
device.deviceVersionMajor !== 1
760+
) {
761+
yield* put(alertsShowAlert('firmware', 'unsupportedDfuHub'));
762+
yield* put(firmwareDidFailToFlashUsbDfu());
763+
return;
764+
}
765+
757766
const dfu = new WebDFU(
758767
device,
759768
// forceInterfacesName is needed to get the flash layout map

0 commit comments

Comments
 (0)