From patchwork Fri Jun 7 13:21:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 249721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id AECEF2C009A for ; Fri, 7 Jun 2013 23:21:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E427CA0119; Fri, 7 Jun 2013 13:21:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rM5-QTrSWSiK; Fri, 7 Jun 2013 13:21:47 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 5C8DEA012D; Fri, 7 Jun 2013 13:21:47 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 7C31A8F79E for ; Fri, 7 Jun 2013 13:21:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 25DBF8A893 for ; Fri, 7 Jun 2013 13:21:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PQjKt-SxgAEi for ; Fri, 7 Jun 2013 13:21:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [94.23.35.102]) by whitealder.osuosl.org (Postfix) with ESMTP id 57CAC8A899 for ; Fri, 7 Jun 2013 13:21:46 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 106) id C6BF87AF; Fri, 7 Jun 2013 15:21:45 +0200 (CEST) Received: from localhost (189.58.26.109.rev.sfr.net [109.26.58.189]) by mail.free-electrons.com (Postfix) with ESMTPSA id 761BA7A0; Fri, 7 Jun 2013 15:21:45 +0200 (CEST) From: Maxime Ripard To: buildroot@busybox.net Date: Fri, 7 Jun 2013 15:21:43 +0200 Message-Id: <1370611303-5054-1-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.8.3 Cc: Maxime Ripard Subject: [Buildroot] [PATCHv2] linux: Fix uImage with appended DTs generation X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Fixes bug #5516 - appended device tree blobs on uImage fails Before version 3.7 of the kernel, building the zImage and then the uImage will rewrite the zImage in the process, removing the device tree we just appended. Use mkimage to append the device tree to the uImage and rebuild the headers directly. Signed-off-by: Maxime Ripard --- linux/linux.mk | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/linux/linux.mk b/linux/linux.mk index 57956dd..50fa943 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -106,12 +106,6 @@ ifneq ($(LINUX_KERNEL_UIMAGE_LOADADDR),) LINUX_MAKE_FLAGS+=LOADADDR="$(LINUX_KERNEL_UIMAGE_LOADADDR)" endif -ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y) -LINUX_IMAGE_TARGET=zImage -else -LINUX_IMAGE_TARGET=$(LINUX_IMAGE_NAME) -endif - # Compute the arch path, since i386 and x86_64 are in arch/x86 and not # in arch/$(KERNEL_ARCH). Even if the kernel creates symbolic links # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the @@ -229,9 +223,16 @@ define LINUX_APPEND_DTB fi >> $(KERNEL_ARCH_PATH)/boot/zImage endef ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y) -# We need to generate the uImage here after that so that the uImage is -# generated with the right image size. -LINUX_APPEND_DTB += $(sep)$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) uImage +# We need to generate a new u-boot image that takes into +# account the extra-size added by the device tree at the end +# of the image. To do so, we first need to retrieve both load +# address and entry point for the kernel from the already +# generate uboot image before using mkimage -l. +LINUX_APPEND_DTB += $(sep) MKIMAGE_ARGS=`$(HOST_DIR)/usr/bin/mkimage -l $(LINUX_IMAGE_PATH) |\ + sed -n -e 's/Image Name:[ ]*\(.*\)/-n \1/p' -e 's/Load Address:/-a/p' -e 's/Entry Point:/-e/p'`; \ + $(HOST_DIR)/usr/bin/mkimage -A $(KERNEL_ARCH) -O linux \ + -T kernel -C none $${MKIMAGE_ARGS} \ + -d $(KERNEL_ARCH_PATH)/boot/zImage $(LINUX_IMAGE_PATH); endif endif @@ -240,7 +241,7 @@ endif define LINUX_BUILD_CMDS $(if $(BR2_LINUX_KERNEL_USE_CUSTOM_DTS), cp $(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH) $(KERNEL_ARCH_PATH)/boot/dts/) - $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_TARGET) + $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_NAME) @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \ $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) modules ; \ fi