fix: ship Pi images with MontaukOS UEFI boot entry

This commit is contained in:
daniel committed 2026-10-26 16:31:25 +01:00
1 parent be84506fdf
commit 8b4a938164
4 files changed
+147 -3

No files matched your search

+19
View File
@@ -26,6 +26,9 @@
# if it differs, and the UEFI firmware
# RPI_EFI.fd (which holds the firmware's own
# settings) is only replaced with --firmware.
# That also copies the image's MBR disk ID to
# the card: the new RPI_EFI.fd's MontaukOS
# boot entry finds the ESP by it.
# root (ext2, MONTAUKROOT)
# os/, apps/, sdk/, boot/ and any other system
# directory: new and changed files written.
@@ -644,6 +647,20 @@ def expand_root(rep, name):
# ==== Flash ====
def copy_disk_id(rep, name, raw):
"""Give the card the image's MBR disk ID (the firmware's boot entry names the ESP by it)."""
with open(raw, "rb") as f:
disk_id = f.read(512)[440:444]
fd = os.open(f"/dev/{name}", os.O_RDWR | os.O_EXCL | os.O_CLOEXEC)
try:
if os.pread(fd, 4, 440) != disk_id:
os.pwrite(fd, disk_id, 440)
os.fsync(fd)
rep.log(f"MBR disk ID set to 0x{struct.unpack('<I', disk_id)[0]:08x}")
finally:
os.close(fd)
def cmd_flash(rep, args):
img = Image(args.image)
name = check_target(rep, args.device)
@@ -1025,6 +1042,8 @@ def update(rep, args, img, name):
if args.expand:
expand_root(rep, name)
esp, root, _ = card_layout(rep, name)
if args.firmware:
copy_disk_id(rep, name, raw)
with contextlib.ExitStack() as stack:
rep.stage("Mounting")