From: Quentin Schulz <quentin.schulz@cherry.de>
To: Jonas Karlman <jonas@kwiboo.se>
Cc: Kever Yang <kever.yang@rock-chips.com>,
Simon Glass <sjg@chromium.org>,
Philipp Tomsich <philipp.tomsich@vrull.eu>,
Tom Rini <trini@konsulko.com>,
u-boot@lists.denx.de
Subject: Re: [PATCH 5/6] rockchip: mkimage: Add support for up to 4 input files
Date: Thu, 6 Feb 2025 15:36:13 +0100 [thread overview]
Message-ID: <7ac6395f-75c7-4dcd-95be-d7d68c04d704@cherry.de> (raw)
In-Reply-To: <d220c0af-2a28-4592-ab37-a9abf997d254@kwiboo.se>
On 2/5/25 8:00 PM, Jonas Karlman wrote:
> Hi Quentin,
>
> On 2025-02-05 17:43, Quentin Schulz wrote:
>> Hi Jonas,
>>
>> On 1/29/25 11:36 PM, Jonas Karlman wrote:
>>> 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 <jonas@kwiboo.se>
>>> ---
>>> tools/rkcommon.c | 93 +++++++++++++++++++++++-------------------------
>>> 1 file changed, 44 insertions(+), 49 deletions(-)
>>>
>>> diff --git a/tools/rkcommon.c b/tools/rkcommon.c
>>> index 542aca931693..4ff48e81a636 100644
>>> --- a/tools/rkcommon.c
>>> +++ b/tools/rkcommon.c
>>> @@ -148,17 +148,15 @@ static struct spl_info spl_infos[] = {
>>> /**
>>> * struct spl_params - spl params parsed in check_params()
>>> *
>>> - * @init_file: Init data file path
>>> - * @init_size: Aligned size of init data in bytes
>>> - * @boot_file: Boot data file path
>>> - * @boot_size: Aligned size of boot data in bytes
>>> + * @file: image file path
>>> + * @size: aligned size of image in bytes
>>
>> Not really matching reality though. Could make it easier maybe to have
>> an intermediary
>>
>> struct spl_params_image {
>> char *file;
>> uint32_t size;
>> };
>>
>> and then have
>>
>> struct spl_params {
>> struct spl_params_image images[4];
>> };
>>
>> ?
>
> Sound good, will use in v2.
>
>>
>>> */
>>>
>>> struct spl_params {
>>> - char *init_file;
>>> - uint32_t init_size;
>>> - char *boot_file;
>>> - uint32_t boot_size;
>>> + struct {
>>> + char *file;
>>> + uint32_t size;
>>> + } images[4];
>>> };
>>>
>>> static struct spl_params spl_params = { 0 };
>>> @@ -238,31 +236,32 @@ int rkcommon_check_params(struct image_tool_params *params)
>>> if (!rkcommon_get_spl_info(params->imagename))
>>> goto err_spl_info;
>>>
>>> - spl_params.init_file = params->datafile;
>>> + 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;
>>>
>>> - spl_params.boot_file = strchr(spl_params.init_file, ':');
>>> - if (spl_params.boot_file) {
>>> - *spl_params.boot_file = '\0';
>>> - spl_params.boot_file += 1;
>>> + *spl_params.images[i].file = '\0';
>>> + spl_params.images[i].file += 1;
>>> }
>>>
>>> - size = rkcommon_get_aligned_filesize(params, spl_params.init_file);
>>> - if (size < 0)
>>> - return EXIT_FAILURE;
>>> - spl_params.init_size = size;
>>> + for (i = 0; i < ARRAY_SIZE(spl_params.images); i++) {
>>> + if (!spl_params.images[i].file)
>>> + break;
>>>
>>> - /* Boot file is optional, and only for back-to-bootrom functionality. */
>>> - if (spl_params.boot_file) {
>>> - size = rkcommon_get_aligned_filesize(params, spl_params.boot_file);
>>> + size = rkcommon_get_aligned_filesize(params,
>>> + spl_params.images[i].file);
>>> if (size < 0)
>>> return EXIT_FAILURE;
>>> - spl_params.boot_size = size;
>>> + spl_params.images[i].size = size;
>>> }
>>>
>>
>> Can't we merge the two for-loops?
>
> Possible, suspect I kept it as two loops to avoid having to work on [i]
> and [i - 1] too much in same loop. Do you have any suggestion on how to
> merge the two for-loops to simplify this?
>
Something like:
"""
for (i = 0; i < ARRAY_SIZE(spl_params.images); i++) {
int size;
if (i == 0)
spl_params.images[i].file = params->datafile;
else
spl_params.images[i].file =
strchr(spl_params.images[i - 1].file, ':');
if (!spl_params.images[i].file)
break;
*spl_params.images[i].file = '\0';
spl_params.images[i].file += 1;
size = rkcommon_get_aligned_filesize(params,
spl_params.images[i].file);
if (size < 0)
return EXIT_FAILURE;
spl_params.images[i].size = size;
}
"""
maybe?
**NOT TESTED**
Cheers,
Quentin
next prev parent reply other threads:[~2025-02-06 14:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-29 22:36 [PATCH 0/6] rockchip: mkimage: Improve support for v2 image format Jonas Karlman
2025-01-29 22:36 ` [PATCH 1/6] rockchip: mkimage: Split size_and_off and size_and_nimage Jonas Karlman
2025-02-05 15:40 ` Quentin Schulz
2025-02-05 18:50 ` Jonas Karlman
2025-01-29 22:36 ` [PATCH 2/6] rockchip: mkimage: Print image information for all embedded images Jonas Karlman
2025-02-05 15:57 ` Quentin Schulz
2025-02-05 19:36 ` Jonas Karlman
2025-02-06 14:23 ` Quentin Schulz
2025-01-29 22:36 ` [PATCH 3/6] rockchip: mkimage: Print boot0 and boot1 parameters Jonas Karlman
2025-02-05 16:04 ` Quentin Schulz
2025-02-05 16:42 ` Jonas Karlman
2025-02-05 16:48 ` Quentin Schulz
2025-02-05 19:15 ` Jonas Karlman
2025-01-29 22:36 ` [PATCH 4/6] rockchip: mkimage: Add option to change image offset alignment Jonas Karlman
2025-02-05 16:29 ` Quentin Schulz
2025-02-05 16:58 ` Jonas Karlman
2025-01-29 22:36 ` [PATCH 5/6] rockchip: mkimage: Add support for up to 4 input files Jonas Karlman
2025-02-05 16:43 ` Quentin Schulz
2025-02-05 19:00 ` Jonas Karlman
2025-02-06 14:36 ` Quentin Schulz [this message]
2025-01-29 22:36 ` [PATCH 6/6] rockchip: mkimage: Add option for image load address and flag Jonas Karlman
2025-02-05 16:51 ` Quentin Schulz
2025-02-05 19:54 ` Jonas Karlman
2025-02-06 14:30 ` Quentin Schulz
2025-05-06 7:38 ` [PATCH 0/6] rockchip: mkimage: Improve support for v2 image format Kever Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7ac6395f-75c7-4dcd-95be-d7d68c04d704@cherry.de \
--to=quentin.schulz@cherry.de \
--cc=jonas@kwiboo.se \
--cc=kever.yang@rock-chips.com \
--cc=philipp.tomsich@vrull.eu \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox