diff mbox series

[RFC,09/13] kbuild: add support for generating FIT images

Message ID 1523956215-28154-10-git-send-email-t-kristo@ti.com
State New
Headers show
Series ARM: dts: DT overlay support infra + some data | expand

Commit Message

Tero Kristo April 17, 2018, 9:10 a.m. UTC
FIT images are built with the mkimage tool, from source description
similar to that of DT files. There are a few FIT image generation
specifics that must be noted with this patch.

The dependency generation for the FIT files requires some makefile
magic, due to the build ordering; the dependency binaries must have
been built before the FIT image itself, which is different from typical
kernel build flow (source files are be built immediately and dependencies
can be generated during build.) To use the generated dependency files,
the user must manually include the local .itb-deps.d file in their makefile.

The PATH environment variable while calling the mkimage tool is tweaked
to contain the local / user provided DTC as first item, so that the
correct version of mkimage tool will be used. Otherwise, the build will
use the system default DTC, or won't find the tool at all.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

---
 scripts/Makefile.lib | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

-- 
1.9.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 95f7a17..18517ea 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -295,6 +295,38 @@  $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
 
+# FIT
+# ---------------------------------------------------------------------------
+define gen_itb_deps
+	@if [ -d $(obj) ] ; then \
+		echo >> $(obj)/.itb-deps.d ; \
+		echo "$(src)/$(patsubst %.its,%.itb,$(notdir $(1))): $(srctree)/$(src)/$(notdir $(1)) \\" >> $(obj)/.itb-deps.d ; \
+		cat $(1) | grep incbin | cut -d "\"" -f 2 | awk '{ printf " $(src)/%s \\\n", $$1 }' | sed '$$s/ \\$$//' >> $(obj)/.itb-deps.d ; \
+	fi
+
+endef
+
+$(obj)/.itb-deps.d:
+	@if [ -d $(obj) ] ; then \
+		echo "$(src)/.itb-deps.d: $(src)/Makefile $(wildcard $(srctree)/$(src)/*.its)" > $(obj)/.itb-deps.d ; \
+		echo >> $(obj)/.itb-deps.d ; \
+	fi
+	$(foreach f,$(wildcard $(srctree)/$(src)/*.its),$(call gen_itb_deps,$f))
+
+DTC_FLAGS_MKIMAGE = -I dts -O dtb -p 500 -Wno-unit_address_vs_reg \
+	-i $(src)
+ifneq ($(DTC),)
+  DTC_PATH=$(dir $(DTC))
+else
+  DTC_PATH=$(objtree)/scripts/dtc
+endif
+
+quiet_cmd_mkdir = MKIMAGE -f $@
+cmd_mkfit = PATH="$(DTC_PATH):$(PATH)" $(MKIMAGE) -D "$(DTC_FLAGS_MKIMAGE)" -f $< $@
+
+$(obj)/%.itb: $(src)/%.its FORCE
+	$(call cmd,mkfit)
+
 # Bzip2
 # ---------------------------------------------------------------------------