Support boot Android image without address on bootm command
authorShawn Guo <shawn.guo@linaro.org>
Fri, 22 Feb 2019 08:28:06 +0000 (16:28 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 22 Apr 2019 22:13:22 +0000 (18:13 -0400)
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>
common/image-fdt.c
common/image.c

index 01186aeac7a433a35f888b3fa227712fb6dbab80..9ed00b7d5bfb9e47db3dbafbf5d1989b32c15bf6 100644 (file)
@@ -284,7 +284,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)
index 4d4248f234fb2ef11d4e152b1d11a0ad9a644c58..75b84d50091d1fa435c9cca1b18bce58fb620da8 100644 (file)
@@ -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)