Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BFFEC54E94 for ; Wed, 25 Jan 2023 16:15:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7BC1B84BD0; Wed, 25 Jan 2023 17:15:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="aSZHe6GM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E881D85480; Wed, 25 Jan 2023 17:15:44 +0100 (CET) Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 42E868091A for ; Wed, 25 Jan 2023 17:15:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x835.google.com with SMTP id jr19so15123393qtb.7 for ; Wed, 25 Jan 2023 08:15:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RkSQHq/FQkENZwDHBv0gGGK5rpEJUnjphkkYaoTC2Ws=; b=aSZHe6GMMhS/9aS0dU0t68A/NGw+9MlqsFzdcvNm9H6hGnGRKJeuivD8ZUKI8S4/DE x5QiBI5W/qxmpcQft330Opw1zMokBvmTTFMVodTbtKJuoyIhXOcJvJsy6jzOV9uSlZl9 K87trvjEwjp9Z55pTBbLKa5kE3Ihtgoh7Dsyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RkSQHq/FQkENZwDHBv0gGGK5rpEJUnjphkkYaoTC2Ws=; b=21Hfa9V/5NfWHhc5W9fsj7W7BL8zRovXbc/9wMalpjguGTAz+f1kk5LZG+nL2Nql6b nK1V3Yp2+Oeupx5HoNwQw2mLqATs+xuis0LORKuH8aEWOaV+j4DTV9GtwVjFxx+VJpuE Sxu0wi3m7MYLMQ0sdoU2oE59Q/CSA6lqJXuk0gaQ4le9dT4eweTaoic0oX3nwcKBYcd8 yQtWSUfSn6c7FlNoWzmje8IAQj7EfE2x76C/d7Fv04kyralIGPd2yFFNAzdx5qJIc0Vc VVtjVWBDhs2E4zuLI0uV8bK63jHry94rRpB9sVPpp8LqCZ5QiNWbJH97efkWIIHivHoC 6G1A== X-Gm-Message-State: AO0yUKXZTxDnyleiJT3Zc0g9fxIF6/N2F9E4UhINf3mrEp6J/Y6selGV umJFDxh4lABCsOFpNeGXjG2WGg== X-Google-Smtp-Source: AK7set/HA/pXzeDLPKXD9CrMR3y2qdfCuAIHsag7XOAdv239mimSku8qsk2WYXWvcnMyrhf9p6dDyA== X-Received: by 2002:ac8:5c4f:0:b0:3b6:9d64:a3a5 with SMTP id j15-20020ac85c4f000000b003b69d64a3a5mr5210942qtj.43.1674663327865; Wed, 25 Jan 2023 08:15:27 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-bae1-07f2-e77c-42e1.res6.spectrum.com. [2603:6081:7b00:6400:bae1:7f2:e77c:42e1]) by smtp.gmail.com with ESMTPSA id z25-20020ac875d9000000b003b6382f66b1sm3471454qtq.29.2023.01.25.08.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 08:15:27 -0800 (PST) Date: Wed, 25 Jan 2023 11:15:25 -0500 From: Tom Rini To: Heinrich Schuchardt Cc: Simon Glass , Mark Kettenis , U-Boot Mailing List Subject: Re: [PATCH] bootstd: Replicate the dtb-filename quirks of distroboot Message-ID: References: <20230125031151.69027-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="RBoxRRiVEh7f/X8y" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --RBoxRRiVEh7f/X8y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 25, 2023 at 04:38:53PM +0100, Heinrich Schuchardt wrote: > On 1/25/23 04:11, Simon Glass wrote: > > For EFI, the distro boot scripts search in three different directories > > for the .dtb file. The SOC-based filename fallback is supported only for > > 32-bit ARM. > >=20 > > Adjust the code to mirror this behaviour. > >=20 > > Signed-off-by: Simon Glass > > Suggested-by: Mark Kettenis > > --- > >=20 > > boot/bootmeth_efi.c | 63 ++++++++++++++++++++++++++++++++++++++------- > > 1 file changed, 54 insertions(+), 9 deletions(-) > >=20 > > diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c > > index 67c972e3fe4..f9544846e68 100644 > > --- a/boot/bootmeth_efi.c > > +++ b/boot/bootmeth_efi.c > > @@ -147,25 +147,57 @@ static int distro_efi_check(struct udevice *dev, = struct bootflow_iter *iter) > > return 0; > > } > > -static void distro_efi_get_fdt_name(char *fname, int size) > > +/** > > + * distro_efi_get_fdt_name() - Get the filename for reading the .dtb f= ile > > + * > > + * @fname: Place to put filename > > + * @size: Max size of filename > > + * @seq: Sequence number, to cycle through options (0=3Dfirst) > > + * Returns: 0 on success, -ENOENT if the "fdtfile" env var does not ex= ist, > > + * -EINVAL if there are no more options > > + */ > > +static int distro_efi_get_fdt_name(char *fname, int size, int seq) > > { > > const char *fdt_fname; > > + const char *prefix; > > + > > + /* select the prefix */ > > + switch (seq) { > > + case 0: > > + /* this is the default */ > > + prefix =3D "/dtb"; > > + break; > > + case 1: > > + prefix =3D ""; > > + break; > > + case 2: > > + prefix =3D "/dtb/current"; > > + break; > > + default: > > + return log_msg_ret("pref", -EINVAL); > > + } > > fdt_fname =3D env_get("fdtfile"); > > if (fdt_fname) { > > - snprintf(fname, size, "dtb/%s", fdt_fname); > > + snprintf(fname, size, "%s/%s", prefix, fdt_fname); > > log_debug("Using device tree: %s\n", fname); > > - } else { > > + > > + /* Use this fallback only for 32-bit ARM */ > > + } else if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_ARM64)) { > > const char *soc =3D env_get("soc"); > > const char *board =3D env_get("board"); > > const char *boardver =3D env_get("boardver"); > > /* cf the code in label_boot() which seems very complex */ > > - snprintf(fname, size, "dtb/%s%s%s%s.dtb", > > + snprintf(fname, size, "%s/%s%s%s%s.dtb", prefix, > > soc ? soc : "", soc ? "-" : "", board ? board : "", > > boardver ? boardver : ""); > > log_debug("Using default device tree: %s\n", fname); > > + } else { > > + return log_msg_ret("env", -ENOENT); > > } > > + > > + return 0; > > } > > static int distro_efi_read_bootflow_file(struct udevice *dev, > > @@ -174,7 +206,7 @@ static int distro_efi_read_bootflow_file(struct ude= vice *dev, > > struct blk_desc *desc =3D NULL; > > ulong fdt_addr, size; > > char fname[256]; > > - int ret; > > + int ret, seq; > > /* We require a partition table */ > > if (!bflow->part) > > @@ -196,13 +228,22 @@ static int distro_efi_read_bootflow_file(struct u= device *dev, > > if (ret) > > return log_msg_ret("read", -EINVAL); > > - distro_efi_get_fdt_name(fname, sizeof(fname)); > > + fdt_addr =3D env_get_hex("fdt_addr_r", 0); > > + > > + /* try the various available names */ > > + ret =3D -ENOENT; > > + for (seq =3D 0; ret; seq++) >=20 > There are boards that don't have a dtb file available and that is ok. Don= 't > loop past seq =3D 2. >=20 > { > > + ret =3D distro_efi_get_fdt_name(fname, sizeof(fname), seq); > > + if (ret) > > + return log_msg_ret("nam", ret); > > + ret =3D bootmeth_common_read_file(dev, bflow, fname, fdt_addr, > > + &size); > > + } > > + > > bflow->fdt_fname =3D strdup(fname); > > if (!bflow->fdt_fname) > > return log_msg_ret("fil", -ENOMEM); >=20 > This should not be an error. The Distroboot fallback is the device-tree at > $fdtcontroladdr. But it should note that it's using that because that's still quite often an unexpected feature to people. --=20 Tom --RBoxRRiVEh7f/X8y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmPRVZQACgkQFHw5/5Y0 tywD2gv9GohQveEp3eM9jwoMd0Sg26jalmcYwd8zG5GbTOJRaltjlxAlB5uu+reN xnrwjuDY2cHCRlieyovX/CqbElkShiARVor/9qtqIJwU/8dL9njfLKrxMr7AfiEf Z2qir2Ddi5RzVmXVZWic4r+psirekoz5CQIMwmdsDECvpHUYHdp/Oi6IFA6Rc/94 slhKjYgoC60HdRRa96yocwdz0Q1lzXaG1/4DcSD+vdUlvpMM22zQPjyKOmfVx52N ejphq6Wv3cpQ3dN3pp+2I441ZEiS+CpqJf7tkSAgUa9oRaFs0zssElM74XlRHF3C beYCRMfInSE2Q2UizwArkKiW2i8XoxFz9cnBIxUxEnOUaa+eu+PSdpcU7cL+B93w KHpBT8ROnwE57xPrtehXpPWkjQQRgI0/TidFjiotH8mtq1mIFYIawgG1R73MYI55 1S0Rvu/r0YuZQg3QqkWBFzAWEFcoUI46WPIQreRscnkBEeHaTOI/iMY2UdKcOK+I cK4ApuXG =h7r1 -----END PGP SIGNATURE----- --RBoxRRiVEh7f/X8y--