* [RFC PATCH v2 1/4] scripts: Add script to generate dtb build information
2020-02-21 16:12 [RFC PATCH v2 0/4] Alexandre Torgue
@ 2020-02-21 16:12 ` Alexandre Torgue
2020-02-24 17:45 ` Masahiro Yamada
2020-02-21 16:12 ` [RFC PATCH v2 2/4] of: fdt: print " Alexandre Torgue
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Alexandre Torgue @ 2020-02-21 16:12 UTC (permalink / raw)
To: robh+dt, Frank Rowand, Masahiro Yamada, Michal Marek, david, sjg
Cc: devicetree, Alexandre Torgue, linux-kernel, linux-kbuild,
devicetree-compiler, Ian Lepore
This commit adds a new script to create a file (in dts file directory) with
some information (date, Linux version, user). This file could then be used
to populate "build-info" property in every dts file that would use this
build information:
Example:
/ {
...
build-info = /incbin/("dtb-build.txt");
...
};
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index bae62549e3d2..a5af84ef4ffc 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -246,6 +246,7 @@ quiet_cmd_gzip = GZIP $@
# DTC
# ---------------------------------------------------------------------------
DTC ?= $(objtree)/scripts/dtc/dtc
+DTB_GEN_INFO ?= $(objtree)/scripts/gen_dtb_build_info.sh
# Disable noisy checks by default
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
@@ -286,6 +287,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
quiet_cmd_dtc = DTC $@
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
+ $(DTB_GEN_INFO) $(src) ; \
$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
$(DTC) -O $(2) -o $@ -b 0 \
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
diff --git a/scripts/gen_dtb_build_info.sh b/scripts/gen_dtb_build_info.sh
new file mode 100755
index 000000000000..0cd8bd98e410
--- /dev/null
+++ b/scripts/gen_dtb_build_info.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+set -o nounset
+
+DTB_DIR=$1
+DTB_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
+DTB_INFO="From Linux $KERNELRELEASE by $DTB_COMPILE_BY the $(date).\0"
+
+printf "$DTB_INFO" > "$DTB_DIR/dtb-build.txt"
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC PATCH v2 1/4] scripts: Add script to generate dtb build information
2020-02-21 16:12 ` [RFC PATCH v2 1/4] scripts: Add script to generate dtb build information Alexandre Torgue
@ 2020-02-24 17:45 ` Masahiro Yamada
2020-02-26 16:38 ` Frank Rowand
0 siblings, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2020-02-24 17:45 UTC (permalink / raw)
To: Alexandre Torgue
Cc: Rob Herring, Frank Rowand, Michal Marek, David Gibson,
Simon Glass, DTML, Linux Kernel Mailing List,
Linux Kbuild mailing list, Devicetree Compiler, Ian Lepore
Hi.
On Sat, Feb 22, 2020 at 1:12 AM Alexandre Torgue
<alexandre.torgue@st.com> wrote:
>
> This commit adds a new script to create a file (in dts file directory) with
> some information (date, Linux version, user). This file could then be used
> to populate "build-info" property in every dts file that would use this
> build information:
>
> Example:
>
> / {
> ...
> build-info = /incbin/("dtb-build.txt");
> ...
> };
>
> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index bae62549e3d2..a5af84ef4ffc 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -246,6 +246,7 @@ quiet_cmd_gzip = GZIP $@
> # DTC
> # ---------------------------------------------------------------------------
> DTC ?= $(objtree)/scripts/dtc/dtc
> +DTB_GEN_INFO ?= $(objtree)/scripts/gen_dtb_build_info.sh
>
> # Disable noisy checks by default
> ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
> @@ -286,6 +287,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
>
> quiet_cmd_dtc = DTC $@
> cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
> + $(DTB_GEN_INFO) $(src) ; \
> $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
> $(DTC) -O $(2) -o $@ -b 0 \
> $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
> diff --git a/scripts/gen_dtb_build_info.sh b/scripts/gen_dtb_build_info.sh
> new file mode 100755
> index 000000000000..0cd8bd98e410
> --- /dev/null
> +++ b/scripts/gen_dtb_build_info.sh
> @@ -0,0 +1,10 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +set -o nounset
> +
> +DTB_DIR=$1
> +DTB_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
> +DTB_INFO="From Linux $KERNELRELEASE by $DTB_COMPILE_BY the $(date).\0"
> +
> +printf "$DTB_INFO" > "$DTB_DIR/dtb-build.txt"
> --
> 2.17.1
>
There are more than 1000 *.dts files
in arch/arm/boot/dts/.
So, with this patch, the build system will creates
arch/arm/boot/dts/dtb-build.txt 1000 times.
Does it work with parallel build ?
Think about what would happen
with 'make -j32 ARCH=arm dtbs'
The 32 threads will write to
arch/arm/boot/dts/dtb-build.txt
at the same time.
Then, some of DTB would very likely to
include the broken dtb-build.txt
A list of missing parts in this approach:
- make it work with parallel build
- clean it up with 'make clean'
- add it .gitignore (and Documentation/dontdiff)
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH v2 1/4] scripts: Add script to generate dtb build information
2020-02-24 17:45 ` Masahiro Yamada
@ 2020-02-26 16:38 ` Frank Rowand
0 siblings, 0 replies; 7+ messages in thread
From: Frank Rowand @ 2020-02-26 16:38 UTC (permalink / raw)
To: Masahiro Yamada, Alexandre Torgue
Cc: Rob Herring, Michal Marek, David Gibson, Simon Glass, DTML,
Linux Kernel Mailing List, Linux Kbuild mailing list,
Devicetree Compiler, Ian Lepore
Hi Alexandre,
On 2/24/20 11:45 AM, Masahiro Yamada wrote:
> Hi.
>
> On Sat, Feb 22, 2020 at 1:12 AM Alexandre Torgue
> <alexandre.torgue@st.com> wrote:
>>
>> This commit adds a new script to create a file (in dts file directory) with
>> some information (date, Linux version, user). This file could then be used
>> to populate "build-info" property in every dts file that would use this
>> build information:
>>
>> Example:
>>
>> / {
>> ...
>> build-info = /incbin/("dtb-build.txt");
>> ...
>> };
>>
>> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
>>
>> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
>> index bae62549e3d2..a5af84ef4ffc 100644
>> --- a/scripts/Makefile.lib
>> +++ b/scripts/Makefile.lib
>> @@ -246,6 +246,7 @@ quiet_cmd_gzip = GZIP $@
>> # DTC
>> # ---------------------------------------------------------------------------
>> DTC ?= $(objtree)/scripts/dtc/dtc
>> +DTB_GEN_INFO ?= $(objtree)/scripts/gen_dtb_build_info.sh
>>
>> # Disable noisy checks by default
>> ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
>> @@ -286,6 +287,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
>>
>> quiet_cmd_dtc = DTC $@
>> cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
>> + $(DTB_GEN_INFO) $(src) ; \
>> $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
>> $(DTC) -O $(2) -o $@ -b 0 \
>> $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
>> diff --git a/scripts/gen_dtb_build_info.sh b/scripts/gen_dtb_build_info.sh
>> new file mode 100755
>> index 000000000000..0cd8bd98e410
>> --- /dev/null
>> +++ b/scripts/gen_dtb_build_info.sh
>> @@ -0,0 +1,10 @@
>> +#!/bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +
>> +set -o nounset
>> +
>> +DTB_DIR=$1
>> +DTB_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
>> +DTB_INFO="From Linux $KERNELRELEASE by $DTB_COMPILE_BY the $(date).\0"
>> +
>> +printf "$DTB_INFO" > "$DTB_DIR/dtb-build.txt"
>> --
>> 2.17.1
>>
>
>
> There are more than 1000 *.dts files
> in arch/arm/boot/dts/.
>
> So, with this patch, the build system will creates
> arch/arm/boot/dts/dtb-build.txt 1000 times.
>
>
> Does it work with parallel build ?
>
> Think about what would happen
> with 'make -j32 ARCH=arm dtbs'
>
>
> The 32 threads will write to
> arch/arm/boot/dts/dtb-build.txt
> at the same time.
>
> Then, some of DTB would very likely to
> include the broken dtb-build.txt
>
>
> A list of missing parts in this approach:
>
> - make it work with parallel build
> - clean it up with 'make clean'
> - add it .gitignore (and Documentation/dontdiff)
>
>
>
You might be able to rework script 'version_dtb_increment_once' from my
previous attempt at this concept. I do not know if the build system
has changed since 2015 in a way that would make the script incorrect
or if it is still valid.
https://lore.kernel.org/linux-arm-kernel/550A44A8.9090302@gmail.com/
-Frank
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH v2 2/4] of: fdt: print dtb build information
2020-02-21 16:12 [RFC PATCH v2 0/4] Alexandre Torgue
2020-02-21 16:12 ` [RFC PATCH v2 1/4] scripts: Add script to generate dtb build information Alexandre Torgue
@ 2020-02-21 16:12 ` Alexandre Torgue
2020-02-21 16:12 ` [RFC PATCH v2 3/4] ARM: dts: stm32: Add dtb build information entry for stm32mp157c-dk2 Alexandre Torgue
2020-02-21 16:12 ` [RFC PATCH v2 4/4] script: make automatic dtb build info generation Alexandre Torgue
3 siblings, 0 replies; 7+ messages in thread
From: Alexandre Torgue @ 2020-02-21 16:12 UTC (permalink / raw)
To: robh+dt, Frank Rowand, Masahiro Yamada, Michal Marek, david, sjg
Cc: devicetree, Alexandre Torgue, linux-kernel, linux-kbuild,
devicetree-compiler, Ian Lepore
This commit prints out DTB build information (build time, dts source
version used, ...) if "Build-info" property exists in DTB root node.
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 2cdf64d2456f..aa5989039746 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1224,9 +1224,18 @@ bool __init early_init_dt_scan(void *params)
*/
void __init unflatten_device_tree(void)
{
+ const char *build_info;
+ unsigned long dt_root;
+
__unflatten_device_tree(initial_boot_params, NULL, &of_root,
early_init_dt_alloc_memory_arch, false);
+ /* If available, provide dtb build information */
+ dt_root = of_get_flat_dt_root();
+ build_info = of_get_flat_dt_prop(dt_root, "build-info", NULL);
+ if (build_info)
+ pr_info("%s\n", build_info);
+
/* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
of_alias_scan(early_init_dt_alloc_memory_arch);
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH v2 3/4] ARM: dts: stm32: Add dtb build information entry for stm32mp157c-dk2
2020-02-21 16:12 [RFC PATCH v2 0/4] Alexandre Torgue
2020-02-21 16:12 ` [RFC PATCH v2 1/4] scripts: Add script to generate dtb build information Alexandre Torgue
2020-02-21 16:12 ` [RFC PATCH v2 2/4] of: fdt: print " Alexandre Torgue
@ 2020-02-21 16:12 ` Alexandre Torgue
2020-02-21 16:12 ` [RFC PATCH v2 4/4] script: make automatic dtb build info generation Alexandre Torgue
3 siblings, 0 replies; 7+ messages in thread
From: Alexandre Torgue @ 2020-02-21 16:12 UTC (permalink / raw)
To: robh+dt, Frank Rowand, Masahiro Yamada, Michal Marek, david, sjg
Cc: devicetree, Alexandre Torgue, linux-kernel, linux-kbuild,
devicetree-compiler, Ian Lepore
dtb-build.txt is a file containing device tree build information (date,
source version ...). This file is used to fill "build-info" entry which
will be displayed during kernel boot.
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
diff --git a/arch/arm/boot/dts/stm32mp157c-dk2.dts b/arch/arm/boot/dts/stm32mp157c-dk2.dts
index 7985b80967ca..387d3bcf5fa3 100644
--- a/arch/arm/boot/dts/stm32mp157c-dk2.dts
+++ b/arch/arm/boot/dts/stm32mp157c-dk2.dts
@@ -15,6 +15,7 @@
/ {
model = "STMicroelectronics STM32MP157C-DK2 Discovery Board";
compatible = "st,stm32mp157c-dk2", "st,stm32mp157";
+ build-info = /incbin/("dtb-build.txt");
aliases {
ethernet0 = ðernet0;
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH v2 4/4] script: make automatic dtb build info generation
2020-02-21 16:12 [RFC PATCH v2 0/4] Alexandre Torgue
` (2 preceding siblings ...)
2020-02-21 16:12 ` [RFC PATCH v2 3/4] ARM: dts: stm32: Add dtb build information entry for stm32mp157c-dk2 Alexandre Torgue
@ 2020-02-21 16:12 ` Alexandre Torgue
3 siblings, 0 replies; 7+ messages in thread
From: Alexandre Torgue @ 2020-02-21 16:12 UTC (permalink / raw)
To: robh+dt, Frank Rowand, Masahiro Yamada, Michal Marek, david, sjg
Cc: devicetree, Alexandre Torgue, linux-kernel, linux-kbuild,
devicetree-compiler, Ian Lepore
Append each "xxx.dtb.dts.tmp" file with "build-info" entry during dtb
build. It allows to get build information (date, source version, ...)
for each device tree without modify them manually.
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a5af84ef4ffc..f084e78267b2 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -289,6 +289,7 @@ quiet_cmd_dtc = DTC $@
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
$(DTB_GEN_INFO) $(src) ; \
$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
+ $(DTB_GEN_INFO) $(src) $(dtc-tmp) ; \
$(DTC) -O $(2) -o $@ -b 0 \
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
-d $(depfile).dtc.tmp $(dtc-tmp) ; \
diff --git a/scripts/gen_dtb_build_info.sh b/scripts/gen_dtb_build_info.sh
index 0cd8bd98e410..72f31e386787 100755
--- a/scripts/gen_dtb_build_info.sh
+++ b/scripts/gen_dtb_build_info.sh
@@ -6,5 +6,7 @@ set -o nounset
DTB_DIR=$1
DTB_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
DTB_INFO="From Linux $KERNELRELEASE by $DTB_COMPILE_BY the $(date).\0"
+DTS_FILE=$2
-printf "$DTB_INFO" > "$DTB_DIR/dtb-build.txt"
+printf "$DTB_INFO" > "arch/arm/boot/dts/dtb-build.txt"
+echo "&{/} {build-info = /incbin/(\"dtb-build.txt\");};" >> $DTS_FILE
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread