
On 10/12/23 03:56, Sean Anderson wrote:
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.
Looking at CONFIG_AHAB_BOOT (related to secure boot) we must be sure that we don't introduce any unsolicited fallback on existing configurations.
Best regards
Heinrich
To avoid too much bloat, Legacy/Raw images are disabled for the four configs which only boot from raw MMC.
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
MAINTAINERS | 1 + arch/arm/include/asm/mach-imx/ahab.h | 2 +- arch/arm/mach-imx/cmd_dek.c | 4 ++-- arch/arm/mach-imx/ele_ahab.c | 2 +- arch/arm/mach-imx/image-container.c | 2 +- arch/arm/mach-imx/imx8/ahab.c | 2 +- arch/arm/mach-imx/parse-container.c | 2 +- arch/arm/mach-imx/spl_imx_romapi.c | 5 +++-- common/spl/spl_mmc.c | 4 +++- common/spl/spl_nand.c | 4 +++- common/spl/spl_nor.c | 4 +++- common/spl/spl_spi.c | 4 +++- configs/deneb_defconfig | 2 ++ configs/giedi_defconfig | 2 ++ configs/imx8qm_mek_defconfig | 2 ++ configs/imx8qxp_mek_defconfig | 2 ++ drivers/usb/gadget/f_sdp.c | 4 +++- .../include/asm/mach-imx/image.h => include/imx_container.h | 0 18 files changed, 34 insertions(+), 14 deletions(-) rename arch/arm/include/asm/mach-imx/image.h => include/imx_container.h (100%)
diff --git a/MAINTAINERS b/MAINTAINERS index 7d5d05320c0..35209e73af5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -300,6 +300,7 @@ F: arch/arm/include/asm/mach-imx/ F: board/freescale/*mx*/ F: board/freescale/common/ F: drivers/serial/serial_mxc.c +F: include/imx_container.h
ARM HISILICON M: Peter Griffin peter.griffin@linaro.org diff --git a/arch/arm/include/asm/mach-imx/ahab.h b/arch/arm/include/asm/mach-imx/ahab.h index 4222e3db278..4884f056251 100644 --- a/arch/arm/include/asm/mach-imx/ahab.h +++ b/arch/arm/include/asm/mach-imx/ahab.h @@ -6,7 +6,7 @@ #ifndef __IMX_AHAB_H__ #define __IMX_AHAB_H__
-#include <asm/mach-imx/image.h> +#include <imx_container.h>
int ahab_auth_cntr_hdr(struct container_hdr *container, u16 length); int ahab_auth_release(void); diff --git a/arch/arm/mach-imx/cmd_dek.c b/arch/arm/mach-imx/cmd_dek.c index 6fa5b41fcd3..2f389dbe8df 100644 --- a/arch/arm/mach-imx/cmd_dek.c +++ b/arch/arm/mach-imx/cmd_dek.c @@ -18,12 +18,12 @@ #include <mapmem.h> #include <tee.h> #ifdef CONFIG_IMX_SECO_DEK_ENCAP +#include <imx_container.h> #include <firmware/imx/sci/sci.h> -#include <asm/mach-imx/image.h> #endif #ifdef CONFIG_IMX_ELE_DEK_ENCAP +#include <imx_container.h> #include <asm/mach-imx/ele_api.h> -#include <asm/mach-imx/image.h> #endif
#include <cpu_func.h> diff --git a/arch/arm/mach-imx/ele_ahab.c b/arch/arm/mach-imx/ele_ahab.c index 6a1ad198f89..295c055ad0a 100644 --- a/arch/arm/mach-imx/ele_ahab.c +++ b/arch/arm/mach-imx/ele_ahab.c @@ -6,12 +6,12 @@ #include <common.h> #include <command.h> #include <errno.h> +#include <imx_container.h> #include <asm/io.h> #include <asm/mach-imx/ele_api.h> #include <asm/mach-imx/sys_proto.h> #include <asm/arch-imx/cpu.h> #include <asm/arch/sys_proto.h> -#include <asm/mach-imx/image.h> #include <console.h> #include <cpu_func.h> #include <asm/global_data.h> diff --git a/arch/arm/mach-imx/image-container.c b/arch/arm/mach-imx/image-container.c index eff9e0c4597..ebc8021d7cc 100644 --- a/arch/arm/mach-imx/image-container.c +++ b/arch/arm/mach-imx/image-container.c @@ -5,6 +5,7 @@
#include <common.h> #include <errno.h> +#include <imx_container.h> #include <log.h> #include <malloc.h> #include <asm/io.h> @@ -12,7 +13,6 @@ #include <spi_flash.h> #include <spl.h> #include <nand.h> -#include <asm/mach-imx/image.h> #include <asm/arch/sys_proto.h> #include <asm/mach-imx/boot_mode.h>
diff --git a/arch/arm/mach-imx/imx8/ahab.c b/arch/arm/mach-imx/imx8/ahab.c index 44ea63584aa..994becccefd 100644 --- a/arch/arm/mach-imx/imx8/ahab.c +++ b/arch/arm/mach-imx/imx8/ahab.c @@ -6,6 +6,7 @@ #include <common.h> #include <command.h> #include <errno.h> +#include <imx_container.h> #include <log.h> #include <asm/global_data.h> #include <asm/io.h> @@ -13,7 +14,6 @@ #include <asm/mach-imx/sys_proto.h> #include <asm/arch-imx/cpu.h> #include <asm/arch/sys_proto.h> -#include <asm/mach-imx/image.h> #include <console.h> #include <cpu_func.h> #include "u-boot/sha256.h" diff --git a/arch/arm/mach-imx/parse-container.c b/arch/arm/mach-imx/parse-container.c index 0a3d41f411e..126ab7c57a1 100644 --- a/arch/arm/mach-imx/parse-container.c +++ b/arch/arm/mach-imx/parse-container.c @@ -6,9 +6,9 @@ #include <common.h> #include <stdlib.h> #include <errno.h> +#include <imx_container.h> #include <log.h> #include <spl.h> -#include <asm/mach-imx/image.h> #ifdef CONFIG_AHAB_BOOT #include <asm/mach-imx/ahab.h> #endif diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index b51061b987b..8816566b364 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -6,11 +6,11 @@ #include <common.h> #include <errno.h> #include <image.h> +#include <imx_container.h> #include <log.h> #include <asm/global_data.h> #include <linux/libfdt.h> #include <spl.h> -#include <asm/mach-imx/image.h> #include <asm/arch/sys_proto.h>
DECLARE_GLOBAL_DATA_PTR; @@ -111,7 +111,8 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, load.read = spl_romapi_read_seekable; load.priv = &pagesize; return spl_load_simple_fit(spl_image, &load, offset / pagesize, 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;
memset(&load, 0, sizeof(load));
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) &&
load.bl_len = 1; load.read = spl_nor_load_read; return spl_load_imx_container(spl_image, &load,valid_container_hdr((void *)header)) {
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;
diff --git a/configs/deneb_defconfig b/configs/deneb_defconfig index 82869e4e0f9..ee2478aa0bb 100644 --- a/configs/deneb_defconfig +++ b/configs/deneb_defconfig @@ -44,6 +44,8 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x128000 CONFIG_SPL_BSS_MAX_SIZE=0x1000 CONFIG_SPL_BOARD_INIT=y +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set +# CONFIG_SPL_LEGACY_IMAGE_FORMAT is not set CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_SYS_MALLOC=y diff --git a/configs/giedi_defconfig b/configs/giedi_defconfig index b56b736c436..5e403c90c8c 100644 --- a/configs/giedi_defconfig +++ b/configs/giedi_defconfig @@ -44,6 +44,8 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x128000 CONFIG_SPL_BSS_MAX_SIZE=0x1000 CONFIG_SPL_BOARD_INIT=y +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set +# CONFIG_SPL_LEGACY_IMAGE_FORMAT is not set CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_SYS_MALLOC=y diff --git a/configs/imx8qm_mek_defconfig b/configs/imx8qm_mek_defconfig index b9083b0453f..4c5206306ee 100644 --- a/configs/imx8qm_mek_defconfig +++ b/configs/imx8qm_mek_defconfig @@ -38,6 +38,8 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x128000 CONFIG_SPL_BSS_MAX_SIZE=0x1000 CONFIG_SPL_BOARD_INIT=y +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set +# CONFIG_SPL_LEGACY_IMAGE_FORMAT is not set CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_SYS_MALLOC=y diff --git a/configs/imx8qxp_mek_defconfig b/configs/imx8qxp_mek_defconfig index f516b0b5557..f312d3945fb 100644 --- a/configs/imx8qxp_mek_defconfig +++ b/configs/imx8qxp_mek_defconfig @@ -38,6 +38,8 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x128000 CONFIG_SPL_BSS_MAX_SIZE=0x1000 CONFIG_SPL_BOARD_INIT=y +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set +# CONFIG_SPL_LEGACY_IMAGE_FORMAT is not set CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_SYS_MALLOC=y diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c index 2b3a9c5fd4c..ee9384fb37e 100644 --- a/drivers/usb/gadget/f_sdp.c +++ b/drivers/usb/gadget/f_sdp.c @@ -34,6 +34,7 @@ #include <spl.h> #include <image.h> #include <imximage.h> +#include <imx_container.h> #include <watchdog.h>
#define HID_REPORT_ID_MASK 0x000000ff @@ -852,7 +853,8 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image, return SDP_EXIT; } #endif
if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
valid_container_hdr((void *)header)) { struct spl_load_info load; load.dev = header;
diff --git a/arch/arm/include/asm/mach-imx/image.h b/include/imx_container.h similarity index 100% rename from arch/arm/include/asm/mach-imx/image.h rename to include/imx_container.h