diff options
author | Weijie Gao <weijie.gao@mediatek.com> | 2022-05-20 11:24:04 +0800 |
---|---|---|
committer | Daniel Schwierzeck <daniel.schwierzeck@gmail.com> | 2022-07-13 23:03:37 +0200 |
commit | 4620e8aabc1431f2de3f4f5c1b22d4bc599e57b6 (patch) | |
tree | 4b50a81140acba1d548efbb369682f85af509ab0 /common | |
parent | fdc03bf4e9342b2ccc553021554270624852cf84 (diff) | |
download | u-boot-4620e8aabc1431f2de3f4f5c1b22d4bc599e57b6.zip u-boot-4620e8aabc1431f2de3f4f5c1b22d4bc599e57b6.tar.gz u-boot-4620e8aabc1431f2de3f4f5c1b22d4bc599e57b6.tar.bz2 |
spl: nand: support loading legacy image with payload compressed
Add support to load legacy image with payload compressed. This redirects
the boot flow for all legacy images. If the payload is not compressed, the
actual behavior will remain unchanged.
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/spl/spl_nand.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index 82a10ff..7b7579a 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -56,6 +56,21 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs, return size / load->bl_len; } +static ulong spl_nand_legacy_read(struct spl_load_info *load, ulong offs, + ulong size, void *dst) +{ + int err; + + debug("%s: offs %lx, size %lx, dst %p\n", + __func__, offs, size, dst); + + err = nand_spl_load_image(offs, size, dst); + if (err) + return 0; + + return size; +} + struct mtd_info * __weak nand_get_mtd(void) { return NULL; @@ -93,6 +108,18 @@ static int spl_nand_load_element(struct spl_image_info *spl_image, load.bl_len = bl_len; load.read = spl_nand_fit_read; return spl_load_imx_container(spl_image, &load, offset / bl_len); + } else if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT) && + image_get_magic(header) == IH_MAGIC) { + struct spl_load_info load; + + debug("Found legacy image\n"); + load.dev = NULL; + load.priv = NULL; + load.filename = NULL; + load.bl_len = 1; + load.read = spl_nand_legacy_read; + + return spl_load_legacy_img(spl_image, bootdev, &load, offset); } else { err = spl_parse_image_header(spl_image, bootdev, header); if (err) |