[PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

Sean Anderson seanga2 at gmail.com
Mon Oct 31 15:21:00 CET 2022


On 10/31/22 10:13, Marc Kleine-Budde wrote:
> If the user select the image type "flat_dt" a FIT image will be build.
> This breaks the legacy use case of putting a Flat Device Tree into a
> legacy u-boot image.
> 
> Add command line options "-L" and "--legacy" to let the user force the
> creation of a legacy u-boot image, even if "flat_dt" is selected.
> 
> Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofgnhm@pengutronix.de
> Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
> ---
>   tools/default_image.c | 1 +
>   tools/fit_common.c    | 3 +++
>   tools/mkimage.c       | 7 ++++++-
>   3 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/default_image.c b/tools/default_image.c
> index 9a6b50a946ba..3673eaa63de2 100644
> --- a/tools/default_image.c
> +++ b/tools/default_image.c
> @@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
>   static int image_check_image_types(uint8_t type, bool legacy)
>   {
>   	if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
> +	    ((type == IH_TYPE_FLATDT) && legacy) ||
>   	    (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
>   		return EXIT_SUCCESS;
>   	else
> diff --git a/tools/fit_common.c b/tools/fit_common.c
> index b4aa89b53577..eba13a789a72 100644
> --- a/tools/fit_common.c
> +++ b/tools/fit_common.c
> @@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
>   
>   int fit_check_image_types(uint8_t type, bool legacy)
>   {
> +	if (legacy)
> +		return EXIT_FAILURE;
> +
>   	if (type == IH_TYPE_FLATDT)
>   		return EXIT_SUCCESS;
>   	else
> diff --git a/tools/mkimage.c b/tools/mkimage.c
> index 6d029afab3a8..9e9edd65583e 100644
> --- a/tools/mkimage.c
> +++ b/tools/mkimage.c
> @@ -91,6 +91,7 @@ static void usage(const char *msg)
>   	fprintf(stderr,
>   		"       %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
>   		"          -A ==> set architecture to 'arch'\n"
> +		"          -L ==> force legacy image\n"
>   		"          -O ==> set operating system to 'os'\n"
>   		"          -T ==> set image type to 'type'\n"
>   		"          -C ==> set compression type 'comp'\n"
> @@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
>   }
>   
>   static const char optstring[] =
> -	"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
> +	"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
>   
>   static const struct option longopts[] = {
>   	{ "load-address", required_argument, NULL, 'a' },
> @@ -181,6 +182,7 @@ static const struct option longopts[] = {
>   	{ "key-dir", required_argument, NULL, 'k' },
>   	{ "key-dest", required_argument, NULL, 'K' },
>   	{ "list", no_argument, NULL, 'l' },
> +	{ "legacy", no_argument, NULL, 'L' },
>   	{ "config", required_argument, NULL, 'n' },
>   	{ "engine", required_argument, NULL, 'N' },
>   	{ "algo", required_argument, NULL, 'o' },
> @@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
>   		case 'l':
>   			params.lflag = 1;
>   			break;
> +		case 'L':
> +			params.Lflag = 1;
> +			break;
>   		case 'n':
>   			params.imagename = optarg;
>   			break;

Please add some documentation to the man page (doc/mkimage.1). And also consider not using a short option.

--Sean


More information about the U-Boot mailing list