Skip to content

Commit 4620e8a

Browse files
hackpascaldanielschwierzeck
authored andcommitted
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 <[email protected]> Signed-off-by: Weijie Gao <[email protected]>
1 parent fdc03bf commit 4620e8a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

common/spl/spl_nand.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
5656
return size / load->bl_len;
5757
}
5858

59+
static ulong spl_nand_legacy_read(struct spl_load_info *load, ulong offs,
60+
ulong size, void *dst)
61+
{
62+
int err;
63+
64+
debug("%s: offs %lx, size %lx, dst %p\n",
65+
__func__, offs, size, dst);
66+
67+
err = nand_spl_load_image(offs, size, dst);
68+
if (err)
69+
return 0;
70+
71+
return size;
72+
}
73+
5974
struct mtd_info * __weak nand_get_mtd(void)
6075
{
6176
return NULL;
@@ -93,6 +108,18 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
93108
load.bl_len = bl_len;
94109
load.read = spl_nand_fit_read;
95110
return spl_load_imx_container(spl_image, &load, offset / bl_len);
111+
} else if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT) &&
112+
image_get_magic(header) == IH_MAGIC) {
113+
struct spl_load_info load;
114+
115+
debug("Found legacy image\n");
116+
load.dev = NULL;
117+
load.priv = NULL;
118+
load.filename = NULL;
119+
load.bl_len = 1;
120+
load.read = spl_nand_legacy_read;
121+
122+
return spl_load_legacy_img(spl_image, bootdev, &load, offset);
96123
} else {
97124
err = spl_parse_image_header(spl_image, bootdev, header);
98125
if (err)

0 commit comments

Comments
 (0)