From patchwork Wed May 29 08:36:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 247174 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 923162C02C7 for ; Wed, 29 May 2013 18:36:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 591CC31C6F; Wed, 29 May 2013 08:36:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L89UEPCvS+Qp; Wed, 29 May 2013 08:36:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 5E32331B6A; Wed, 29 May 2013 08:36:54 +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 713908F7A2 for ; Wed, 29 May 2013 08:36:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 75DF58D08D for ; Wed, 29 May 2013 08:36:52 +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 aMYO9NuKhFUg for ; Wed, 29 May 2013 08:36:51 +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 7258C8D051 for ; Wed, 29 May 2013 08:36:51 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 106) id 8D3ABE48; Wed, 29 May 2013 10:36:48 +0200 (CEST) Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 779987BD; Wed, 29 May 2013 10:36:47 +0200 (CEST) From: Maxime Ripard To: buildroot@busybox.net Date: Wed, 29 May 2013 10:36:45 +0200 Message-Id: <1369816605-6268-1-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.8.2.3 Cc: Maxime Ripard Subject: [Buildroot] [PATCH] 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/linux/linux.mk b/linux/linux.mk index 3877c35..a1166e5 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -228,9 +228,17 @@ 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) LOAD=`$(HOST_DIR)/usr/bin/mkimage -l $(LINUX_IMAGE_PATH) |\ + sed -n 's/Load Address: \([0-9]*\)/\1/p'`; \ + ENTRY=`$(HOST_DIR)/usr/bin/mkimage -l $(LINUX_IMAGE_PATH) |\ + sed -n 's/Entry Point: \([0-9]*\)/\1/p'`; \ + $(HOST_DIR)/usr/bin/mkimage -A $(KERNEL_ARCH) -O linux -T kernel -C none -a $${LOAD} -e $${ENTRY} \ + -n 'Linux Buildroot' -d $(KERNEL_ARCH_PATH)/boot/zImage $(LINUX_IMAGE_PATH); endif endif