[PATCH v3] cmd: bootm: add ELF file support
Quentin Schulz
quentin.schulz at theobroma-systems.com
Thu Apr 11 10:42:43 CEST 2024
Hi Maxim,
On 4/11/24 10:32, Maxim Moskalets wrote:
> From: Maxim Moskalets <maximmosk4 at gmail.com>
>
> Some operating systems (e.g. seL4) and embedded applications are ELF
> images. It is convenient to use FIT-images to implement trusted boot.
> Added "elf" image type for booting using bootm command.
>
> Signed-off-by: Maxim Moskalets <maximmosk4 at gmail.com>
> ---
> boot/bootm_os.c | 24 ++++++++++++++++++++++++
> boot/image-fit.c | 3 ++-
> boot/image.c | 3 +++
> include/image.h | 1 +
> 4 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/boot/bootm_os.c b/boot/bootm_os.c
> index ccde72d22c..1c92b8149c 100644
> --- a/boot/bootm_os.c
> +++ b/boot/bootm_os.c
> @@ -395,6 +395,27 @@ static int do_bootm_qnxelf(int flag, struct bootm_info *bmi)
> }
> #endif
>
> +#if defined(CONFIG_CMD_ELF)
> +static int do_bootm_elf(int flag, struct bootm_info *bmi)
> +{
> + struct bootm_headers *images = bmi->images;
> + char *local_args[2] = {NULL};
> + char str[19] = ""; /* "0x" + 16 digits + "\0" */
> +
> + if (flag != BOOTM_STATE_OS_GO)
> + return 0;
> +
> + snprintf(str, sizeof str, "0x%lx", images->ep); /* write entry-point into string */
While sizeof str does return the same as the number of elements in the
array, it's only because it's a char array and thus its elements are all
1B, any other type would have returned something incorrect.
I recommend using ARRAY_SIZE(str) instead, which is the way to know the
number of elements in the array (dividing the size of the array by the
size of an element in the array).
Cheers,
Quentin
More information about the U-Boot
mailing list