From 5e218862b78068e32955e5b17b8dbbc941d71054 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Fri, 22 Feb 2019 16:28:06 +0800 Subject: Support boot Android image without address on bootm command 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 Reviewed-by: Tom Rini --- common/image-fdt.c | 2 +- common/image.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/image-fdt.c b/common/image-fdt.c index 01186aeac7a..9ed00b7d5bf 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -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) diff --git a/common/image.c b/common/image.c index 4d4248f234f..75b84d50091 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) -- cgit v1.2.3 From 35c7527eb9884e2a1c6911cf524639c6e5b91c98 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 6 Mar 2019 15:52:27 +0200 Subject: fit: load all fragments from the extra configurations Currently only the first fdt is loaded from the extra configuration of FIT image. If the configuration have multiple fdt, load them all as well. Signed-off-by: Peter Ujfalusi Reviewed-by: Lokesh Vutla --- common/image-fit.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common') diff --git a/common/image-fit.c b/common/image-fit.c index ac901e131ca..a74b44f2982 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -2118,6 +2118,18 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr, if (next_config) *next_config++ = '\0'; uname = NULL; + + /* + * fit_image_load() would load the first FDT from the + * extra config only when uconfig is specified. + * Check if the extra config contains multiple FDTs and + * if so, load them. + */ + cfg_noffset = fit_conf_get_node(fit, uconfig); + + i = 0; + count = fit_conf_get_prop_node_count(fit, cfg_noffset, + FIT_FDT_PROP); } debug("%d: using uname=%s uconfig=%s\n", i, uname, uconfig); -- cgit v1.2.3 From 792dd5709144278d5e314f7010578c2947719a1f Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 6 Mar 2019 22:04:31 +0100 Subject: spl: ymodem: Add support for loading full fitImages Add support for loading fully featured fitImages over YModem in SPL. This is useful when various advanced features of full fitImages are needed in SPL. Signed-off-by: Marek Vasut Cc: Tom Rini --- common/spl/spl_ymodem.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index 25226e9a335..fa539ecd7af 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -89,7 +89,25 @@ static int spl_ymodem_load_image(struct spl_image_info *spl_image, if (res <= 0) goto end_stream; - if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) && + image_get_magic((struct image_header *)buf) == FDT_MAGIC) { + addr = CONFIG_SYS_LOAD_ADDR; + ih = (struct image_header *)addr; + + memcpy((void *)addr, buf, res); + size += res; + addr += res; + + while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) { + memcpy((void *)addr, buf, res); + size += res; + addr += res; + } + + ret = spl_parse_image_header(spl_image, ih); + if (ret) + return ret; + } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && image_get_magic((struct image_header *)buf) == FDT_MAGIC) { struct spl_load_info load; struct ymodem_fit_info info; -- cgit v1.2.3 From 443b3ce5cf00995a12e0dcaab6d4963daefe511e Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 26 Mar 2019 13:04:00 +0100 Subject: spl: spl_nand.c: Add NAND loading message This patch adds a short message to the SPL NAND loader, which displays the source and destinations addresses including the size of the loaded image, like this: U-Boot SPL 2019.04-rc3-00113-g486efd8aaf (Mar 15 2019 - 14:18:02 +0100) Trying to boot from NAND Loading U-Boot from 0x00040000 (size 0x000a0000) to 0x22900000 I find this message quite helpful - hopefully others do so as well. Signed-off-by: Stefan Roese Cc: Heiko Schocher Cc: Tom Rini Reviewed-by: Tom Rini --- common/spl/spl_nand.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'common') diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index 6eb190f1ea5..e2bcefb111e 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -17,6 +17,10 @@ static int spl_nand_load_image(struct spl_image_info *spl_image, { nand_init(); + printf("Loading U-Boot from 0x%08x (size 0x%08x) to 0x%08x\n", + CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE, + CONFIG_SYS_NAND_U_BOOT_DST); + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE, (void *)CONFIG_SYS_NAND_U_BOOT_DST); -- cgit v1.2.3 From 4c6be01c2719e78cd7ff257dd65a666623566863 Mon Sep 17 00:00:00 2001 From: Andreas Dannenberg Date: Wed, 27 Mar 2019 13:17:26 -0500 Subject: malloc: Fix memalign not honoring alignment prior to full malloc init When using memalign() in a scenario where U-Boot is configured for full malloc support with simple malloc not explicitly enabled and before the full malloc support is initialized, a memory block is being allocated and returned without the alignment parameter getting honored. Fix this issue by replacing the existing memalign pre-full malloc init logic with a call to memalign_simple() this way ensuring proper alignment of the returned memory block. Fixes: ee038c58d519 ("malloc: Use malloc simple before malloc is fully initialized in memalign()") Signed-off-by: Andreas Dannenberg Reviewed-by: Lokesh Vutla --- common/dlmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'common') diff --git a/common/dlmalloc.c b/common/dlmalloc.c index edaad299bbb..6f12a18d549 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1893,8 +1893,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes; #if CONFIG_VAL(SYS_MALLOC_F_LEN) if (!(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { - nb = roundup(bytes, alignment); - return malloc_simple(nb); + return memalign_simple(alignment, bytes); } #endif -- cgit v1.2.3 From b4353b371322b54d8effd8737e3f7ba021950180 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Wed, 27 Mar 2019 23:50:09 +0000 Subject: bootm: Simplying cache flush code The cache flush of the kernel load area needs to be aligned outward to the DMA cache alignment. The operations are simpler if we think of this as aligning the start down, ALIGN_DOWN(load, ARCH_DMA_MINALIGN), and aligning the end up, ALIGN(load_end, ARCH_DMA_MINALIGN), and then find the length of the flushed region by subtracting the former from the latter. Cc: Tom Rini Cc: Simon Glass Cc: Bryan O'Donoghue Signed-off-by: Trent Piepho Reviewed-by: Simon Glass --- common/bootm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'common') diff --git a/common/bootm.c b/common/bootm.c index 3adbceaa38e..42358b81fc9 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -450,7 +450,6 @@ static int bootm_load_os(bootm_headers_t *images, int boot_progress) ulong image_start = os.image_start; ulong image_len = os.image_len; ulong flush_start = ALIGN_DOWN(load, ARCH_DMA_MINALIGN); - ulong flush_len; bool no_overlap; void *load_buf, *image_buf; int err; @@ -465,11 +464,7 @@ static int bootm_load_os(bootm_headers_t *images, int boot_progress) return err; } - flush_len = load_end - load; - if (flush_start < load) - flush_len += load - flush_start; - - flush_cache(flush_start, ALIGN(flush_len, ARCH_DMA_MINALIGN)); + flush_cache(flush_start, ALIGN(load_end, ARCH_DMA_MINALIGN) - flush_start); debug(" kernel loaded at 0x%08lx, end = 0x%08lx\n", load, load_end); bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED); -- cgit v1.2.3 From 829ceb28215a1b6178bf690182def5ad56842f49 Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Mon, 8 Apr 2019 17:35:27 +0200 Subject: image: android: allow booting lz4-compressed kernels According to Android image format [1], kernel image resides at 1 page offset from the boot image address. Grab the magic number from there and allow U-Boot to handle LZ4-compressed KNL binaries instead of hardcoding compression type to IH_COMP_NONE. Other compression types, if needed, can be added later. Tested on H3ULCB-KF using the image detailed in [2]. [1] Excerpt from include/android_image.h +-----------------+ | boot header | 1 page +-----------------+ | kernel | n pages +-----------------+ | ramdisk | m pages +-----------------+ | second stage | o pages +-----------------+ [2] => iminfo 4c000000 ## Checking Image at 4c000000 ... Android image found kernel size: 85b9d1 kernel address: 48080000 ramdisk size: 54ddbc ramdisk addrress: 4a180000 second size: 0 second address: 48000800 tags address: 48000100 page size: 800 os_version: 1200012a (ver: 0.9.0, level: 2018.10) name: cmdline: buildvariant=userdebug Signed-off-by: Eugeniu Rosca --- common/bootm.c | 2 +- common/image-android.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/bootm.c b/common/bootm.c index 42358b81fc9..b5d37d38db8 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -154,7 +154,7 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc, #ifdef CONFIG_ANDROID_BOOT_IMAGE case IMAGE_FORMAT_ANDROID: images.os.type = IH_TYPE_KERNEL; - images.os.comp = IH_COMP_NONE; + images.os.comp = android_image_get_kcomp(os_hdr); images.os.os = IH_OS_LINUX; images.os.end = android_image_get_end(os_hdr); diff --git a/common/image-android.c b/common/image-android.c index 2f38c191e91..c31dcd44652 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -8,6 +8,7 @@ #include #include #include +#include #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000 @@ -126,6 +127,16 @@ ulong android_image_get_kload(const struct andr_img_hdr *hdr) return android_image_get_kernel_addr(hdr); } +ulong android_image_get_kcomp(const struct andr_img_hdr *hdr) +{ + const void *p = (void *)((uintptr_t)hdr + hdr->page_size); + + if (get_unaligned_le32(p) == LZ4F_MAGIC) + return IH_COMP_LZ4; + else + return IH_COMP_NONE; +} + int android_image_get_ramdisk(const struct andr_img_hdr *hdr, ulong *rd_data, ulong *rd_len) { -- cgit v1.2.3 From 74a7e0018a97a0e7318c4c7a3b473fd9ebbb5ad1 Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Mon, 8 Apr 2019 17:35:28 +0200 Subject: image: android: fix 'iminfo' typo Fix below CP warning triggered by the 'iminfo' output in another patch: WARNING: 'addrress' may be misspelled - perhaps 'address'? Fixes: 4f1318b29c7a20 ("common: image: minimal android image iminfo support") Signed-off-by: Eugeniu Rosca Acked-by: Marek Vasut --- common/image-android.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/image-android.c b/common/image-android.c index c31dcd44652..8b0f6b3b8ba 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -197,7 +197,7 @@ void android_print_contents(const struct andr_img_hdr *hdr) printf("%skernel size: %x\n", p, hdr->kernel_size); printf("%skernel address: %x\n", p, hdr->kernel_addr); printf("%sramdisk size: %x\n", p, hdr->ramdisk_size); - printf("%sramdisk addrress: %x\n", p, hdr->ramdisk_addr); + printf("%sramdisk address: %x\n", p, hdr->ramdisk_addr); printf("%ssecond size: %x\n", p, hdr->second_size); printf("%ssecond address: %x\n", p, hdr->second_addr); printf("%stags address: %x\n", p, hdr->tags_addr); -- cgit v1.2.3