From e2811ca760d064970646cae7e4b1533238e6af6c Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 1 Aug 2024 12:26:08 +0200 Subject: [PATCH] scripts: sd_fusing: Write bootcode before calling 'udevadm settle' Writing bootcode to the first sector of the device might trigger kernel or udev to reread partition table, so do this before calling 'udevadm settle' command. Signed-off-by: Marek Szyprowski Change-Id: Iaab903a31b3ff97de3195f02b5220f26b246a832 --- sd_fusing.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sd_fusing.py b/sd_fusing.py index c776a3c..2954838 100755 --- a/sd_fusing.py +++ b/sd_fusing.py @@ -886,6 +886,12 @@ def mkpart(args, target): logging.error(f"New partition table:\n" + str(target.label)) sys.exit(1) + if target.bootcode: + logging.debug("Writing bootcode\n") + with open(Device, "wb") as f: + f.write(target.bootcode) + f.close + # Run `udevadm settle` to ensure that partition change made by `sfdisk` is completely reflected in userspace. logging.info("Waiting for the udev event queue to empty...") argv = ['udevadm', 'settle'] @@ -898,12 +904,6 @@ def mkpart(args, target): else: logging.info("The udev event queue is empty.") - if target.bootcode: - logging.debug("Writing bootcode\n") - with open(Device, "wb") as f: - f.write(target.bootcode) - f.close - for i, part in enumerate(target.part_table): d = "/dev/" + get_partition_device(target.device, i+1) if not 'fstype' in part: -- 2.34.1