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 9EB06C433F5 for ; Wed, 10 Nov 2021 08:12:04 +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 E3C6E61052 for ; Wed, 10 Nov 2021 08:12:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E3C6E61052 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com 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 084B08355C; Wed, 10 Nov 2021 09:12:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com 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=canonical.com header.i=@canonical.com header.b="XZXnvpKS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 414D28355C; Wed, 10 Nov 2021 09:11:59 +0100 (CET) Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2336E836DD for ; Wed, 10 Nov 2021 09:11:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 136964000F for ; Wed, 10 Nov 2021 08:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1636531912; bh=DHxv3FAEbDSTkwkunW6lO6cTAJC4oBAYccuvQ4z+rVg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:Cc: In-Reply-To:Content-Type; b=XZXnvpKSHpEn5SOR3MI59EciAjuycOopnaTLCEkBLPyXaeEh6O6nD3okY29TxNbRa YsnL2VUsWYRe2Nh0/jL+T3jRay54fNzAF7lGvRp1SVmWh5doigomelYxgTEXL4HKQ+ jyBBOuLY6zrM8hWyId6P07ODsMAd0gn0AKekTqra75ykbu+SuXTtZ7/+CCb6mCXMN4 RFrnH0QVSMKnkwm1oSLNCfnDhnQCcaMHOoK0XDsmr2Sq5lGTRG7OYaT8w7qLjfI1ld phaDVJOPwPIhS6YBLRpbs6jtl1YgC3EWWleL1lY3blX8EZIGdiVc+rrEVwfAP1kuit 5f4hcAfmp5Ojg== Received: by mail-wr1-f69.google.com with SMTP id q7-20020adff507000000b0017d160d35a8so220959wro.4 for ; Wed, 10 Nov 2021 00:11:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:cc:in-reply-to :content-transfer-encoding; bh=DHxv3FAEbDSTkwkunW6lO6cTAJC4oBAYccuvQ4z+rVg=; b=tEk/3onI9aiTbqRatGVGD/aLTecv5AypJYVoq72+yxyhUZbtLaSYba1SFkTr12HiaC fUMt8eT3fH2Y7ZlCY8UYbxfMEuJxZuVhd/7IeMVgVbDb7vIKPSLpB1rpeZKGFTVMOZ6+ WEQtcj8u+fVCES4ZGuqjgaJmdfO+AV5AXIVxUbGQs07s3zSqbAgVSeozeqwoe42xa8T+ QbF2orXEOhr5fhPsUBNmVVWSWAir+/jjFIFXDXicxgCm/ITjf511Ka7T2FvuLlhGMzCB EPX694wFIiZ5PzBt8gfjM2TtWbaQ1O3e+Uil1xwDJYsV6q+ItSSblrYuov6kS6LQIZXq c5yw== X-Gm-Message-State: AOAM530ezP7OO1VadZyupgZjKC3g/mBc4cg+A0Lve0OEYn8Y/zHJSgOg 2K89zZq5FORSHEvpJicxar8NEFjzBiPfdOSBT3xyQkQMwCt9zPAlgT2gTYapKYB3ws1JfQm7DUE ChBYdaIygt3AA6HZmeZ8EwtF5ac3J6xA= X-Received: by 2002:adf:f08d:: with SMTP id n13mr17965605wro.395.1636531911465; Wed, 10 Nov 2021 00:11:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwG7Fdm1mJWHZ4Fpv5m4Frleu+JX6m6XJPEPcX9qVEbvWNqtnYZE4FxBGRvnHSCnRa8mhKhpQ== X-Received: by 2002:adf:f08d:: with SMTP id n13mr17965577wro.395.1636531911192; Wed, 10 Nov 2021 00:11:51 -0800 (PST) Received: from [192.168.123.35] (ip-88-152-144-157.hsi03.unitymediagroup.de. [88.152.144.157]) by smtp.gmail.com with ESMTPSA id u14sm21995406wrt.49.2021.11.10.00.11.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Nov 2021 00:11:50 -0800 (PST) Message-ID: <66353088-caad-7953-6a12-eded28576c3d@canonical.com> Date: Wed, 10 Nov 2021 09:11:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [RFC 3/3] cmd: efidebug: handle booting from removable media Content-Language: en-US To: AKASHI Takahiro References: <20211109013233.72902-1-takahiro.akashi@linaro.org> <20211109013233.72902-4-takahiro.akashi@linaro.org> <20211110062433.GC54635@laputa> From: Heinrich Schuchardt Cc: Marek Vasut , agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de In-Reply-To: <20211110062433.GC54635@laputa> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 11/10/21 07:24, AKASHI Takahiro wrote: > 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. 0x781,0x5571 relates to Vendor: SanDisk Corp. Device: Cruzer Fit This is how Linux sees my OrangePi PC: $ lsusb Bus 009 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 002: ID 0781:5571 SanDisk Corp. Cruzer Fit Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub The bus numbering seems not to be stable: $ lsusb Bus 009 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 002: ID 0781:5571 SanDisk Corp. Cruzer Fit Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub And this is in U-Boot: usb 0 [ + ] ehci_generic | |-- usb@1c1a000 usb_hub 0 [ + ] usb_hub | | `-- usb_hub usb 1 [ + ] ohci_generic | |-- usb@1c1a400 usb_hub 1 [ + ] usb_hub | | `-- usb_hub usb 2 [ + ] ehci_generic | |-- usb@1c1b000 usb_hub 2 [ + ] usb_hub | | `-- usb_hub usb 3 [ + ] ohci_generic | |-- usb@1c1b400 usb_hub 3 [ + ] usb_hub | | `-- usb_hub usb 4 [ + ] ehci_generic | |-- usb@1c1c000 usb_hub 4 [ + ] usb_hub | | `-- usb_hub usb_mass_s 0 [ + ] usb_mass_storage | | `-- usb_mass_storage blk 1 [ ] usb_storage_blk | | `-- usb_mass_storage.lun0 usb 5 [ + ] ohci_generic | |-- usb@1c1c400 usb_hub 5 [ + ] usb_hub | | `-- usb_hub usb 6 [ + ] ehci_generic | |-- usb@1c1d000 usb_hub 6 [ + ] usb_hub | | `-- usb_hub usb 7 [ + ] ohci_generic | |-- usb@1c1d400 usb_hub 7 [ + ] usb_hub | | `-- usb_hub The location where a USB is plugged is identified by the port of the USB hub it is connected to. I think before we can properly support removable media we will have to get the UEFI device path right. We need a node on all of the levels of the DM tree of which more than one instance can exist. Best regards Heinrich > > 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