spl: fit: support load multiple backup of images
Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: I29bce60f1b958baedbd2b45e86a611b89547c0d8
This commit is contained in:
parent
36c668870e
commit
22c7c1a827
14
Kconfig
14
Kconfig
|
|
@ -333,6 +333,20 @@ config SPL_FIT_HW_CRYPTO
|
|||
help
|
||||
Enable SPL hardware crypto for FIT image checksum and rsa verify.
|
||||
|
||||
config SPL_FIT_IMAGE_KB
|
||||
int "SPL FIT image size in KiB"
|
||||
depends on SPL_FIT
|
||||
default 2048
|
||||
help
|
||||
SPL FIT image size in KiB.
|
||||
|
||||
config SPL_FIT_IMAGE_MULTIPLE
|
||||
int "SPL FIT image multiple number"
|
||||
depends on SPL_FIT
|
||||
default 1
|
||||
help
|
||||
SPL FIT image multiple number.
|
||||
|
||||
config SPL_SYS_DCACHE_OFF
|
||||
bool "Disable SPL dcache"
|
||||
default y
|
||||
|
|
|
|||
|
|
@ -71,8 +71,14 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
|
|||
if (err <= 0)
|
||||
goto end;
|
||||
|
||||
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
|
||||
if ((IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) ||
|
||||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
|
||||
#else
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
#endif
|
||||
struct spl_load_info load;
|
||||
|
||||
debug("Found FIT\n");
|
||||
|
|
|
|||
|
|
@ -342,8 +342,9 @@ static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
|
|||
#endif
|
||||
}
|
||||
|
||||
int spl_load_simple_fit(struct spl_image_info *spl_image,
|
||||
struct spl_load_info *info, ulong sector, void *fit)
|
||||
static int spl_internal_load_simple_fit(struct spl_image_info *spl_image,
|
||||
struct spl_load_info *info,
|
||||
ulong sector, void *fit)
|
||||
{
|
||||
int sectors;
|
||||
ulong size;
|
||||
|
|
@ -528,3 +529,34 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spl_load_simple_fit(struct spl_image_info *spl_image,
|
||||
struct spl_load_info *info, ulong sector, void *fit)
|
||||
{
|
||||
ulong sector_offs = sector;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_SPL_FIT_IMAGE_MULTIPLE; i++) {
|
||||
if (i > 0) {
|
||||
sector_offs +=
|
||||
i * ((CONFIG_SPL_FIT_IMAGE_KB << 10) / info->bl_len);
|
||||
printf("Trying fit image at 0x%lx sector\n", sector_offs);
|
||||
if (info->read(info, sector_offs, 1, fit) != 1) {
|
||||
printf("IO error\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (image_get_magic(fit) != FDT_MAGIC) {
|
||||
printf("Bad fit magic\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spl_internal_load_simple_fit(spl_image, info,
|
||||
sector_offs, fit))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,8 +103,14 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
|
|||
goto end;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
|
||||
if ((IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) ||
|
||||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
|
||||
#else
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
#endif
|
||||
struct spl_load_info load;
|
||||
|
||||
debug("Found FIT\n");
|
||||
|
|
|
|||
|
|
@ -85,8 +85,14 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
|
||||
if ((IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) ||
|
||||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
|
||||
#else
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
#endif
|
||||
struct spl_load_info load;
|
||||
|
||||
debug("Found FIT\n");
|
||||
|
|
|
|||
|
|
@ -47,8 +47,14 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
|
|||
return rv;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
|
||||
if ((IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) ||
|
||||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
|
||||
#else
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
#endif
|
||||
struct spl_load_info load;
|
||||
|
||||
debug("Found FIT\n");
|
||||
|
|
|
|||
|
|
@ -39,8 +39,14 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
|
|||
spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
|
||||
if ((IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) ||
|
||||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
|
||||
#else
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
#endif
|
||||
struct spl_load_info load;
|
||||
|
||||
debug("Found FIT\n");
|
||||
|
|
|
|||
|
|
@ -113,8 +113,14 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
|
||||
if ((IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) ||
|
||||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
|
||||
#else
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
#endif
|
||||
struct spl_load_info load;
|
||||
|
||||
debug("Found FIT\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue