Skip to contentSkip to conversation

ARM: supply a DTB file to be appended

PATCH New Linus Walleij 5 participants 7 messages Sep 8, 2011 – Sep 19, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

From: Linus Walleij <[email protected]>

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 <[email protected]>
Cc David Brown <[email protected]>
Cc Niklas Hernaeus <[email protected]>
Cc Grant Likely <[email protected]>

---
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(-)
arch/arm/Kconfig +10 -0
index 4ea9974..cb8ee68 100644
@@ -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
arch/arm/boot/Makefile +7 -1
index a1edfd5..5ab6abf 100644
@@ -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
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

Quoted 7 lines · Linus Walleij

From: Linus Walleij <[email protected]>

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.

Quoted 5 lines

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.

Quoted 59 lines
Cc Nicolas Pitre <[email protected]>
Cc David Brown <[email protected]>
Cc Niklas Hernaeus <[email protected]>
Cc Grant Likely <[email protected]>

---
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(-)
arch/arm/Kconfig +10 -0
index 4ea9974..cb8ee68 100644
@@ -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
arch/arm/boot/Makefile +7 -1
index a1edfd5..5ab6abf 100644
@@ -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
Signature · 1 line
1.7.3.2
#2 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

Quoted 11 lines · Grant Likely
Quoted 5 lines · Linus Walleij

From: Linus Walleij <[email protected]> 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

#3 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

In reply to Linus Walleij
Quoted 18 lines · Linus Walleij

From: Linus Walleij <[email protected]>

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 <[email protected]>
Cc David Brown <[email protected]>
Cc Niklas Hernaeus <[email protected]>
Cc Grant Likely <[email protected]>
Quoted 4 lines

---
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

#4 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

In reply to Linus Walleij

Linus,

Quoted 6 lines · Linus Walleij

From: Linus Walleij <[email protected]>

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

Quoted 62 lines

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 <[email protected]>
Cc David Brown <[email protected]>
Cc Niklas Hernaeus <[email protected]>
Cc Grant Likely <[email protected]>

---
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(-)
arch/arm/Kconfig +10 -0
index 4ea9974..cb8ee68 100644
@@ -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
arch/arm/boot/Makefile +7 -1
index a1edfd5..5ab6abf 100644
@@ -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
#5 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

In reply to Linus Walleij
Quoted 5 lines · Linus Walleij

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

#6 lore raw

PATCH 1/1 ARM: supply a DTB file to be appended

Quoted 9 lines · Linus Walleij
Quoted 5 lines · Linus Walleij

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.

Quoted 7 lines

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