Hi Jonas,

On 2026-07-13T10:02:41, Alexey Charkov <[email protected]> wrote:
> rockchip: mkimage: Split size_and_off and size_and_nimage
>
> Split 32-bit size_and_off and size_and_nimage fields of the v2 image
> format header into their own 16-bit size, offset and num_images fields.
>
> Set num_images based on number of images passed by the datafile
> parameter and size based on the offset to the hash field to fix using a
> single init data file and no boot data file for the v2 image format.
>
> Signed-off-by: Jonas Karlman <[email protected]>
> Signed-off-by: Alexey Charkov <[email protected]>
>
> tools/rkcommon.c | 44 ++++++++++++++++++++++++--------------------
>  1 file changed, 24 insertions(+), 20 deletions(-)

Reviewed-by: Simon Glass <[email protected]>

> diff --git a/tools/rkcommon.c b/tools/rkcommon.c
> @@ -370,6 +373,8 @@ static void rkcommon_set_header0_v2(void *buf, struct 
> image_tool_params *params)
> +     hdr->num_images = cpu_to_le16(i);
> +     hdr->size = cpu_to_le16(offsetof(typeof(*hdr), hash) / 
> sizeof(uint32_t));

With the split fields the offset of hash works out to 1536 bytes, i.e.
384 words, matching the old hardcoded value, so this is a nice cleanup.
It does rely on struct header0_info_v2 having no padding - fine today
since all fields are naturally aligned, but a static assert that the
struct is 2048 bytes would guard against someone reordering the fields
later. What do you think?

Regards,
Simon

Reply via email to