Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bricks/_common/arm_none_eabi.mk
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ UBOOT_FILE = $(PBTOP)/bricks/ev3/u-boot.bin
MAKE_BOOTABLE_IMAGE = $(PBTOP)/bricks/ev3/make_bootable_image.py
# For EV3, merge firmware blob with u-boot to create a bootable image.
$(BUILD)/firmware-base.bin: $(BUILD)/uImage
python $(MAKE_BOOTABLE_IMAGE) $(UBOOT_FILE) $(BUILD)/uImage $(BUILD)/firmware-base.bin
$(Q)$(MAKE_BOOTABLE_IMAGE) $(UBOOT_FILE) $(BUILD)/uImage $(BUILD)/firmware-base.bin
else
# For embeded systems, the firmware is just the base file.
$(BUILD)/firmware-base.bin: $(BUILD)/firmware-obj.bin
Expand Down
16 changes: 12 additions & 4 deletions bricks/ev3/make_bootable_image.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT

import argparse
import sys

# Expected layout of the firmware image:
#
Expand All @@ -18,14 +22,18 @@
FIRMWARE_ROUND_SIZE = 256 * 1024


def make_firmware(uboot_blob, uimage_blob):
def make_firmware(uboot_blob: bytes, uimage_blob: bytes) -> bytes:

if len(uboot_blob) > UBOOT_MAX_SIZE:
print("u-boot file is bigger than expected. Using only the first 256KiB.")
uboot_blob = uboot_blob[:UBOOT_MAX_SIZE]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was initially used to use the original LEGO firmware as a source to extract u-boot. But if we have a proper u-boot now, we should indeed no longer need it.

print(
f"u-boot file is bigger than 256KiB ({len(uboot_blob)} bytes), it is not safe to use.",
file=sys.stderr,
)
exit(1)

if len(uimage_blob) > UIMAGE_MAX_SIZE:
raise ValueError("uImage file is too big.")
print(f"uImage file is too big ({len(uimage_blob)} > {UIMAGE_MAX_SIZE}).", file=sys.stderr)
exit(1)

# Gets combined size, rounded to nearest expected size.
combined_size = UIMAGE_OFFSET + len(uimage_blob)
Expand Down