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 <[email protected]>
---
 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
[email protected]

Reply via email to