mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Riesch <michael.riesch@wolfvision.net>
To: ptxdist@pengutronix.de
Cc: christian.melki@t2data.com, m.tretter@pengutronix.de,
	Michael Riesch <michael.riesch@wolfvision.net>
Subject: [ptxdist] [PATCH v2 1/2] ptxd_make_world_{dtb, dtbo}: add support for device tree overlays
Date: Thu,  9 Dec 2021 12:02:57 +0100	[thread overview]
Message-ID: <20211209110258.3307503-2-michael.riesch@wolfvision.net> (raw)
In-Reply-To: <20211209110258.3307503-1-michael.riesch@wolfvision.net>

Make ptxd_make_dtb more general and provide suitable wrappers to
support the generation of device tree overlays.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
---
 rules/post/ptxd_make_world_dtbo.make | 21 ++++++++
 scripts/lib/ptxd_make_world_dtb.sh   | 79 ++++++++++++++++++++--------
 2 files changed, 78 insertions(+), 22 deletions(-)
 create mode 100644 rules/post/ptxd_make_world_dtbo.make

diff --git a/rules/post/ptxd_make_world_dtbo.make b/rules/post/ptxd_make_world_dtbo.make
new file mode 100644
index 000000000..61babc653
--- /dev/null
+++ b/rules/post/ptxd_make_world_dtbo.make
@@ -0,0 +1,21 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2020 by Michael Tretter <m.tretter@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+world/dtbo/env = \
+	$(call world/env, $(1)) \
+	pkg_dtso_path="$($(1)_DTSO_PATH)" \
+	pkg_dtso="$($(1)_DTSO)" \
+	pkg_dtbo_dir="$($(1)_DTBO_DIR)" \
+	pkg_kernel_src="$($(1)_KERNEL_DIR)" \
+	pkg_arch="$(GENERIC_KERNEL_ARCH)"
+
+world/dtbo = \
+	$(call world/dtbo/env,$(strip $(1))) \
+	ptxd_make_world_dtbo
+
+# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_world_dtb.sh b/scripts/lib/ptxd_make_world_dtb.sh
index f5e796b9d..f78d2f885 100644
--- a/scripts/lib/ptxd_make_world_dtb.sh
+++ b/scripts/lib/ptxd_make_world_dtb.sh
@@ -7,24 +7,22 @@
 #
 
 ptxd_make_dtb() {
-    local dtc dts tmp_dts dtb deps tmp_deps
+    local dtc dts tmp_dts dtb dtb_extra_args dtb_kernel_dir deps tmp_deps
 
-    if [[ "${dts_dts}" =~ ^/.* ]]; then
-	ptxd_bailout "'${dts_dts}' must not be an absolute path!" \
-	    "Use <PKG>_DTS_PATH to specify the search path."
-    fi
+    dts="${dtb_source}"
+    dtb="${dtb_target}"
 
-    if ! ptxd_in_path pkg_dts_path "${dts_dts}"; then
-	ptxd_bailout "Device-tree '${dts_dts}' not found in '${pkg_dts_path}'."
-    fi
-    dts="${ptxd_reply}"
-    dtb="${dtb_dir}/$(basename ${dts/%.dts/.dtb})"
+    dtb_kernel_dir="${pkg_kernel_src:-${pkg_dir}}"
 
-    dtc="${pkg_build_dir}/scripts/dtc/dtc"
+    dtc="${dtb_kernel_dir}/scripts/dtc/dtc"
     if [ ! -x "${dtc}" ]; then
 	dtc=dtc
     fi
 
+    if [ "$(ptxd_get_ptxconf PTXCONF_KERNEL_DTS_SUPPORT_OVERLAYS)" == "y" ]; then
+	dtb_extra_args="-@"
+    fi
+
     tmp_dts="${ptx_state_dir}/${pkg_label}.$(basename "${dts}").tmp"
 
     deps="${ptx_state_dir}/${pkg_label}.$(basename "${dts}").deps"
@@ -39,16 +37,16 @@ ptxd_make_dtb() {
 	-Wp,-MT,${dtb_deps_target} \
 	-nostdinc \
 	-I"$(dirname "${dts}")" \
-	-I${pkg_dir}/arch/${pkg_arch}/boot/dts \
-	-I${pkg_dir}/arch/${pkg_arch}/boot/dts/include \
-	-I${pkg_dir}/scripts/dtc/include-prefixes \
-	-I${pkg_dir}/drivers/of/testcase-data \
-	-I${pkg_dir}/include \
+	-I${dtb_kernel_dir}/arch/${pkg_arch}/boot/dts \
+	-I${dtb_kernel_dir}/arch/${pkg_arch}/boot/dts/include \
+	-I${dtb_kernel_dir}/scripts/dtc/include-prefixes \
+	-I${dtb_kernel_dir}/drivers/of/testcase-data \
+	-I${dtb_kernel_dir}/include \
 	-undef -D__DTS__ -x assembler-with-cpp \
 	-o ${tmp_dts} \
 	${dts} &&
 
-    sed -e "\;^ ${pkg_dir}[^ ]*;d" \
+    sed -e "\;^ ${dtb_kernel_dir}[^ ]*;d" \
 	-e 's;^ \([^ \]*\); $(wildcard \1);' "${tmp_deps}" > "${deps}" &&
     # empty line in case all dependencies were removed
     echo >> "${deps}" &&
@@ -57,9 +55,9 @@ ptxd_make_dtb() {
     echo "DTC $(ptxd_print_path "${dtb}")" &&
     ptxd_eval \
 	"${dtc}" \
-	$(ptxd_get_ptxconf PTXCONF_DTC_EXTRA_ARGS) \
+	"${dtb_extra_args}" \
 	-i "$(dirname "${dts}")" \
-	-i "${pkg_dir}/arch/${pkg_arch}/boot/dts" \
+	-i "${dtb_kernel_dir}/arch/${pkg_arch}/boot/dts" \
 	-d "${tmp_deps}" \
 	-I dts -O dtb -b 0 \
 	-o "${dtb}" "${tmp_dts}" &&
@@ -81,17 +79,54 @@ ptxd_make_dtb() {
 export -f ptxd_make_dtb
 
 
+ptxd_make_world_dtbo() {
+    local dtb_deps_target dtb_source dtb_target
+
+    ptxd_make_world_init || break
+
+    dtb_deps_target="${ptx_state_dir}/${pkg_stamp}"
+
+    echo -e "\nBuilding device tree overlays..."
+
+    for overlay in ${pkg_dtso}; do
+	if [[ "${overlay}" =~ ^/.* ]]; then
+	    ptxd_bailout "'${overlay}' must not be an absolute path!" \
+			 "Use <PKG>_DTSO_PATH to specify the search path."
+	fi
+
+	if ! ptxd_in_path pkg_dtso_path "${overlay}"; then
+	    ptxd_bailout "Overlay '${overlay}' not found in '${pkg_dtso_path}'."
+	fi
+	dtb_source="${ptxd_reply}"
+	dtb_target="${pkg_pkg_dir}/${pkg_dtbo_dir}/$(basename ${overlay/%.dts*/.dtbo})"
+
+	ptxd_make_dtb || break
+    done
+}
+export -f ptxd_make_world_dtbo
+
+
 ptxd_make_world_dtb() {
-    local dtb_deps_target dtb_dir
+    local dtb_deps_target dtb_source dtb_target
 
     ptxd_make_world_init || break
 
     dtb_deps_target="${ptx_state_dir}/${pkg_stamp}"
-    dtb_dir="${pkg_pkg_dir}/boot"
 
-    echo -e "\nBuilding Device trees..."
+    echo -e "\nBuilding device trees..."
 
     for dts_dts in ${pkg_dts}; do
+	if [[ "${dts_dts}" =~ ^/.* ]]; then
+	    ptxd_bailout "'${dts_dts}' must not be an absolute path!" \
+			 "Use <PKG>_DTS_PATH to specify the search path."
+	fi
+
+	if ! ptxd_in_path pkg_dts_path "${dts_dts}"; then
+	    ptxd_bailout "Device tree '${dts_dts}' not found in '${pkg_dts_path}'."
+	fi
+	dtb_source="${ptxd_reply}"
+	dtb_target="${pkg_pkg_dir}/boot/$(basename ${dts_dts/%.dts/.dtb})"
+
 	ptxd_make_dtb || break
     done
 }
-- 
2.30.2


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de


  reply	other threads:[~2021-12-09 11:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 11:02 [ptxdist] [PATCH v2 0/2] Add " Michael Riesch
2021-12-09 11:02 ` Michael Riesch [this message]
2021-12-10 13:07   ` [ptxdist] [APPLIED] ptxd_make_world_{dtb, dtbo}: add " Michael Olbrich
2021-12-09 11:02 ` [ptxdist] [PATCH v2 2/2] kernel: activate " Michael Riesch
2021-12-10 13:07   ` [ptxdist] [APPLIED] " Michael Olbrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211209110258.3307503-2-michael.riesch@wolfvision.net \
    --to=michael.riesch@wolfvision.net \
    --cc=christian.melki@t2data.com \
    --cc=m.tretter@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox