image: improve uImage.FIT device tree overlay support
authorDaniel Golle <daniel@makrotopia.org>
Sun, 4 Jun 2023 14:57:25 +0000 (15:57 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 5 Jun 2023 10:36:32 +0000 (11:36 +0100)
Instead of generating full config nodes incl. kernel, generate minimal
config nodes for device tree overlays to be applied to the main config.
In this way, multiple device tree overlays can be applied more easily.
While at it change filenames to upstream style, ie. use dtso and dtbo
suffix for device tree overlays.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
include/image-commands.mk
include/image.mk
scripts/mkits.sh

index ea602662a5b3c2e7627612089500c1fe28ee2201..1d694850195457f826a975044a43a2674d6c1af2 100644 (file)
@@ -307,7 +307,7 @@ define Build/fit
                $(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \
                $(if $(DEVICE_DTS_DELIMITER),-l $(DEVICE_DTS_DELIMITER)) \
                $(if $(DEVICE_DTS_LOADADDR),-s $(DEVICE_DTS_LOADADDR)) \
-               $(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtb)) \
+               $(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtbo)) \
                -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \
                -A $(LINUX_KARCH) -v $(LINUX_VERSION)
        PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\
index 0eae216ded20f3e8fcd876819a4c96751ac4c292..0cf110df9319c3a84ced0624071c328cee34d367 100644 (file)
@@ -554,16 +554,33 @@ define Device/Build/dtb
   image_prepare: $(KDIR)/image-$(1).dtb
   endif
 
+endef
+
+define Device/Build/dtbo
+  ifndef BUILD_DTS_$(1)
+  BUILD_DTS_$(1) := 1
+  $(KDIR)/image-$(1).dtbo: FORCE
+       $(call Image/BuildDTB,$(strip $(2))/$(strip $(3)).dtso,$$@)
+
+  image_prepare: $(KDIR)/image-$(1).dtbo
+  endif
+
 endef
 endif
 
 define Device/Build/kernel
-  $$(eval $$(foreach dts,$$(DEVICE_DTS) $$(DEVICE_DTS_OVERLAY), \
+  $$(eval $$(foreach dts,$$(DEVICE_DTS), \
        $$(call Device/Build/dtb,$$(notdir $$(dts)), \
                $$(if $$(DEVICE_DTS_DIR),$$(DEVICE_DTS_DIR),$$(DTS_DIR)), \
                $$(dts) \
        ) \
   ))
+  $$(eval $$(foreach dtso,$$(DEVICE_DTS_OVERLAY), \
+       $$(call Device/Build/dtbo,$$(notdir $$(dtso)), \
+               $$(if $$(DEVICE_DTS_DIR),$$(DEVICE_DTS_DIR),$$(DTS_DIR)), \
+               $$(dtso) \
+       ) \
+  ))
 
   $(KDIR)/$$(KERNEL_NAME):: image_prepare
   $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
index bf75d69f09cc09008b5f6099863b6dd54ebd545f..b1c6f98867471101ab7fa65ac7b1c7961137c2d7 100755 (executable)
@@ -191,13 +191,10 @@ OVCONFIGS=""
 "
        OVCONFIGS="$OVCONFIGS
 
-               config-$ovname {
-                       description = \"OpenWrt ${DEVICE} with $ovname\";
-                       kernel = \"kernel${REFERENCE_CHAR}1\";
-                       fdt = \"fdt${REFERENCE_CHAR}$FDTNUM\", \"$ovnode\";
-                       ${LOADABLES:+loadables = ${LOADABLES};}
+               $ovname {
+                       description = \"OpenWrt ${DEVICE} overlay $ovname\";
+                       fdt = \"$ovnode\";
                        ${COMPATIBLE_PROP}
-                       ${INITRD_PROP}
                };
        "
 done