From: "André Przywara" <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [PATCH 5/8] sunxi: board: Save the chosen DT name in the SPL header
Date: Tue, 22 Sep 2020 01:41:25 +0100 [thread overview]
Message-ID: <fceb307c-5758-5ff7-7827-e0de6f859381@arm.com> (raw)
In-Reply-To: <20200903050716.48488-6-samuel@sholland.org>
On 03/09/2020 06:07, Samuel Holland wrote:
> This overwrites the name loaded from the SPL image. It will be different
> if there was previously no name provided, or if a more accurate name was
> determined by the board variant selection logic. This means that the DT> name in the SPL header now always matches the DT appended to U-Boot.
That's a nice way of preserving all this fancy DT selection choices for
U-Boot proper!
> Signed-off-by: Samuel Holland <samuel@sholland.org>
One hint below, but nevertheless:
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
> ---
> board/sunxi/board.c | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 3d64ed18664..eaa40a1ea96 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -331,6 +331,21 @@ static const char *get_spl_dt_name(void)
> return NULL;
> }
>
> +static void set_spl_dt_name(const char *name)
> +{
> + struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION);
> +
> + if (spl == INVALID_SPL_HEADER)
> + return;
> +
> + /* Promote the header version for U-Boot proper, if needed. */
> + if (spl->spl_signature[3] < SPL_DT_HEADER_VERSION)
> + spl->spl_signature[3] = SPL_DT_HEADER_VERSION;
> +
> + strcpy((char *)&spl->string_pool, name);
Let's hope nobody ever optimises the strcpy() routine, as this might
break (when doing unaligned accesses) on device memory, as in this case.
Cheers,
Andre.
> + spl->dt_name_offset = offsetof(struct boot_file_head, string_pool);
> +}
> +
> int dram_init(void)
> {
> struct boot_file_head *spl = get_spl_header(SPL_DRAM_HEADER_VERSION);
> @@ -904,6 +919,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
> int board_fit_config_name_match(const char *name)
> {
> const char *best_dt_name = get_spl_dt_name();
> + int ret;
>
> #ifdef CONFIG_DEFAULT_DEVICE_TREE
> if (best_dt_name == NULL)
> @@ -941,6 +957,15 @@ int board_fit_config_name_match(const char *name)
> }
> #endif
>
> - return strcmp(name, best_dt_name);
> + ret = strcmp(name, best_dt_name);
> +
> + /*
> + * If one of the FIT configurations matches the most accurate DT name,
> + * update the SPL header to provide that DT name to U-Boot proper.
> + */
> + if (ret == 0)
> + set_spl_dt_name(best_dt_name);
> +
> + return ret;
> }
> #endif
>
next prev parent reply other threads:[~2020-09-22 0:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 5:07 [PATCH 0/8] PinePhone automatic device tree selection Samuel Holland
2020-09-03 5:07 ` [PATCH 1/8] sunxi: board: Use a more descriptive variable name Samuel Holland
2020-09-22 0:37 ` André Przywara
2020-09-03 5:07 ` [PATCH 2/8] sunxi: board: Add a helper to get the SPL DT name Samuel Holland
2020-09-22 0:38 ` André Przywara
2020-09-03 5:07 ` [PATCH 3/8] sunxi: board: Simplify Pine A64 DT selection logic Samuel Holland
2020-09-22 0:40 ` André Przywara
2020-09-03 5:07 ` [PATCH 4/8] sunxi: board: Add PinePhone " Samuel Holland
2020-09-22 0:41 ` André Przywara
2020-10-21 18:56 ` Jagan Teki
2020-10-22 1:38 ` Samuel Holland
2020-10-22 6:26 ` Jagan Teki
2020-10-22 15:50 ` Maxime Ripard
2020-09-03 5:07 ` [PATCH 5/8] sunxi: board: Save the chosen DT name in the SPL header Samuel Holland
2020-09-22 0:41 ` André Przywara [this message]
2020-09-22 1:12 ` Samuel Holland
2020-09-22 7:46 ` André Przywara
2020-09-03 5:07 ` [PATCH 6/8] sunxi: board: Set fdtfile to match the DT chosen by SPL Samuel Holland
2020-09-22 0:43 ` André Przywara
2020-09-22 1:33 ` Samuel Holland
2020-09-24 14:22 ` Andre Przywara
2020-09-03 5:07 ` [PATCH 7/8] sunxi: DT: A64: update device tree files Samuel Holland
2020-09-03 5:07 ` [PATCH 8/8] sunxi: a64: Add a defconfig for the PinePhone Samuel Holland
2020-09-03 7:31 ` [PATCH 0/8] PinePhone automatic device tree selection Maxime Ripard
2020-09-07 0:01 ` André Przywara
2020-10-24 16:50 ` Peter Robinson
2020-10-24 14:45 ` Jagan Teki
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=fceb307c-5758-5ff7-7827-e0de6f859381@arm.com \
--to=andre.przywara@arm.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