U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Schulz <quentin.schulz@cherry.de>
To: Jonas Karlman <jonas@kwiboo.se>,
	Kever Yang <kever.yang@rock-chips.com>,
	Simon Glass <sjg@chromium.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH 4/6] rockchip: mkimage: Add option to change image offset alignment
Date: Wed, 5 Feb 2025 17:29:39 +0100	[thread overview]
Message-ID: <7aa55d4f-42d9-490a-8a20-705358db00cc@cherry.de> (raw)
In-Reply-To: <20250129223641.1888833-5-jonas@kwiboo.se>

Hi Jonas,

On 1/29/25 11:36 PM, Jonas Karlman wrote:
> The vendor boot_merger tool support a ALIGN parameter that is used to
> define offset alignment of the embedded images.
> 
> Vendor use this for RK3576 to change offset alignment from the common
> 2 KiB to 4 KiB, presumably it may have something to do with UFS.
> Testing with eMMC has shown that using a 512-byte alignment also work.
> 
> Add support for overriding offset alignment in case this is needed for
> e.g. RK3576 in the future.
> 
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
>   tools/rkcommon.c | 75 +++++++++++++++++++++++++++++++-----------------
>   tools/rkcommon.h |  2 --
>   2 files changed, 49 insertions(+), 28 deletions(-)
> 
> diff --git a/tools/rkcommon.c b/tools/rkcommon.c
> index 324820717663..542aca931693 100644
> --- a/tools/rkcommon.c
> +++ b/tools/rkcommon.c
> @@ -124,6 +124,7 @@ struct spl_info {
>   	const uint32_t spl_size;
>   	const bool spl_rc4;
>   	const uint32_t header_ver;
> +	const uint32_t align;

Missing documentation update above the struct definition.

>   };
>   
>   static struct spl_info spl_infos[] = {
> @@ -181,14 +182,19 @@ static struct spl_info *rkcommon_get_spl_info(char *imagename)
>   	return NULL;
>   }
>   
> -static int rkcommon_get_aligned_size(struct image_tool_params *params,
> -				     const char *fname)
> +static bool rkcommon_is_header_v2(struct image_tool_params *params)
>   {
> -	int size;
> +	struct spl_info *info = rkcommon_get_spl_info(params->imagename);
>   
> -	size = imagetool_get_filesize(params, fname);
> -	if (size < 0)
> -		return -1;
> +	return (info->header_ver == RK_HEADER_V2);
> +}
> +
> +static int rkcommon_get_aligned_size(struct image_tool_params *params, int size)

Maybe use an unsigned type here as a size will be guaranteed to be positive?

> +{
> +	struct spl_info *info = rkcommon_get_spl_info(params->imagename);
> +
> +	if (info->align)
> +		return ROUND(size, info->align * RK_BLK_SIZE);
>   

Why not make info->align be 4 (RK_SIZE_ALIGN / RK_BLK_SIZE) if unset?

I like the change, though I felt splitting in more commits would have 
made the review easier, e.g.:

- split part of get_aligned_size into get_aligned_filesize
- migrate hardcoded RK_INIT_OFFSET to get_aligned_size
- migrate hardcoded RK_SPL_HDR_START to get_aligned_size
- add align to spl_info + handling in get_aligned_size

Looks good to me otherwise!

Cheers,
Quentin

  reply	other threads:[~2025-02-05 16:29 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 [this message]
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
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=7aa55d4f-42d9-490a-8a20-705358db00cc@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