U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: George Chan via B4 Relay <devnull+gchan9527.gmail.com@kernel.org>
To: Tom Rini <trini@konsulko.com>,
	 Mattijs Korpershoek <mkorpershoek@kernel.org>,
	 Simon Glass <sjg@chromium.org>,
	Casey Connolly <casey.connolly@linaro.org>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	 Sumit Garg <sumit.garg@kernel.org>
Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io,
	 George Chan <gchan9527@gmail.com>
Subject: [PATCH 1/3] boot/image-android.c: Workaround androidboot kernel/ramdisk addr
Date: Sun, 27 Apr 2025 19:25:20 +0800	[thread overview]
Message-ID: <20250427-android-boot-v1-1-bb6b37c9c9f1@gmail.com> (raw)
In-Reply-To: <20250427-android-boot-v1-0-bb6b37c9c9f1@gmail.com>

From: George Chan <gchan9527@gmail.com>

Some vendor bootloader ignored kernel/ramdisk addr and use
their own addr. Even those addr are pointing to out-of-reach
memory block at 0, and available address start at 0x80000000.

So we also need to use our own available addr for loadaddr.

Signed-off-by: George Chan <gchan9527@gmail.com>
---
 boot/image-android.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/boot/image-android.c b/boot/image-android.c
index 1746b018900..36822d788b0 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -12,6 +12,7 @@
 #include <asm/unaligned.h>
 #include <mapmem.h>
 #include <linux/libfdt.h>
+#include <dm/of.h>
 
 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR	0x10008000
 #define ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR	0x11000000
@@ -281,6 +282,13 @@ static ulong android_image_get_kernel_addr(struct andr_image_data *img_data,
 	if (img_data->kernel_addr == 0 && img_data->ramdisk_addr == 0)
 		return env_get_ulong("kernel_addr_r", 16, 0);
 
+	/*
+	 * Some vendor bootloader ignore kernel and ramdisk address also
+	 * default value are out of physical mem base... so we use ours.
+	 */
+	if (img_data->kernel_addr < gd->ram_base)
+		return env_get_ulong("kernel_addr_r", 16, 0);
+
 	return img_data->kernel_addr;
 }
 
@@ -490,6 +498,8 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
 		if (img_data.ramdisk_addr == 0 ||
 		    img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
 			*rd_data = img_data.ramdisk_ptr;
+		} else if (img_data.ramdisk_addr < gd->ram_base) {
+                        *rd_data = img_data.ramdisk_ptr;
 		} else {
 			ramdisk_ptr = img_data.ramdisk_addr;
 			*rd_data = ramdisk_ptr;

-- 
2.43.0



  reply	other threads:[~2025-04-27 12:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-27 11:25 [PATCH 0/3] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay
2025-04-27 11:25 ` George Chan via B4 Relay [this message]
2025-04-27 11:25 ` [PATCH 2/3] boot/bootmeth-android.c: Reuse fastboot memory block for unzip kernel George Chan via B4 Relay
2025-04-27 11:25 ` [PATCH 3/3] mach-snapdragon: Add support to append string to kernel cmdline George Chan via B4 Relay
2025-04-28 13:53 ` [PATCH 0/3] u-boot chain-loading LineageOS bootimg Casey Connolly
2025-04-29  4:04   ` george chan
2025-04-29  8:30   ` Mattijs Korpershoek
2025-04-30  3:58     ` george chan
2025-04-30 12:03       ` Mattijs Korpershoek
2025-04-30 15:13         ` george chan

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=20250427-android-boot-v1-1-bb6b37c9c9f1@gmail.com \
    --to=devnull+gchan9527.gmail.com@kernel.org \
    --cc=casey.connolly@linaro.org \
    --cc=gchan9527@gmail.com \
    --cc=mkorpershoek@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@kernel.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.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