From: Alexander Dahl <post@lespocky.de>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH 2/2] image_kernel: new options for "appended DT" images
Date: Mon, 28 Nov 2016 11:21:32 +0100 [thread overview]
Message-ID: <1480328492-29475-3-git-send-email-post@lespocky.de> (raw)
In-Reply-To: <1480328492-29475-1-git-send-email-post@lespocky.de>
On a platform where we can not load a separate device tree binary blob
with the old bootloader we use the kernel option
CONFIG_ARM_APPENDED_DTB to load the DT blob. This requires creating a
zImage, concatenate the dtb file and put this back to an uImage. This
patch extends the image generation rules so this is possible
automatically with just a few options in the menu.
Signed-off-by: Alexander Dahl <post@lespocky.de>
---
platforms/image_kernel.in | 26 ++++++++++++++++++++++++++
platforms/kernel.in | 2 +-
rules/kernel.make | 6 ++++++
rules/post/image_kernel.make | 32 ++++++++++++++++++++++++++++++++
4 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/platforms/image_kernel.in b/platforms/image_kernel.in
index 1f32576..e7928b3 100644
--- a/platforms/image_kernel.in
+++ b/platforms/image_kernel.in
@@ -44,4 +44,30 @@ config IMAGE_KERNEL_LZOP_EXTRA_ARGS
string
prompt "extra arguments passed to the lzop command"
+menuconfig IMAGE_KERNEL_APPENDED_DTB_ZIMAGE
+ bool
+ prompt "Generate image with appended DT blob"
+ depends on DTC
+ depends on KERNEL_IMAGE_Z
+ help
+ Old bootloaders may not be able load a separate device tree binary
+ blob, so the kernel offers the option CONFIG_ARM_APPENDED_DTB to
+ append the dtb directly to a zImage and load it from there.
+
+config IMAGE_KERNEL_APPENDED_DTB_FILE
+ string
+ prompt "dtb filename"
+ depends on IMAGE_KERNEL_APPENDED_DTB_ZIMAGE
+ help
+ You can build several dtb files, but it only makes sense to
+ concatenate one to the kernel image. Enter the filename here!
+
+config IMAGE_KERNEL_APPENDED_DTB_UIMAGE
+ bool
+ prompt "additional uImage"
+ depends on IMAGE_KERNEL_APPENDED_DTB_ZIMAGE
+ select HOST_U_BOOT_TOOLS
+ help
+ Make a uImage from the concatenated zImage/dtb file.
+
endif
diff --git a/platforms/kernel.in b/platforms/kernel.in
index 2a00122..0a894b2 100644
--- a/platforms/kernel.in
+++ b/platforms/kernel.in
@@ -216,7 +216,7 @@ config KERNEL_DTC
config KERNEL_LOADADDR
hex
prompt "uImage load address"
- depends on KERNEL_IMAGE_U
+ depends on KERNEL_IMAGE_U || IMAGE_KERNEL_APPENDED_DTB_UIMAGE
help
Newer kernels want this passed if you build an uImage.
diff --git a/rules/kernel.make b/rules/kernel.make
index 3270231..dc1e240 100644
--- a/rules/kernel.make
+++ b/rules/kernel.make
@@ -280,6 +280,12 @@ $(STATEDIR)/kernel.targetinstall.post: $(IMAGEDIR)/linuximage
ifdef PTXCONF_IMAGE_KERNEL_LZOP
$(STATEDIR)/kernel.targetinstall.post: $(IMAGEDIR)/linuximage.lzo
endif
+ifdef PTXCONF_IMAGE_KERNEL_APPENDED_DTB_ZIMAGE
+$(STATEDIR)/kernel.targetinstall.post: $(IMAGEDIR)/linux_dtb.zImage
+endif
+ifdef PTXCONF_IMAGE_KERNEL_APPENDED_DTB_UIMAGE
+$(STATEDIR)/kernel.targetinstall.post: $(IMAGEDIR)/linux_dtb.uImage
+endif
endif
$(STATEDIR)/kernel.targetinstall.post:
diff --git a/rules/post/image_kernel.make b/rules/post/image_kernel.make
index a401d71..402b743 100644
--- a/rules/post/image_kernel.make
+++ b/rules/post/image_kernel.make
@@ -10,6 +10,8 @@
SEL_ROOTFS-$(PTXCONF_IMAGE_KERNEL) += $(IMAGEDIR)/linuximage
SEL_ROOTFS-$(PTXCONF_IMAGE_KERNEL_LZOP) += $(IMAGEDIR)/linuximage.lzo
+SEL_ROOTFS-$(PTXCONF_IMAGE_KERNEL_APPENDED_DTB_ZIMAGE) += $(IMAGEDIR)/linux_dtb.zImage
+SEL_ROOTFS-$(PTXCONF_IMAGE_KERNEL_APPENDED_DTB_UIMAGE) += $(IMAGEDIR)/linux_dtb.uImage
ifdef PTXCONF_IMAGE_KERNEL_INITRAMFS
$(IMAGEDIR)/linuximage: $(STATEDIR)/image_kernel.compile
@@ -33,4 +35,34 @@ $(IMAGEDIR)/linuximage.lzo: $(IMAGEDIR)/linuximage
@lzop -f $(call remove_quotes,$(PTXCONF_IMAGE_KERNEL_LZOP_EXTRA_ARGS)) -c "$(<)" > "$(@)"
@echo "done."
+$(IMAGEDIR)/linux_dtb.zImage: $(IMAGEDIR)/linuximage $(STATEDIR)/dtc.targetinstall
+ @echo -n "Creating '$(notdir $(@))' from '$(notdir $(<))' ..."
+ @cat "$(<)" "$(IMAGEDIR)/$(call remove_quotes,$(PTXCONF_IMAGE_KERNEL_APPENDED_DTB_FILE))" > "$(@)"
+ @echo ' done.'
+
+#
+# Create architecture type for mkimage
+# Most architectures are working with label $(PTXCONF_ARCH_STRING)
+# but the i386 family needs "x86" instead!
+#
+ifeq ($(PTXCONF_ARCH_STRING),"i386")
+MKIMAGE_ARCH := x86
+else
+MKIMAGE_ARCH := $(PTXCONF_ARCH_STRING)
+endif
+
+$(IMAGEDIR)/linux_dtb.uImage: $(IMAGEDIR)/linux_dtb.zImage
+ @echo "Creating '$(notdir $(@))' from '$(notdir $(<))' ..."
+ @$(PTXCONF_SYSROOT_HOST)/bin/mkimage \
+ -A $(MKIMAGE_ARCH) \
+ -O linux \
+ -T kernel \
+ -C none \
+ -a $(PTXCONF_KERNEL_LOADADDR) \
+ -e $(PTXCONF_KERNEL_LOADADDR) \
+ -n "Linux-$(KERNEL_VERSION)" \
+ -d "$(<)" \
+ "$(@)"
+ @echo 'Done.'
+
# vim: syntax=make
--
2.1.4
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
prev parent reply other threads:[~2016-11-28 10:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 10:21 [ptxdist] [PATCH 0/2] kernel image generation extensions Alexander Dahl
2016-11-28 10:21 ` [ptxdist] [PATCH 1/2] kernel: pass loadaddr for building uImage Alexander Dahl
2016-11-28 16:46 ` Michael Olbrich
2016-11-29 9:04 ` Marc Kleine-Budde
2016-11-29 9:12 ` Michael Olbrich
2016-11-29 9:18 ` Uwe Kleine-König
2016-11-29 9:21 ` Alexander Stein
2016-11-29 9:23 ` Marc Kleine-Budde
2016-11-30 10:06 ` Alexander Dahl
2016-11-28 10:21 ` Alexander Dahl [this message]
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=1480328492-29475-3-git-send-email-post@lespocky.de \
--to=post@lespocky.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