From patchwork Thu Oct 17 14:44:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 836146 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp361572wrt; Thu, 17 Oct 2024 07:45:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW7azxvTQpZfUo8xedxV4DZEOrVBdMkZPSTalXR4Bjm2iQYe71rkW8YV2nsxNNDvPrf9+uHyQ==@linaro.org X-Google-Smtp-Source: AGHT+IHqI0G6O7c7OCdqe0waA9si7NnMe1ZIOG+K412fAtm5WsZzy6lZLkSHhTaeZQCHADHkdbej X-Received: by 2002:a05:6e02:13ab:b0:3a3:ae58:2ef1 with SMTP id e9e14a558f8ab-3a3bcd9849emr121035165ab.2.1729176302372; Thu, 17 Oct 2024 07:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729176302; cv=none; d=google.com; s=arc-20240605; b=DCxDffwk7ta3D1xq414Etd/cOgcUopNUimCAfDWJGEvwpoFR01RUkwbRXxYtJaycN+ L3nV7oiI3if1j9sqSsLhg8G0tOnubPQRNRooaTZmqMu7gTR6q5vBdfG7YwuCb9eps57x z3+1nc/71Rp08+vH5byQCLBztIrTDmCxCHEb9Ir/kRwR+mBBnWjgxGa9+maaa6i/HDoq /lhoavNBjdPLtZT6uLMM3iENRblI0YW9vDhcUd0V2mfNs8adKEyIsCAkzNn8S3hpdUzi kAXa59fCDjcUClEOIXmwTSzcXzW35E/LZyzP071ZfGsch5Jtb6ZBVx3+rZfauMJ6Tk3D 4ntA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=gQYY5frZBxHo84ChtJ9RZ/UNM3wDdkWaFRjHDGXXJ8Y=; fh=ROGTLJdJjAOSGUhLmIuUo0LXrCDChmcMmPhlq4tbP+8=; b=T4O7RT8ml4RY6pF71ReUnF8LaXilRADifiqlTYX++LlpvZqoljufyOcgrKUxhLIYJc +/QW6kj3GSf5K/4d2WFa5MjvfWYDJDnxKKQN7zQHsMXfzBWLvfBPyw8gzkB41y9G/aHf SzCx2iBAc03KyOVO+uz3lmmUQkdB9BVqN3YncUYpAXW+msArFS3HPDloiUgrXSNQgNy0 cJeB0/TQbHErYwTd5l8lIkyUzYgmepOd4vkoSR/1xO+Z/EKyO+fApqNvY/75IlQp4wXg jPHMicoryqgevbBYTiq7j9T2MmcwaOS6JUpuNkA88S0IhHf+yDxgKedMWtd5w8bgEzCq YZgg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fONKu6lw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a3d71e2703si30218965ab.186.2024.10.17.07.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 07:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fONKu6lw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D18DF89023; Thu, 17 Oct 2024 16:44:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fONKu6lw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BDDA889EB; Thu, 17 Oct 2024 16:44:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3BDB188FF6 for ; Thu, 17 Oct 2024 16:44:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4314311959aso9442085e9.1 for ; Thu, 17 Oct 2024 07:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729176287; x=1729781087; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gQYY5frZBxHo84ChtJ9RZ/UNM3wDdkWaFRjHDGXXJ8Y=; b=fONKu6lw7c73KKVSVNg8YGscuvuhw2yPXEvWwImGLIGKJXI0JIk+dNA36WrbwTq6m1 9zpVm+xYpSigsVZnZCBkhAzlNypVxvEIus7JKFuxriQPdmq26p4Ky82vXQcDFUF4yaLg ipCs9h2fT4khNteHwYBLZEy6XIY5J1GCm2IPnKB65yxafExPvFK0Y4Ofs/oQiwqs8mzV 97/1fQ8fqE2V9tIk+kYwVRZ4VWmKFmqQLF50zdJiVLGtOSAbb1d727qlOQNXfXwmLTAg mgRWdvV3pIUeOY5g49efkXeuE76MOKUuZy3tPKAp+lHFS7u/gPoWCZzPbzfsJ/90wjRQ dRIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729176287; x=1729781087; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gQYY5frZBxHo84ChtJ9RZ/UNM3wDdkWaFRjHDGXXJ8Y=; b=SHJWLW21RssnTyLW0Oqst6haTsQJ6CkbHkiqgFSlzZddEMy9xioK/eCobNvUdx4U6K nXFsn2+S7Ss1fW2loyIXj9tN2XO4G8qIKRaycQB/ux4Qn3IqglVDEw1bbjcr+VYDS3U0 SgsHLPGQ9OuXG6kdU/hIu9uynfE87j0Dcy+PYRsivFkv80y/rd3VlYK4l2iOky7RC4z+ Y/IDDdbfSqZedO05WpVpRzMPljFzLJi91Vv/DcVrSiEvF8a+GlUoVyv7frN88KnYcaN5 l83HG94PNaZM5PSeqfsPJ0utrcXJVBWny1fW2ojjOeyFYOwm8H+zuM4AlW9xvqqtL0Vm pHzw== X-Forwarded-Encrypted: i=1; AJvYcCV7JmnZnrc+TO4IgJXopISi5Df+d0ne9ZjJkMfxCjmV5NQ7QqQgsOwzLQ/33xe8DzeQw0+BJzI=@lists.denx.de X-Gm-Message-State: AOJu0YxYiKjnbpSwsgsnmS+p4bIo/8zX7t0bSjPxhJEF5qvr7Ptawmiq TFzVV6I1nj5DxmZY02brerpzPeJxdkh7p/Sd49RQXXPA3/lxqcGvdEXsCXbQ0OMPFDv0ERXXTRR EymI= X-Received: by 2002:a05:600c:3d89:b0:42c:b2fa:1c15 with SMTP id 5b1f17b1804b1-431255e2cafmr152976455e9.15.1729176286530; Thu, 17 Oct 2024 07:44:46 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43158c37fbesm28923195e9.8.2024.10.17.07.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 07:44:46 -0700 (PDT) From: Neil Armstrong Date: Thu, 17 Oct 2024 16:44:42 +0200 Subject: [PATCH v2 1/3] image: android: use ulong for kernel address MIME-Version: 1.0 Message-Id: <20241017-topic-fastboot-fixes-mkbootimg-v2-1-c3927102d931@linaro.org> References: <20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org> In-Reply-To: <20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org> To: Tom Rini Cc: Mattijs Korpershoek , Guillaume La Roque , Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1906; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=X7ZHztPg6fZqYVFEgR25qte+6Ywvk/GfINxsOSd4KGY=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnESLbOTMpjLJAf9RS2jDcXNLBhfF9kwW1uaTnt0wL MKs+S5qJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZxEi2wAKCRB33NvayMhJ0ZwoD/ 95Dmp7+PcoeNakGSpKzZlElzdlMslUiJVgZmQE6sJFscEa4ADXYETpMBChYUuykPAR1VS08UfKdkIK MKZBMwoIjNhmLmhDbYgUTzG0JORFcqLpj4568qBrd92F60nRPiG2Va79Zdch0UhukLs3gQ3j8/qgvh CT8kvhzFH+TU982o7GY55vPPfdUcwlrB7ACvmEzTyidagrYtFqiH+zg+tXigsNk/SgW4ncjsLl2Ccd XDxtAhHRZZB/XhnVFYozxyNewbtlbr5EHq2cqQdVXugyfQ9/GAXl2wNRcHnE+af2fKduDnmhVz2kwY gYz5lGoYJk7tfaWwYTQC4/v00UNbFTO6vq+pdGR2vB5NolqxsHuG22qZfjXi+Ie/qSmPzAeYw+p96R uHdd3vC+p0kOzGj9bk+pX7yyVXjqiPg6ubnj/DnKyAAgzUs/1KXZ5cMqRvv90DHMCXYA0M7D1aH6ex 09RvrQVanKa1c4XpolD2FTn4yUbjPAWZMyrhwEGGW3AifgbfPuNczsX/BjMuzmYEbz9SeeXMUpQmij VVa1nkRDif7CjGv0rr8ciLlapNXO5xYRXBVtzHi5mqKYR89G1BRbdjP5vtOViyiKrpAQbgVQ4cjpKt JF675xaxuM5CTfvNNHwvGt7bK5VzyXCJ+CsZENvxltqkHlgGJaPXEEQt7x6w== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When booting with platforms having > 4GiB of memory, the kernel physical address can be more than 32bits. Use ulong like all the other addresses, and fix the print to show the > 32bits address numbers. Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek --- boot/image-android.c | 4 ++-- include/android_image.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index e74dd498a305566e42aa235b45c22995e21ca64b..bb5f4f84487d40e0cf24dc3b57042993967e66d5 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -256,7 +256,7 @@ int android_image_get_kernel(const void *hdr, ulong *os_data, ulong *os_len) { struct andr_image_data img_data = {0}; - u32 kernel_addr; + ulong kernel_addr; const struct legacy_img_hdr *ihdr; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) @@ -275,7 +275,7 @@ int android_image_get_kernel(const void *hdr, if (strlen(andr_tmp_str)) printf("Android's image name: %s\n", andr_tmp_str); - printf("Kernel load addr 0x%08x size %u KiB\n", + printf("Kernel load addr 0x%08lx size %u KiB\n", kernel_addr, DIV_ROUND_UP(img_data.kernel_size, 1024)); int len = 0; diff --git a/include/android_image.h b/include/android_image.h index d503c980b233bf31cd12a246ff1570544597a1c7..96820709b42830c7ce4cb753687da373936253a7 100644 --- a/include/android_image.h +++ b/include/android_image.h @@ -348,7 +348,7 @@ struct andr_image_data { ulong bootconfig_addr; /* bootconfig image address */ ulong bootconfig_size; /* bootconfig image size */ - u32 kernel_addr; /* physical load addr */ + ulong kernel_addr; /* physical load addr */ ulong ramdisk_addr; /* physical load addr */ ulong ramdisk_ptr; /* ramdisk address */ ulong dtb_load_addr; /* physical load address for DTB image */ From patchwork Thu Oct 17 14:44:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 836147 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp361762wrt; Thu, 17 Oct 2024 07:45:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXjYLeqhdBO1ri4p5RRFC81trG5fIefWGfSqQTxjrZEZXwCr4RFsGYpwuHfP+63y8E5Jrsjow==@linaro.org X-Google-Smtp-Source: AGHT+IG5PJy5Ni2wPBK/SaCZijc+JSTcQtsyM3SsHaSSd7ho/vQzdLuS9qVn+LGZTg5mhTEtq/Ft X-Received: by 2002:a05:6602:158c:b0:837:f951:38ce with SMTP id ca18e2360f4ac-83a94482fe3mr841208839f.8.1729176313466; Thu, 17 Oct 2024 07:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729176313; cv=none; d=google.com; s=arc-20240605; b=Bx/Per1kWIHkOVEUuZTclkD/ApZqx5bmOWd3dJ5x9cZO9VRiddDgypf0btvuRKJQP2 ElB/U+iMhE/JFKVBijN9dxVETuyC4O66vcg4qE+FiGXk9v/+gLZQr7tZKFP/YKZe5f6Y CxZBsP+aMm+lqcbnNVMnQ08RNlreYC+XqAp/6vWdABb9GwycmAm41F9WhnU84kNoAwOa nklYfvMahBS6QxvZT5+HcLFgpQ+tPphbIaRW7xeuhVj+kFBcAXayVkdrYJlr8GuhQZF2 peeH+/XnenJ/tanTx6xaUvvhP/j0V9q4KB02RC0JsniGWqEfEGhgNS41mxcfnIdmNaig JTXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=E55KgvjEq6ZvKO5NADnCK5xx/g2VloRvKzw2CbvnhlU=; fh=F4Ow2KowhngtZgSR0q8w6Q0W1BYEuYTfeXnZ/Uip3a4=; b=ErsOyNp9SRa6NdvndD4+uv6S3SpL7Dc3btUpyVo/Hvdw01b0M1UC3NlIXGyT1ccja7 b/zXWUA0uO6H0BbuEOIoQQAKX2oGqYpgCbLViTCqApoxdLHm9R67RCi2czLJv8bUl7/a SnbqFEj1i0UwLWyBWBx9C4g8LiONXGi6SHrhQ67zItJMGEo3cRSDd/spmSiTycF+IjK+ NIUT8OfoLhy54JdY/zeYmcS4kfXPWeTLuR2edOqjAXeog4ncU5w31FD9M4qu+R0gaMZp QVqb1VxQZ7g91vLU9l/vu29kEe5/vuU1rSGXqeSAc2hKVvOENSDhb73M87tzMxLhl9Dz OTCA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kN6VwXXy; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4dbecccb7cdsi3092712173.91.2024.10.17.07.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 07:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kN6VwXXy; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E01089010; Thu, 17 Oct 2024 16:44:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kN6VwXXy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 180188902E; Thu, 17 Oct 2024 16:44:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ED0FA8900B for ; Thu, 17 Oct 2024 16:44:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4315abed18aso7012525e9.2 for ; Thu, 17 Oct 2024 07:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729176287; x=1729781087; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=E55KgvjEq6ZvKO5NADnCK5xx/g2VloRvKzw2CbvnhlU=; b=kN6VwXXyb0tIwSF5r6eNkhJLe1xtEKpFcShUtNhaBtuLbihg0RsHRdLGvS8l9HxfsT bvcd38rW+eL8AZrdprUAASP3p0+EXLpi+erI1WLyQlqtF2D0pMKXl3nEQ4VcFPZX1PTc JJy9EITeDD9r0hhMONoT6PWc8sVf6Au25/njto+p9RHKtR2Kzb1OOIsxVb5l2+u5rY4j Vb04Hftup8ogppHkTqSWeG+TFuXtuGiUAstD0o1bnosqjt0tF9n5Ma9yPQ8PbIo52EWJ YLL5K8qyDHHIUXAMFAa6MB/b+UG9Am20DMy4iDdD9FxNo6ulBH8WimJpi7v1AiUuaMhM Mcew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729176287; x=1729781087; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E55KgvjEq6ZvKO5NADnCK5xx/g2VloRvKzw2CbvnhlU=; b=n+7h/SrhdrXhiqDIyxFDw4NmmV7/4kOU71o0KkvRCdrenFy8wa+B7RpJIpBi9f3aK0 qGo5K6D2JFlrXIJRRJFoB3Gdg7cndmoe2C928zu2EJW0Xy6AQVZnK2snSB9FqzHjzyVe vNosqqoOesvZ1nAMRDfIJV0kIhOFJ6mQ2a2tufx8pDXn/eW05acwzFLhdm0VxBVYJGlz f4H5+RUwu9WL4wQxdHEWewrJwxMEKlaWL1Tpw3xoEMDhPQ1rK4qCsW+frlo8wdYEi/ec /mep0RVFWKc9qjqq8hVa5M8ENDjC2w8r4T+aBNS+TxmG1kpweYdPPy81aiftKWi/3nAJ HOKQ== X-Forwarded-Encrypted: i=1; AJvYcCWqKRD+nnI7vcXdUAu7jS1qUXBxRfcDwSoMV+2ic70DjM0Lu2NPzYm9kbhaJqwV64hZV2kRHaM=@lists.denx.de X-Gm-Message-State: AOJu0YwKQpfVXjSxpPLk4XhjgdG9xHSreePMQp2oII4AsF0gNeyFQ0fX rb4lgGpYPvKwgDciSCVw66t2USsQdQK0cwsJcM1a4wM6KxJCgdcCyz1qyNamzBQ= X-Received: by 2002:a05:600c:1c9c:b0:430:563a:b20a with SMTP id 5b1f17b1804b1-431255dc851mr155656735e9.11.1729176287354; Thu, 17 Oct 2024 07:44:47 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43158c37fbesm28923195e9.8.2024.10.17.07.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 07:44:46 -0700 (PDT) From: Neil Armstrong Date: Thu, 17 Oct 2024 16:44:43 +0200 Subject: [PATCH v2 2/3] image: android: do not boot XIP when kernel is compressed MIME-Version: 1.0 Message-Id: <20241017-topic-fastboot-fixes-mkbootimg-v2-2-c3927102d931@linaro.org> References: <20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org> In-Reply-To: <20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org> To: Tom Rini Cc: Mattijs Korpershoek , Guillaume La Roque , Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2625; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=aF8xM9sCZGgIvtKbwtbcWSVIp3oIbPcNIUcWWyzrU40=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnESLcv50SOriFtw1GWstbBob806gcaPUdwBk2hEmf RRFyGkiJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZxEi3AAKCRB33NvayMhJ0aidEA C/uXTXQPGggHP9vxN0jd5BaE5Y+WNp3tPY94FcPlxIoUpjrdFY3Qe2AI3vNFZCc0qATwHSA4OQbaX/ z9ylCCiQjNjB3T4sc4EijS0IS2jGddiviHGOVkX35+uxJitiP+ZskVTrEsVvokia/Bfv0J4agyAqBq aXuILcXL2o76RDpZv9XdgJTOVgezlbvbyH+y0uiGs1JFzwyN1TgeQgt7UiiAgSFK3I80C2IopVOO4d dCNrHynUmqnlvps+U1mY82Ickj0jXZ264crLrC86wdBWWqviqJgjeWvgyXgkkSkquBRyIrEZkBtl7Q nAol7aNWMGi/tDZRHbUORwKYUmzn1mUlEPTlwiKn9Q1232oTnVc/ACP0MehzOlcb9NvuRD1Pl6u/XQ 5kYwY5AJNJix7Yi1aZQQj8QMD2FtFiY3Llz5CS4jRRDPSOs4YM7tlGvLlsurCJV2/7JYwqIx4JJdO2 wuiNlXf0Ex5hmBz8/QIEka3HNnpz6BaZp7sFrXrshG6GSPDxpQxj25vYx1LMHL8z5LIdEnwLSOPho8 XJK7krOzvYb8C1VEii6xNHxF8EtzRtxBtrVDr4HkQfU3Hxc+83DxqAPTMZEN+9Ld2612GVITzUFC/+ K5K/dp0z4i249zioysFf2eJafJ7c279NEMNL808Xx+03L4kkF2YrFq3ZXbOA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When trying to boot an android boot image with a compressed kernel, if the kernel is used in-place because it was created with mkbootimg, the space will be too small to properly uncompress. Take in account the compressed state, and if compressed use the kernel_addr_r which should be big enough. Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek --- boot/image-android.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index bb5f4f84487d40e0cf24dc3b57042993967e66d5..3adcc69a392f74ae64f3fbcf1b85204f60ac9aff 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -208,7 +208,8 @@ bool android_image_get_data(const void *boot_hdr, const void *vendor_boot_hdr, return true; } -static ulong android_image_get_kernel_addr(struct andr_image_data *img_data) +static ulong android_image_get_kernel_addr(struct andr_image_data *img_data, + ulong comp) { /* * All the Android tools that generate a boot.img use this @@ -221,8 +222,11 @@ static ulong android_image_get_kernel_addr(struct andr_image_data *img_data) * * Otherwise, we will return the actual value set by the user. */ - if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR) - return img_data->kernel_ptr; + if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR) { + if (comp == IH_COMP_NONE) + return img_data->kernel_ptr; + return env_get_ulong("kernel_addr_r", 16, 0); + } /* * abootimg creates images where all load addresses are 0 @@ -258,11 +262,14 @@ int android_image_get_kernel(const void *hdr, struct andr_image_data img_data = {0}; ulong kernel_addr; const struct legacy_img_hdr *ihdr; + ulong comp; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) return -EINVAL; - kernel_addr = android_image_get_kernel_addr(&img_data); + comp = android_image_get_kcomp(hdr, vendor_boot_img); + + kernel_addr = android_image_get_kernel_addr(&img_data, comp); ihdr = (const struct legacy_img_hdr *)img_data.kernel_ptr; /* @@ -359,11 +366,14 @@ ulong android_image_get_kload(const void *hdr, const void *vendor_boot_img) { struct andr_image_data img_data; + ulong comp; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) return -EINVAL; - return android_image_get_kernel_addr(&img_data); + comp = android_image_get_kcomp(hdr, vendor_boot_img); + + return android_image_get_kernel_addr(&img_data, comp); } ulong android_image_get_kcomp(const void *hdr, From patchwork Thu Oct 17 14:44:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 836148 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp361888wrt; Thu, 17 Oct 2024 07:45:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvzedK/37MyHdrUouW8w5AL12T7HfYLp/QbXrYzmJNFXp8TXRpxy3PUzAhCxyJLpf2+c8RIA==@linaro.org X-Google-Smtp-Source: AGHT+IH60r0BiScGolUWKySLBOtzCJAdg0pJPPOGbqaTWK2oyO8iK7O8yuO+hX8cnF7MVclPp1Nn X-Received: by 2002:a05:6602:6d0e:b0:831:fbd3:88d3 with SMTP id ca18e2360f4ac-83a64cc5064mr1385166839f.2.1729176322953; Thu, 17 Oct 2024 07:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729176322; cv=none; d=google.com; s=arc-20240605; b=ZTfb5xQwLOC7Bk73YQEBG89HtTo2jIaWHKvLlXzi8T7hQJl467iamiE7dQg+nFITAp QXB4AI6psVhPN6DZuZcp0y98vbM3ykB9VfFMZCqnlJwj8TFnnhydB31nDVcPXT20X+4D FYrr85ywbvD1ntb62Lox5+AHjpp5+lilT042STz5T2jzs7D/mZTjJskPVMyIFgN64mXH Y1zf++D0gmi/K5CVwA2CYfaVTcMNUk22tSzzFIsL2OwDnIb6A6tTMrMB0zgb9GXDXPuc n44Zxwdi9Kr07Pt+86AkSU2wO/C8tlwQ6X0XAmAd5pYIXfgNOnRCUzQ0i0Nlb7sm/AMU 6sJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=EzhLcA6piBi9Lp1lE8chhJOw/6UMV1aVb8+MOmQmkew=; fh=9T8rK+HjJ8SY2Sax8H+0WTCqbHNcuvs6WIWdVA40nmI=; b=JHuPeTqws3XmmxceVtiDw4KG6duv8kkhVEav01+iKnUfqrs2qlxvAdBxTIJu7jBviq J0IXdNkJ1M9dKwoTvRXMuuJwCW0dtO2py8a6s1HwpP0jiLVZXOOvZ3G/CJDvj2A9rSqj lXHkiwgahRSzZ6eCxMt7WQQcs6mTNe+GFHDKQP5AatNzcBc2PvzkIW3wExlBOzDLylW6 hmAqdF66+Mo/d9gmQ5a7DJ5gfqxZqo6aKSHVBIISFbcEAI32rFh6my3cRzZn9R632AOZ 9W+eFO/PZEST5qoi8MXimMbkKfZCwcluYch2qTytgCVvGzjOTQ8d3jpGDxCYmYBjUEPD PK4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NaBIW69j; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4dbeccfdf91si3076991173.177.2024.10.17.07.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 07:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NaBIW69j; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D63D58904C; Thu, 17 Oct 2024 16:44:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NaBIW69j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 27651889EB; Thu, 17 Oct 2024 16:44:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CD94689011 for ; Thu, 17 Oct 2024 16:44:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43115887867so7484865e9.0 for ; Thu, 17 Oct 2024 07:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729176288; x=1729781088; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EzhLcA6piBi9Lp1lE8chhJOw/6UMV1aVb8+MOmQmkew=; b=NaBIW69j7/VrXATjdME9Fxl7CuAsSuzWXGxsKYWzxi4devJabx3rTBMaMPvDvKPRUj 1iFcZii1AmHpvlrcXvZfuvjD+B6PblAMVruLVhbuQNqdT0rXkOBXXVtmBzDdyrPQTR+J mDsJKuDqzEuCMxp9vpPnHyb7lPj0CHfnIGs8iN0zVWzKJWB9nnzlKJw0lszpFKEFI34p LVDDxnMx5EzMbL1a31Ho+BYYjVqqAkPFthrbjqwCBDc5R5g2uCeUyf4RPMwvTseKPvGD 14SgT13ABJmC0GduVLxquE15yfoYIJGq3gEYFO6vJBUpGfa7Z8Jbw+m3qHkx0l9pOZ/V nsTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729176288; x=1729781088; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EzhLcA6piBi9Lp1lE8chhJOw/6UMV1aVb8+MOmQmkew=; b=WzdmxmTLoCoQMlyYKI1PVLyA0dMgHeY7RXHEgVmRFLcjF5HDgi0W9dP0RtaZzAptVI JZIS9WaXxRtVWtXPkL5x0R4b0lbJVeuz1z81/FYWSVZiVcX5VzYUwqzDC0Jwepc7AqK6 Uico/WV+1hklTywyndwZWJEjoQZBjHH4Bued7wpA0/hevdLDGCc3KUmj3yE7INomiOJd MgV8qR91T6XOu6I0Qv2w4LVpSSsY6fw3ZYgkqKnrHTVFvRAGlIfA7+DblzGs0Tp1a92I iFYvo1cGMPJyAfn7wAbohrOuylI0gShHYiSP/7QHhv6gSh/j5GPaSFHTyc8SxHe9aG0f sFbQ== X-Forwarded-Encrypted: i=1; AJvYcCU0Y9bYSc3URIGtL0NI11VwhFZxRH9fXtbbtnAgFwIbExcnmrKUEkbtmNAkN6vud3uSLdXmtSs=@lists.denx.de X-Gm-Message-State: AOJu0Yx7Gaz4GeCUkI16hb05XiCcuoTylTm81v/bYCSsuLw42z0F3pm7 IEOmlDdHJMn2kPewC9vt4kTAo9DryabKDgK+eFu2Juia6p9hWTNg68fBMM+lOMU= X-Received: by 2002:a05:600c:1da5:b0:424:895c:b84b with SMTP id 5b1f17b1804b1-43158707646mr22222235e9.4.1729176288132; Thu, 17 Oct 2024 07:44:48 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43158c37fbesm28923195e9.8.2024.10.17.07.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 07:44:47 -0700 (PDT) From: Neil Armstrong Date: Thu, 17 Oct 2024 16:44:44 +0200 Subject: [PATCH v2 3/3] image: android: handle ramdisk default address MIME-Version: 1.0 Message-Id: <20241017-topic-fastboot-fixes-mkbootimg-v2-3-c3927102d931@linaro.org> References: <20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org> In-Reply-To: <20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org> To: Tom Rini Cc: Mattijs Korpershoek , Guillaume La Roque , Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3428; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=+7r25kqF87iWFDDQSqezyyYMHwj1QP4sW1JXrq28SWg=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnESLcKDLmeRw9+qeBWcTTMvlahUGzDXDNhJFU9aqW 9uXdXC6JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZxEi3AAKCRB33NvayMhJ0d6kD/ 9doRDusLvheNonie+55bDa7AOcFj1pYkcrBAHRpp3a9U0+j3rJRLkQKni/44+W6f8F3sa/O1RdD56m 2umE8hbqC3mhGZTZMlyoejO+XaS+2bCZCUhuvK8w/51pTVEwHHxmkDlB5GCG7lNm14Ui8GSVSV+0j3 ySEAnO1t8zqGULP7e81kJoeYJovGQI4jQTMckecezgeP6QnWAhoPmzOiFneZWPamACcpi8xakjI3Bi NCUdUR/qcefsms89jkkHDRA7kP3pJFn9FF1Q+ynVYHPrxP5bnK6RVKLvc7sSIC7QS6VxtnLQJ9Ese9 w79gAjXtw7u066/8iMkhFdpgi4qaweWEPF3VHRxYDDKaFuJz+Jt3FECVIC9GVv1o2BAymbsBp2Mccl OyxRDJP12lJ2pfKKFaYS3PZgSP/EyS9nWGqJyqmqWN/N3FLMLZoRO44nKFNeM5EdpD2fovlkoHsjfe b/ApFYq6jAyo12LmpLcpOtW2G1jczGalF0ECRQsjQKJlpOnNhY6viRmRPaq3oX5Tj1DWO1z35RjHn6 FyllUzmRL1QQ9D/5HepkZgQo1hgOJAiy9oggT6ORYj4zrxs+zoYrEq/hVlm8sbmbyM7PGrWQLTIpaS OvORRtKpk4e3LRAc46OMMm/jKls4zoVJBwG0uR1JPo/A4/ZY7gb0m/3myAfw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The two tools that create android boot images, mkbootimg and the fastboot client, set the kernel address by default to 0x11008000. U-boot always honors this field, and will try to copy the ramdisk to whatever value is set in the header, which won't be mapped to the actual RAM on most platforms, resulting in the kernel obviously not booting. All the targets in U-Boot right now will download the android boot image to CONFIG_SYS_LOAD_ADDR, which means that it will already have been downloaded to some location that is suitable to use the ramdisk in-place for header version 0 to 2. For header version 3 and later, the ramdisk can't be used in-place to use ramdisk_addr_r in this case. Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek --- boot/image-android.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index 3adcc69a392f74ae64f3fbcf1b85204f60ac9aff..cd01278f211d63262f2bdad7aa1176e2c1bbfedd 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -14,6 +14,7 @@ #include #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000 +#define ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR 0x11000000 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1]; @@ -405,9 +406,25 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, if (!img_data.ramdisk_size) return -ENOENT; - + /* + * Android tools can generate a boot.img with default load address + * or 0, even though it doesn't really make a lot of sense, and it + * might be valid on some platforms, we treat that address as + * the default value for this field, and try to pass ramdisk + * in place if possible. + */ if (img_data.header_version > 2) { - ramdisk_ptr = img_data.ramdisk_addr; + /* Ramdisk can't be used in-place, copy it to ramdisk_addr_r */ + if (img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) { + ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0); + if (!ramdisk_ptr) { + printf("Invalid ramdisk_addr_r to copy ramdisk into\n"); + return -EINVAL; + } + } else { + ramdisk_ptr = img_data.ramdisk_addr; + } + *rd_data = ramdisk_ptr; memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr, img_data.vendor_ramdisk_size); ramdisk_ptr += img_data.vendor_ramdisk_size; @@ -420,15 +437,20 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, img_data.bootconfig_size); } } else { - ramdisk_ptr = img_data.ramdisk_addr; - memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr, - img_data.ramdisk_size); + /* Ramdisk can be used in-place, use current ptr */ + if (img_data.ramdisk_addr == 0 || + img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) { + *rd_data = img_data.ramdisk_ptr; + } else { + ramdisk_ptr = img_data.ramdisk_addr; + *rd_data = ramdisk_ptr; + memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr, + img_data.ramdisk_size); + } } printf("RAM disk load addr 0x%08lx size %u KiB\n", - img_data.ramdisk_addr, DIV_ROUND_UP(img_data.ramdisk_size, 1024)); - - *rd_data = img_data.ramdisk_addr; + *rd_data, DIV_ROUND_UP(img_data.ramdisk_size, 1024)); *rd_len = img_data.ramdisk_size; return 0;