From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C17F2C433EF for ; Wed, 10 Nov 2021 06:24:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DA8D261179 for ; Wed, 10 Nov 2021 06:24:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DA8D261179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 458968363C; Wed, 10 Nov 2021 07:24:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DLlmUVnx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8494B836ED; Wed, 10 Nov 2021 07:24:43 +0100 (CET) Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 9D0FD8363C for ; Wed, 10 Nov 2021 07:24:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42f.google.com with SMTP id r130so1754076pfc.1 for ; Tue, 09 Nov 2021 22:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=FWZJRrkdnxLapOTM+cvIa8TDObNp+jLzHsaYa4CpYts=; b=DLlmUVnx2UbJu7uRy+SLtCdU4TWFKBRlWvWFAEYiRnswnA6wlIy7/f0r7tzW6+qt49 EiDF5RcumY7S+i7+cvRby+n8wXkZPm9qnLRs2a7jGXKW3TxY9P5YTmm6adBIvjEloWVz lY4VMalK7ydILHEzY/ZQ1Joi/jaxMwWRyLxsTpBuCuWOEHwuaLRSI9Re2o1Yq1Wl2HOu scFUdAzK6BMcwXgYSUNwJ9NGilMAB4X1sL5bo5vlxX0FEF3c26PVZGv/XJQo5AW4iXTc EAQBQ8+4KfHm3Uc8oSpyGuEfq0QQkhxmsnwtSjwqN1eLkG6TRciieH6gOnsq0UAzr+lx waow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=FWZJRrkdnxLapOTM+cvIa8TDObNp+jLzHsaYa4CpYts=; b=sxc/MTzHRlIU8DIe9al+O0AVAb+qvKFWp/FtBF4ituFZBB/4AYB0bMA0dQdRAWPdVO EooqYka6G8oCGchu4JLkFhQm5ta0mrUahOk44WRMqq9kcGKJdZPpy4G7+Oy06MVP7Dsi 2l1teXYRA+HMYyiEujFJHQaXCvYiPAOY/HOfmem6Lk+MOFchU7KgC7id1YGWYtmI+jzq NQJMJwcq5K+riCTjHUkFJpmOBZZ6fdUgHuHW8z3ID4NIGngVL04PLYLWyhekBr/eeGDu Hws6pbqcKZZGU6OoTM/1/Pse/s+w4EwkU0VjTNzinXsCmj/4E9kgeVjeTt9lWLucHWiO z3EA== X-Gm-Message-State: AOAM533NcwEnTFxuLhByeJDl3+cbuDdJVWUF0ztUWQKGxWXeykwP8aF6 gyEZqwkJBbje04eqAop6T0eEvQ== X-Google-Smtp-Source: ABdhPJxcVWp1uLoYuBTFP0CCYHryIqOJdUwtx65aDvJEIVdP829J/NGB8sQHaUTMzv/jwHguDIIrtg== X-Received: by 2002:a05:6a00:887:b0:44b:dee9:b7b1 with SMTP id q7-20020a056a00088700b0044bdee9b7b1mr14768227pfj.84.1636525477936; Tue, 09 Nov 2021 22:24:37 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:d4ad:badd:7539:9f5a]) by smtp.gmail.com with ESMTPSA id l12sm22588170pfu.100.2021.11.09.22.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 22:24:37 -0800 (PST) Date: Wed, 10 Nov 2021 15:24:33 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de Subject: Re: [RFC 3/3] cmd: efidebug: handle booting from removable media Message-ID: <20211110062433.GC54635@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de References: <20211109013233.72902-1-takahiro.akashi@linaro.org> <20211109013233.72902-4-takahiro.akashi@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Tue, Nov 09, 2021 at 10:50:37AM +0100, Heinrich Schuchardt wrote: > On 11/9/21 02:32, AKASHI Takahiro wrote: > > Support for booting from removable media is now added to UEFI boot > > manager. Here we should modify efidebug command in order to define > > a proper "BootXXXX" variable. > > > > With this patch applied, you will be able to specify the boot order, > > usb and scsi: > > I guess for a removable device this should work even if the device is not > present. But currently: > > => efidebug boot add -b 1000 USB_present usb 0:1 EFI/BOOT/BOOTARM.EFI > => efidebug boot add -b 1000 USB_not_present usb 1:1 EFI/BOOT/BOOTARM.EFI > Cannot create device path for "usb 1:1" # In the second, I don't expect you to specify the file path, # "EFI/BOOT/BOOTARM.EFI", for removable media support. Yes, I have been aware of this issue but it is not this-patch specific but an existing issue as you clearly mentioned above. > A media device path like: > > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800) > > is not very helpful because the next device that you insert may have a > different location of the ESP partition. > > I think you should store > > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0) Apparently it is promising but actually not because "UsbClass(0x781,0x5571,0x0,0x0,0x0)" contains Vendor ID and Product ID which can only be retrieved from a real device attached to the board. I'm not yet sure where "UsbClass(0x0,0x0,0x9,0x0,0x1)" comes from. "USB(X, Y)", where X is a parent_port_number and Y is a usb_interface, would be a more appropriate candidate for this kind of device path, but we don't utilise this form in the current implementation. > and find the ESP on it at runtime. I don't think the specification requires that the disk is an ESP (at least explicitly). > > => efidebug -b 1 SCSI scsi 0:1 > > => efidebug boot dump > > Boot0001: > > attributes: A-- (0x00000001) > > label: SCSI > > file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0)/ Contrary to USB, we use Scsi(0,0) for scsi devices but it is NOT identical to U-Boot's scsi0 (in boot_targets). > > HD(1,GPT,0ed48d12-1b4c-4e08-b3ee-decf20428036,0x800,0xa000) > > data: > > 00000000: 00 00 > > => efideubg -b 2 USB usb 0:1 > > efidebug OK -Takahiro Akashi > Best regards > > Heinrich > > > => efidebug boot order 2 1 > > => bootefi bootmgr > > > > Signed-off-by: AKASHI Takahiro > > --- > > cmd/efidebug.c | 46 ++++++++++++++++++++++++++++++++++++++++------ > > 1 file changed, 40 insertions(+), 6 deletions(-) > > > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > > index a977ca9c72f5..aaf269cdf47d 100644 > > --- a/cmd/efidebug.c > > +++ b/cmd/efidebug.c > > @@ -933,6 +933,29 @@ out: > > return initrd_dp; > > } > > +/** > > + * count_arguments - count the number of arguments > > + * @argc: Total number of arguments > > + * @argv: Argument array > > + * Return: Number of arguments > > + * > > + * Count the number of arguments for a given option, "-?" > > + * Specifically if the first argument is not "-?", return 0; > > + */ > > +static int count_arguments(int argc, char *const argv[]) > > +{ > > + int i; > > + > > + if (argv[0][0] != '-') > > + return 0; > > + > > + for (i = 1; i < argc; i++) > > + if (argv[i][0] == '-') > > + break; > > + > > + return i; > > +} > > + > > /** > > * do_efi_boot_add() - set UEFI load option > > * > > @@ -945,7 +968,7 @@ out: > > * > > * Implement efidebug "boot add" sub-command. Create or change UEFI load option. > > * > > - * efidebug boot add -b