diff mbox series

[U-Boot] Support boot Android image without address on bootm command

Message ID 20190222082806.4169-1-shawn.guo@linaro.org
State Accepted
Commit 5e218862b78068e32955e5b17b8dbbc941d71054
Delegated to: Tom Rini
Headers show
Series [U-Boot] Support boot Android image without address on bootm command | expand

Commit Message

Shawn Guo Feb. 22, 2019, 8:28 a.m. UTC
It works perfectly fine to boot an Android boot.img with bootm command
followed by an explicit address argument that holds the image.  But if
we have boot.img downloaded into default 'loadaddr', and then boot it
using bootm command without the address argument, we will run into
problem, because U-Boot fails to find ramdisk and fdt (second area) in
boot.img.

The current Android image support assumes there is always an address
argument on bootm command.  However just like booting any other images,
'loadaddr' should be used when address argument is missing from bootm
command.  It patches boot_get_ramdisk() and boot_get_fdt() a bit to
support this quite common usage of bootm command for Android image.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 common/image-fdt.c | 2 +-
 common/image.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Feb. 22, 2019, 1:56 p.m. UTC | #1
On Fri, Feb 22, 2019 at 04:28:06PM +0800, Shawn Guo wrote:

> It works perfectly fine to boot an Android boot.img with bootm command
> followed by an explicit address argument that holds the image.  But if
> we have boot.img downloaded into default 'loadaddr', and then boot it
> using bootm command without the address argument, we will run into
> problem, because U-Boot fails to find ramdisk and fdt (second area) in
> boot.img.
> 
> The current Android image support assumes there is always an address
> argument on bootm command.  However just like booting any other images,
> 'loadaddr' should be used when address argument is missing from bootm
> command.  It patches boot_get_ramdisk() and boot_get_fdt() a bit to
> support this quite common usage of bootm command for Android image.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini April 24, 2019, 1:22 p.m. UTC | #2
On Fri, Feb 22, 2019 at 04:28:06PM +0800, Shawn Guo wrote:

> It works perfectly fine to boot an Android boot.img with bootm command
> followed by an explicit address argument that holds the image.  But if
> we have boot.img downloaded into default 'loadaddr', and then boot it
> using bootm command without the address argument, we will run into
> problem, because U-Boot fails to find ramdisk and fdt (second area) in
> boot.img.
> 
> The current Android image support assumes there is always an address
> argument on bootm command.  However just like booting any other images,
> 'loadaddr' should be used when address argument is missing from bootm
> command.  It patches boot_get_ramdisk() and boot_get_fdt() a bit to
> support this quite common usage of bootm command for Android image.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/image-fdt.c b/common/image-fdt.c
index 57f150311392..8009932f1405 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -246,7 +246,7 @@  int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 	*of_flat_tree = NULL;
 	*of_size = 0;
 
-	img_addr = simple_strtoul(argv[0], NULL, 16);
+	img_addr = (argc == 0) ? load_addr : simple_strtoul(argv[0], NULL, 16);
 	buf = map_sysmem(img_addr, 0);
 
 	if (argc > 2)
diff --git a/common/image.c b/common/image.c
index 4d4248f234fb..75b84d50091d 100644
--- a/common/image.c
+++ b/common/image.c
@@ -957,7 +957,7 @@  int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 	 */
 	buf = map_sysmem(images->os.start, 0);
 	if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
-		select = argv[0];
+		select = (argc == 0) ? env_get("loadaddr") : argv[0];
 #endif
 
 	if (argc >= 2)