mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH v3 1/7] kbuild: Add target to build dtb overlay files
Date: Fri, 10 Mar 2023 10:42:16 +0100	[thread overview]
Message-ID: <20230310094222.2538259-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20230310094222.2538259-1-s.hauer@pengutronix.de>

Device tree overlay files have the suffix dtso in source format
and dtbo in binary format. Add the necessary targets to build dtbo
files from dtso files and also dtbo.o files to include into the
barebox binary.
The overlay files shouldn't include the device tree snippets from
CONFIG_EXTERNAL_DTS_FRAGMENTS which makes it necessary to specify
these fragments as an argument to cmd_dtc.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 scripts/Makefile.build |  2 ++
 scripts/Makefile.lib   | 10 +++++++++-
 scripts/gen-dtbo-s     | 14 ++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100755 scripts/gen-dtbo-s

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 216f03677b..25347eee01 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -258,11 +258,13 @@ intermediate_targets = $(foreach sfx, $(2), \
 					$(filter %$(strip $(1)), $(targets))))
 # %.asn1.o <- %.asn1.[ch] <- %.asn1
 # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
+# %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso
 # %.dtb.pbl.o <- %.dtb.S <- %.dtb <- %.dts (Barebox only)
 # %.lex.o <- %.lex.c <- %.l
 # %.tab.o <- %.tab.[ch] <- %.y
 targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
 	   $(call intermediate_targets, .dtb.o, .dtb.S .dtb.z .dtb) \
+	   $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo.z .dtbo) \
 	   $(call intermediate_targets, .dtb.pbl.o, .dtb.S .dtb.z .dtb) \
 	   $(call intermediate_targets, .lex.o, .lex.c) \
 	   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6e0d92cf75..42c59a072c 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -361,13 +361,18 @@ cmd_dt_S_dtb = $(srctree)/scripts/gen-dtb-s $(subst -,_,$(*F)) $< $(CONFIG_IMD)
 $(obj)/%.dtb.S: $(obj)/%.dtb $(obj)/%.dtb.z $(srctree)/scripts/gen-dtb-s FORCE
 	$(call if_changed,dt_S_dtb)
 
+quiet_cmd_dt_S_dtbo = DTBO    $@
+cmd_dt_S_dtbo = $(srctree)/scripts/gen-dtbo-s $(subst -,_,$(*F)) $< > $@
+$(obj)/%.dtbo.S: $(obj)/%.dtbo $(srctree)/scripts/gen-dtbo-s FORCE
+	$(call if_changed,dt_S_dtbo)
+
 $(obj)/%.dtb.z: $(obj)/%.dtb FORCE
 	$(call if_changed,$(suffix_y))
 
 dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
 # For compatibility between make 4.2 and 4.3
-cmd_dtc = /usr/bin/env echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(pound)include "$(f)"\n') | \
+cmd_dtc = /usr/bin/env echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(2),'$(pound)include "$(f)"\n') | \
 	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
 	$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
 		-i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \
@@ -376,6 +381,9 @@ cmd_dtc = /usr/bin/env echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(fore
 	cat $(depfile).pre $(depfile).dtc > $(depfile)
 
 $(obj)/%.dtb: $(src)/%.dts FORCE
+	$(call if_changed_dep,dtc,$(dts-frags))
+
+$(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
 	$(call if_changed_dep,dtc)
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
diff --git a/scripts/gen-dtbo-s b/scripts/gen-dtbo-s
new file mode 100755
index 0000000000..06f78609ed
--- /dev/null
+++ b/scripts/gen-dtbo-s
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+name=$1
+dtbo=$2
+
+echo "#include <asm/barebox.lds.h>"
+
+echo ".section .dtb.rodata.${name}_dtbo,\"a\""
+echo ".balign STRUCT_ALIGNMENT"
+echo ".global __dtbo_${name}_start"
+echo "__dtbo_${name}_start:"
+echo ".incbin \"$dtbo\""
+echo "__dtbo_${name}_end:"
+echo ".global __dtbo_${name}_end"
-- 
2.30.2




  reply	other threads:[~2023-03-10  9:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  9:42 [PATCH v3 0/7] support overlays to the barebox live tree Sascha Hauer
2023-03-10  9:42 ` Sascha Hauer [this message]
2023-03-10  9:42 ` [PATCH v3 2/7] driver: Add rescan hook to struct device Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 3/7] i2c: implement rescan Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 4/7] spi: Directly register SPI device Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 5/7] spi: reduce scope of 'chip' Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 6/7] spi: implement rescan Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 7/7] of_overlay: Add option to apply overlay to live tree Sascha Hauer
2023-03-14 14:59   ` Michael Riesch
2023-03-14 15:49     ` Sascha Hauer
2023-03-14 16:03       ` Michael Riesch
2023-03-15 16:09 ` [PATCH v3 0/7] support overlays to the barebox " Michael Riesch
2023-03-16  8:58   ` Sascha Hauer

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=20230310094222.2538259-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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