diff mbox series

[1/3] uki.bbclass: skip overlays and select between several devicetrees

Message ID 20261129223704.2168814-1-ricardo.salveti@oss.qualcomm.com
State New
Headers show
Series [1/3] uki.bbclass: skip overlays and select between several devicetrees | expand

Commit Message

Ricardo Salveti Nov. 29, 2026, 10:37 p.m. UTC
Every UKI_DEVICETREE entry is passed to ukify as its own --devicetree,
but that option takes a single file, so only the last entry ends up in
the UKI. With the KERNEL_DEVICETREE default that is often a .dtbo,
which systemd-stub then installs in place of the firmware devicetree.

Skip .dtbo entries and pass several devicetrees with --devicetree-auto,
so that systemd-stub (257 or later) installs the one whose first
"compatible" matches the firmware devicetree, or the device found
through .hwids when the firmware has none. When nothing matches, it
installs the DeviceTree= of UKI_CONFIG_FILE if set, which now applies,
and otherwise keeps the firmware devicetree, or none if the firmware
has none. A single devicetree is still always installed, so list one
to force it.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>
---
 meta/classes-recipe/uki.bbclass | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/uki.bbclass b/meta/classes-recipe/uki.bbclass
index bcccf824c7..ea8aaa5e6b 100644
--- a/meta/classes-recipe/uki.bbclass
+++ b/meta/classes-recipe/uki.bbclass
@@ -151,16 +151,18 @@  python do_uki() {
     if cmdline:
         ukify_cmd += " --cmdline='%s'" % (cmdline)
 
-    # dtb
-    uki_devicetree = d.getVar('UKI_DEVICETREE')
-    if uki_devicetree:
-        for dtb in uki_devicetree.split():
-            # DTBs are without sub-directories in deploy_dir
-            dtb_name = os.path.basename(dtb)
-            dtb_path = "%s/%s" % (deploy_dir_image, dtb_name)
-            if not os.path.exists(dtb_path):
-                bb.fatal(f"ERROR: cannot find {dtb_path}.")
-            ukify_cmd += " --devicetree %s" % (dtb_path)
+    # dtb, overlays cannot be used as the base devicetree. With several dtbs,
+    # systemd-stub picks the first one matching the firmware's "compatible".
+    uki_devicetree = [dtb for dtb in (d.getVar('UKI_DEVICETREE') or "").split()
+                      if not dtb.endswith('.dtbo')]
+    dtb_option = "--devicetree" if len(uki_devicetree) == 1 else "--devicetree-auto"
+    for dtb in uki_devicetree:
+        # DTBs are without sub-directories in deploy_dir
+        dtb_name = os.path.basename(dtb)
+        dtb_path = "%s/%s" % (deploy_dir_image, dtb_name)
+        if not os.path.exists(dtb_path):
+            bb.fatal(f"ERROR: cannot find {dtb_path}.")
+        ukify_cmd += " %s %s" % (dtb_option, dtb_path)
 
     # custom config for ukify
     if os.path.exists(d.getVar('UKI_CONFIG_FILE')):