diff options
author | Sean Anderson | 2023-10-14 16:47:44 -0400 |
---|---|---|
committer | Tom Rini | 2023-10-17 20:50:52 -0400 |
commit | ab12179b3e9fa8a9c54f9cd5ad6b2c0c185a2191 (patch) | |
tree | 64b342311be8492d3d26897ff35da06b3ebff3d8 /common | |
parent | d401e0b264a21e94a96074ce66c5f8df275cccbe (diff) |
arm: imx: Check header before calling spl_load_imx_container
Make sure we have an IMX header before calling spl_load_imx_container,
since if we don't it will fail with -ENOENT. This allows us to fall back to
legacy/raw images if they are also enabled.
This is a functional change, one which likely should have been in place
from the start, but a functional change nonetheless. Previously, all
non-IMX8 images (except FITs without FIT_FULL) would be optimized out if
the only image load method enabled supported IMX8 images. With this change,
support for other image types now has an effect.
There are seven boards with SPL_LOAD_IMX_CONTAINER enabled: three with
SPL_BOOTROM_SUPPORT:
imx93_11x11_evk_ld imx93_11x11_evk imx8ulp_evk
and four with SPL_MMC:
deneb imx8qxp_mek giedi imx8qm_mek
All of these boards also have SPL_RAW_IMAGE_SUPPORT and
SPL_LEGACY_IMAGE_FORMAT enabled as well. However, none have FIT support
enabled. Of the six load methods affected by this patch, only SPL_MMC and
SPL_BOOTROM_SUPPORT are enabled with SPL_LOAD_IMX_CONTAINER.
spl_romapi_load_image_seekable does not support legacy or raw images, so
there is no growth. However, mmc_load_image_raw_sector does support loading
legacy/raw images. Since these images could not have been booted before, I
have disabled support for legacy/raw images on these four boards. This
reduces bloat from around 800 bytes to around 200.
There are no in-tree boards with SPL_LOAD_IMX_CONTAINER and AHAB_BOOT both
enabled, so we do not need to worry about potentially falling back to
legacy images in a secure boot scenario.
Future work could include merging imx_container.h with imx8image.h, since
they appear to define mostly the same structures.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/spl/spl_mmc.c | 4 | ||||
-rw-r--r-- | common/spl/spl_nand.c | 4 | ||||
-rw-r--r-- | common/spl/spl_nor.c | 4 | ||||
-rw-r--r-- | common/spl/spl_spi.c | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 02ad32a23e0..67c7ae34a58 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -16,6 +16,7 @@ #include <errno.h> #include <mmc.h> #include <image.h> +#include <imx_container.h> static int mmc_load_legacy(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, @@ -108,7 +109,8 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read; ret = spl_load_simple_fit(spl_image, &load, sector, header); - } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { + } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) && + valid_container_hdr((void *)header)) { struct spl_load_info load; load.dev = mmc; diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index 6cc34004f49..07916bedbb9 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -7,6 +7,7 @@ #include <config.h> #include <fdt_support.h> #include <image.h> +#include <imx_container.h> #include <log.h> #include <spl.h> #include <asm/io.h> @@ -99,7 +100,8 @@ 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_simple_fit(spl_image, &load, offset / bl_len, header); - } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { + } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) && + valid_container_hdr((void *)header)) { struct spl_load_info load; load.dev = NULL; diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index c141a9ae629..dd447982071 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -5,6 +5,7 @@ #include <common.h> #include <image.h> +#include <imx_container.h> #include <log.h> #include <spl.h> @@ -102,7 +103,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image, (void *)header); } #endif - if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { + if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) && + valid_container_hdr((void *)header)) { load.bl_len = 1; load.read = spl_nor_load_read; return spl_load_imx_container(spl_image, &load, diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index d69069a75bf..1427c9478c0 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -10,6 +10,7 @@ #include <common.h> #include <image.h> +#include <imx_container.h> #include <log.h> #include <spi.h> #include <spi_flash.h> @@ -153,7 +154,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, err = spl_load_simple_fit(spl_image, &load, payload_offs, header); - } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { + } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) && + valid_container_hdr((void *)header)) { struct spl_load_info load; load.dev = flash; |