Hi Alexey,
On 2026-07-13T10:02:41, Alexey Charkov <[email protected]> wrote:
> rockchip: mkimage: Add support for up to 4 input files
>
> The v2 image format can support up to 4 embedded images that can be
> loaded by the BootROM using the back-to-bootrom method.
>
> Currently two input files can be passed in using the datafile parameter,
> separated by a colon (":").
>
> Extend the datafile parameter parsing to support up to 4 input files
> separated by a colon (":") for use with the v2 image format.
>
> Signed-off-by: Jonas Karlman <[email protected]>
> Signed-off-by: Alexey Charkov <[email protected]>
>
> tools/rkcommon.c | 93 +++++++++++++++++++++++++++-----------------------------
> 1 file changed, 44 insertions(+), 49 deletions(-)
> diff --git a/tools/rkcommon.c b/tools/rkcommon.c
> @@ -257,31 +255,32 @@ int rkcommon_check_params(struct image_tool_params
> *params)
> + spl_params.images[0].file = params->datafile;
> + for (i = 1; i < ARRAY_SIZE(spl_params.images); i++) {
> + spl_params.images[i].file =
> + strchr(spl_params.images[i - 1].file, ':');
> + if (!spl_params.images[i].file)
> + break;
If more than four files are passed, the loop stops splitting after the
fourth, so the remaining colon(s) stay in the last file name and the
subsequent open fails with a confusing message. Please can you detect
this case and print a clear error that at most 4 input files are
supported?
> diff --git a/tools/rkcommon.c b/tools/rkcommon.c
> @@ -750,16 +748,13 @@ err_close:
> + for (i = 0; i < ARRAY_SIZE(spl_params.images); i++) {
> + if (!spl_params.images[i].size)
> + break;
> + ret = copy_file(params, ifd, spl_params.images[i].file,
> + spl_params.images[i].size);
This copies up to four images for both header versions, but for v1
rkcommon_set_header0() can only describe images[0] and images[1] via
init_size / init_boot_size, so a third or fourth file is written into
the output yet invisible to the BootROM. I suspect check_params should
reject more than two files when the format is not v2, rather than
silently producing a broken image. What do you think?
> diff --git a/tools/rkcommon.c b/tools/rkcommon.c
> @@ -662,8 +659,9 @@ int rkcommon_vrec_header(struct image_tool_params *params,
> + params->orig_file_size = tparams->header_size;
> + for (int i = 0; i < ARRAY_SIZE(spl_params.images); i++)
> + params->orig_file_size += spl_params.images[i].size;
A small one: this declares the loop variable inside the for statement,
while rockchip_copy_image() in the same patch (and the rest of the
file) declares it at the top of the function, as U-Boot in general -
please move it.
Regards,
Simon