linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: supply a DTB file to be appended
@ 2011-09-08 10:14 Linus Walleij
  2011-09-08 16:32 ` Grant Likely
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Linus Walleij @ 2011-09-08 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: Linus Walleij <linus.walleij@linaro.org>

This adds a Kconfig string where you can specify a
file to be appended to the zImage on build, then
auto-appends it. The idea is to mimic how we supply
an initramfs image by a similar parameter.

This makes it easy to script the kernel build with
different device trees, and it also vastly simplifies
building uImages since "make uImage" will now pick
up the devcie tree and include it in the final image
as part of the build process.

Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: David Brown <davidb@codeaurora.org>
Cc: Niklas Hernaeus <niklas.hernaeus@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
This builds on top of Nicos pending appended device tree
patches. Nico, if this gains some liking, please include
it in your series.
---
 arch/arm/Kconfig       |   10 ++++++++++
 arch/arm/boot/Makefile |    8 +++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4ea9974..cb8ee68 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1789,6 +1789,16 @@ config ARM_APPENDED_DTB
 	  (dtb) appended to zImage
 	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
 
+config ARM_APPENDED_DTB_FILE
+	string "DTB file"
+	depends on ARM_APPENDED_DTB
+	default ""
+	help
+	  This gives the name of file from the build directory to append
+	  to the zImage after it has been built.
+
+	  If you are not sure, leave it blank.
+
 config ARM_ATAG_DTB_COMPAT
 	bool "Supplement the appended DTB with traditional ATAG information"
 	depends on ARM_APPENDED_DTB
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index a1edfd5..5ab6abf 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -53,8 +53,14 @@ $(obj)/Image: vmlinux FORCE
 $(obj)/compressed/vmlinux: $(obj)/Image FORCE
 	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
 
-$(obj)/zImage:	$(obj)/compressed/vmlinux FORCE
+# Rule to optionally append a DTB
+dtbfile := $(shell echo $(CONFIG_ARM_APPENDED_DTB_FILE))
+quiet_cmd_append = CAT     $@
+      cmd_append = (cat /dev/null $(dtbfile) >> $@)
+
+$(obj)/zImage:	$(obj)/compressed/vmlinux $(dtbfile) FORCE
 	$(call if_changed,objcopy)
+	$(call if_changed,append)
 	@echo '  Kernel: $@ is ready'
 
 endif
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] ARM: supply a DTB file to be appended
  2011-09-08 10:14 [PATCH] ARM: supply a DTB file to be appended Linus Walleij
@ 2011-09-08 16:32 ` Grant Likely
  2011-09-08 21:50   ` Linus Walleij
  2011-09-08 16:49 ` Nicolas Pitre
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2011-09-08 16:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 08, 2011 at 12:14:44PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This adds a Kconfig string where you can specify a
> file to be appended to the zImage on build, then
> auto-appends it. The idea is to mimic how we supply
> an initramfs image by a similar parameter.
> 
> This makes it easy to script the kernel build with
> different device trees, and it also vastly simplifies
> building uImages since "make uImage" will now pick
> up the devcie tree and include it in the final image
> as part of the build process.

The other option is to encode the .dtb filename into the zImage target
name (something like zImage.%).  The advantage being that the build
can emit multiple .dtb bound images without changing the kernel
config.  This is what PowerPC currently does.

Also, the way this is implemented means that it is no longer possible
to emit a zImage without a dtb if the DTB config is set.  Personally,
I'd use a different target name regardless instead of adjusting the
semantics of zImage.

g.

> 
> Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
> Cc: David Brown <davidb@codeaurora.org>
> Cc: Niklas Hernaeus <niklas.hernaeus@linaro.org>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> This builds on top of Nicos pending appended device tree
> patches. Nico, if this gains some liking, please include
> it in your series.
> ---
>  arch/arm/Kconfig       |   10 ++++++++++
>  arch/arm/boot/Makefile |    8 +++++++-
>  2 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 4ea9974..cb8ee68 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1789,6 +1789,16 @@ config ARM_APPENDED_DTB
>  	  (dtb) appended to zImage
>  	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
>  
> +config ARM_APPENDED_DTB_FILE
> +	string "DTB file"
> +	depends on ARM_APPENDED_DTB
> +	default ""
> +	help
> +	  This gives the name of file from the build directory to append
> +	  to the zImage after it has been built.
> +
> +	  If you are not sure, leave it blank.
> +
>  config ARM_ATAG_DTB_COMPAT
>  	bool "Supplement the appended DTB with traditional ATAG information"
>  	depends on ARM_APPENDED_DTB
> diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
> index a1edfd5..5ab6abf 100644
> --- a/arch/arm/boot/Makefile
> +++ b/arch/arm/boot/Makefile
> @@ -53,8 +53,14 @@ $(obj)/Image: vmlinux FORCE
>  $(obj)/compressed/vmlinux: $(obj)/Image FORCE
>  	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
>  
> -$(obj)/zImage:	$(obj)/compressed/vmlinux FORCE
> +# Rule to optionally append a DTB
> +dtbfile := $(shell echo $(CONFIG_ARM_APPENDED_DTB_FILE))
> +quiet_cmd_append = CAT     $@
> +      cmd_append = (cat /dev/null $(dtbfile) >> $@)
> +
> +$(obj)/zImage:	$(obj)/compressed/vmlinux $(dtbfile) FORCE
>  	$(call if_changed,objcopy)
> +	$(call if_changed,append)
>  	@echo '  Kernel: $@ is ready'
>  
>  endif
> -- 
> 1.7.3.2
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: supply a DTB file to be appended
  2011-09-08 10:14 [PATCH] ARM: supply a DTB file to be appended Linus Walleij
  2011-09-08 16:32 ` Grant Likely
@ 2011-09-08 16:49 ` Nicolas Pitre
  2011-09-09  4:52 ` Rob Herring
  2011-09-19  8:52 ` Linus Walleij
  3 siblings, 0 replies; 7+ messages in thread
From: Nicolas Pitre @ 2011-09-08 16:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 8 Sep 2011, Linus Walleij wrote:

> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This adds a Kconfig string where you can specify a
> file to be appended to the zImage on build, then
> auto-appends it. The idea is to mimic how we supply
> an initramfs image by a similar parameter.
> 
> This makes it easy to script the kernel build with
> different device trees, and it also vastly simplifies
> building uImages since "make uImage" will now pick
> up the devcie tree and include it in the final image
> as part of the build process.
> 
> Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
> Cc: David Brown <davidb@codeaurora.org>
> Cc: Niklas Hernaeus <niklas.hernaeus@linaro.org>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> This builds on top of Nicos pending appended device tree
> patches. Nico, if this gains some liking, please include
> it in your series.

I don't like it -- see my previous email for the rational.

I don't want usage of this feature to be vastly simplified.  I want you 
to put pressure on your bootloader team to implement proper DTB passing.
I want the promise of having DT data independent from the kernel binary 
to stay true up to a point, even with bootloaders lacking native support 
for it.  I don't want the incentive to do things properly buried away.

I did resist the idea of even merging this DTB append ability 
into mainline initially.  Given the bootloader reality out there I 
eventually gave in, but I don't want the production flow around it to 
just remain unchanged from the days we didn't have DT at all.


Nicolas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: supply a DTB file to be appended
  2011-09-08 16:32 ` Grant Likely
@ 2011-09-08 21:50   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2011-09-08 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 8, 2011 at 6:32 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
> On Thu, Sep 08, 2011 at 12:14:44PM +0200, Linus Walleij wrote:
>> From: Linus Walleij <linus.walleij@linaro.org>
>> This adds a Kconfig string where you can specify a
>> file to be appended to the zImage on build, then
>> auto-appends it. The idea is to mimic how we supply
>> an initramfs image by a similar parameter.
>
> The other option is to encode the .dtb filename into the zImage target
> name (something like zImage.%). ?The advantage being that the build
> can emit multiple .dtb bound images without changing the kernel
> config. ?This is what PowerPC currently does.

Then "make uimage" has to emit uImage.% as well I guess.

I could do that, but it appears Nico don't like making this too
easy to do so I'll just keep it around as some out-of-tree patch
for personal playground.

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: supply a DTB file to be appended
  2011-09-08 10:14 [PATCH] ARM: supply a DTB file to be appended Linus Walleij
  2011-09-08 16:32 ` Grant Likely
  2011-09-08 16:49 ` Nicolas Pitre
@ 2011-09-09  4:52 ` Rob Herring
  2011-09-19  8:52 ` Linus Walleij
  3 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2011-09-09  4:52 UTC (permalink / raw)
  To: linux-arm-kernel

Linus,

On 09/08/2011 05:14 AM, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This adds a Kconfig string where you can specify a
> file to be appended to the zImage on build, then
> auto-appends it. The idea is to mimic how we supply
> an initramfs image by a similar parameter.

The key difference is an initramfs is much more likely to be platform
independent, but a dtb will never be. Once we have a single kernel, then
we'll need a way to include multiple dtbs and logic to select one?

I think appending a dtb in a way that can be done as late as possible
(i.e. kernel rootfs install time) is a much more useful feature.

Rob

> 
> This makes it easy to script the kernel build with
> different device trees, and it also vastly simplifies
> building uImages since "make uImage" will now pick
> up the devcie tree and include it in the final image
> as part of the build process.
> 
> Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
> Cc: David Brown <davidb@codeaurora.org>
> Cc: Niklas Hernaeus <niklas.hernaeus@linaro.org>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> This builds on top of Nicos pending appended device tree
> patches. Nico, if this gains some liking, please include
> it in your series.
> ---
>  arch/arm/Kconfig       |   10 ++++++++++
>  arch/arm/boot/Makefile |    8 +++++++-
>  2 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 4ea9974..cb8ee68 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1789,6 +1789,16 @@ config ARM_APPENDED_DTB
>  	  (dtb) appended to zImage
>  	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
>  
> +config ARM_APPENDED_DTB_FILE
> +	string "DTB file"
> +	depends on ARM_APPENDED_DTB
> +	default ""
> +	help
> +	  This gives the name of file from the build directory to append
> +	  to the zImage after it has been built.
> +
> +	  If you are not sure, leave it blank.
> +
>  config ARM_ATAG_DTB_COMPAT
>  	bool "Supplement the appended DTB with traditional ATAG information"
>  	depends on ARM_APPENDED_DTB
> diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
> index a1edfd5..5ab6abf 100644
> --- a/arch/arm/boot/Makefile
> +++ b/arch/arm/boot/Makefile
> @@ -53,8 +53,14 @@ $(obj)/Image: vmlinux FORCE
>  $(obj)/compressed/vmlinux: $(obj)/Image FORCE
>  	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
>  
> -$(obj)/zImage:	$(obj)/compressed/vmlinux FORCE
> +# Rule to optionally append a DTB
> +dtbfile := $(shell echo $(CONFIG_ARM_APPENDED_DTB_FILE))
> +quiet_cmd_append = CAT     $@
> +      cmd_append = (cat /dev/null $(dtbfile) >> $@)
> +
> +$(obj)/zImage:	$(obj)/compressed/vmlinux $(dtbfile) FORCE
>  	$(call if_changed,objcopy)
> +	$(call if_changed,append)
>  	@echo '  Kernel: $@ is ready'
>  
>  endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: supply a DTB file to be appended
  2011-09-08 10:14 [PATCH] ARM: supply a DTB file to be appended Linus Walleij
                   ` (2 preceding siblings ...)
  2011-09-09  4:52 ` Rob Herring
@ 2011-09-19  8:52 ` Linus Walleij
  2011-09-19 15:22   ` Nicolas Pitre
  3 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2011-09-19  8:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 8, 2011 at 12:14 PM, Linus Walleij
<linus.walleij@stericsson.com> wrote:

> This makes it easy to script the kernel build with
> different device trees, and it also vastly simplifies
> building uImages since "make uImage" will now pick
> up the devcie tree and include it in the final image
> as part of the build process.

A clarification here on what it actually simplifies.

make zImage
cat my.dtb >> arch/arm/boot/zImage
make uImage

Does *not* work.

The reason is that when you issue "make uImage"
the zImage is overwritten due to changed timestamp.
Then a uImage without the DTB is created.

So currently to generate a uImage you have to
do something like:

make zImage
cat my.dtb >> arch/arm/boot/zImage
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000
-n 'Linux-3.0' -d arch/arm/boot/zImage arch/arm/boot/uImage

The patch folds all of this into:

make uImage

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: supply a DTB file to be appended
  2011-09-19  8:52 ` Linus Walleij
@ 2011-09-19 15:22   ` Nicolas Pitre
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Pitre @ 2011-09-19 15:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 19 Sep 2011, Linus Walleij wrote:

> On Thu, Sep 8, 2011 at 12:14 PM, Linus Walleij
> <linus.walleij@stericsson.com> wrote:
> 
> > This makes it easy to script the kernel build with
> > different device trees, and it also vastly simplifies
> > building uImages since "make uImage" will now pick
> > up the devcie tree and include it in the final image
> > as part of the build process.
> 
> A clarification here on what it actually simplifies.
> 
> make zImage
> cat my.dtb >> arch/arm/boot/zImage
> make uImage
> 
> Does *not* work.

You must have been confused by what this patch fixes:

http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7016/1

Some confusion on my part made me create a similar patch and send it to 
RMK, but the issue being fixed is the same.

So yes, the above now *does* work.


Nicolas

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-09-19 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-08 10:14 [PATCH] ARM: supply a DTB file to be appended Linus Walleij
2011-09-08 16:32 ` Grant Likely
2011-09-08 21:50   ` Linus Walleij
2011-09-08 16:49 ` Nicolas Pitre
2011-09-09  4:52 ` Rob Herring
2011-09-19  8:52 ` Linus Walleij
2011-09-19 15:22   ` Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).