Skip to content

Commit 73d3cdb

Browse files
committed
flash: Don't customize SPIKE firmwares.
We will be using the firmware.bin file from the ZIP archive without changes.
1 parent 3a89ec3 commit 73d3cdb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pybricksdev/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ async def run(self, args: argparse.Namespace):
227227
print("Creating firmware")
228228
firmware, metadata = await create_firmware(args.firmware, args.name)
229229

230-
if metadata["device-id"] == HubKind.TECHNIC_LARGE:
230+
if metadata["device-id"] in (HubKind.TECHNIC_SMALL, HubKind.TECHNIC_LARGE):
231231
from ..dfu import flash_dfu
232232

233233
flash_dfu(firmware, metadata)

pybricksdev/flash.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ async def create_firmware(
4949
"""
5050

5151
archive = zipfile.ZipFile(firmware_zip)
52+
metadata = json.load(archive.open("firmware.metadata.json"))
53+
54+
# For SPIKE Hubs, we can use the firmware without changes.
55+
if metadata["device-id"] in (HubKind.TECHNIC_SMALL, HubKind.TECHNIC_LARGE):
56+
firmware = bytearray(archive.open("firmware.bin").read())
57+
return firmware, metadata
58+
59+
# For Powered Up hubs, we append a script and checksum to a base firmware.
5260
base = archive.open("firmware-base.bin").read()
5361
main_py = io.TextIOWrapper(archive.open("main.py"))
54-
metadata = json.load(archive.open("firmware.metadata.json"))
5562

5663
mpy = await compile_file(
5764
save_script(main_py.read()),

0 commit comments

Comments
 (0)