scripts: sd_fusing: Write bootcode before calling 'udevadm settle' 80/315480/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 1 Aug 2024 10:26:08 +0000 (12:26 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 2 Aug 2024 03:06:22 +0000 (03:06 +0000)
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 <m.szyprowski@samsung.com>
Change-Id: Iaab903a31b3ff97de3195f02b5220f26b246a832

scripts/tizen/sd_fusing.py

index c776a3c605cdde1e6bd9bf71634b360ab2d7ef9a..2954838c632cfdc3566750a8bbcf67ef928e72b1 100755 (executable)
@@ -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: