From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::22f; helo=mail-pl0-x22f.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x22f.google.com (mail-pl0-x22f.google.com [IPv6:2607:f8b0:400e:c01::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3FDFA20355222 for ; Tue, 7 Nov 2017 22:03:23 -0800 (PST) Received: by mail-pl0-x22f.google.com with SMTP id g16so650624plj.1 for ; Tue, 07 Nov 2017 22:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :in-reply-to:content-language:content-transfer-encoding:mime-version; bh=EA9T6K/OCpMHJ6upfVp/FrG4uCu36ZpoezIYUK9ylVY=; b=F2erwI1T4XPyYF43At4co9N5vRqPNkNxPpFnOXlwKECEBJjfESiBujYteBbdtCWNrh PuVM0JwXaru5DF3G6nAdUPhwUYraEYR7jRpAfnBp37RR7ra2RI/7RV6qu2U8nHNR6aj+ LGPc9sAGEn0WhJvsxvEDeAR3ZZHVcRaLSdNew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:in-reply-to:content-language :content-transfer-encoding:mime-version; bh=EA9T6K/OCpMHJ6upfVp/FrG4uCu36ZpoezIYUK9ylVY=; b=ES2cihMrqNXBr8a7tNsf4ugY06zC706EuxMdH+/LCsczIjqjnl1hJkHX/wN1AGxXNG zshF6F2fqYT8Rb56sRPpzxjIxUCOZz0e0Q2G5okCWORkFdVEnySsQc5cd+5cQcVrev91 Q1popDZfnDY/hrg6YZ1HQM4ox8Gn6VV3JV4oBXN/+YenZQZXUhiyzjxkecqBmq/C0vVD v7v1L+EG1xE2Jie1/twGNe+g5PalnlpA6/DnWvwwRMotMfHuXJ2fO20XQsXF9VmLY06x F7PHLCJ2wMzMMjzrkl/yX6C8C2R3WV2PocV69GGM+VLDLxd5ITVZrjyR/nrDUx6Fc81l G/Iw== X-Gm-Message-State: AJaThX5POLB7FP/DLt4U2HtdvEzAwSbd4/n+JoXfoE0VyJvzWs7cEMuP QIyDZAgK11NrIxpSTEy34xrdNQ== X-Google-Smtp-Source: ABhQp+R2FV8AzxuyZbyEZfead7V5Wus2PZQl7e3F6K8En8X0LsJVdCkgo4CEZzvOA/Ts9wFEhiGGLw== X-Received: by 10.84.235.69 with SMTP id g5mr1231311plt.239.1510121243038; Tue, 07 Nov 2017 22:07:23 -0800 (PST) Received: from BY2PR15MB0728.namprd15.prod.outlook.com ([132.245.246.61]) by smtp.gmail.com with ESMTPSA id f11sm6173853pfd.82.2017.11.07.22.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Nov 2017 22:07:21 -0800 (PST) Received: from [192.168.9.22] (10.170.177.21) by BY2PR15MB0728.namprd15.prod.outlook.com (10.164.170.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13 via Mailbox Transport; Wed, 8 Nov 2017 05:46:20 +0000 Reply-To: haojian.zhuang@linaro.org To: Vladimir 'phcoder' Serbinenko Cc: Fathi Boudra , Leif Lindholm , "edk2-devel@lists.01.org" , okuji@enbug.org, grub-devel@gnu.org References: <5efb001e-f292-9f22-edae-a617147749c6@linaro.org> From: Haojian Zhuang Message-ID: <3239f02f-73ce-0bd3-681b-494d378d3ebd@linaro.org> Date: Wed, 8 Nov 2017 13:46:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 In-Reply-To: X-MS-Exchange-Organization-Network-Message-Id: 971f9bd8-7cf9-4402-b760-08d5266c0b10 X-MS-Exchange-Organization-AuthSource: BY2PR15MB0728.namprd15.prod.outlook.com X-MS-Exchange-Organization-AuthAs: Anonymous X-TMN: [lAo/fK438wlbCqYZbOLmJX87+wmDcesH] X-MS-Exchange-Organization-MessageDirectionality: Originating MIME-Version: 1.0 Subject: Re: GRUB issue on device priority X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 06:03:23 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit On 2017/11/7 23:14, Vladimir 'phcoder' Serbinenko wrote: > > > On Tue, Nov 7, 2017, 15:23 Haojian Zhuang > wrote: > > Hi all, > > It seems there's a device priority issue in GRUB. > > Please use mailing list for grub, not just messaging random people some > of whom have left project 10 years ago. Sure. Just find the mailing account. Loop grub-devel@gnu.org. > > > All block io handles are linked into the list in edk2, and GRUB could > fetch it. Then GRUB creates its own ascending on HD priority. > > What do you mean by "priority"? It's just disk numbers that don't change > anything. Yes, it's disk numbers and it causes an issue. In edk2, I organize all handles in sequence. For example, eMMC is the first BlockIO device, and SD is the second BlockIO device. In GRUB, it resorts the sequence by ascending order on UUID (device path). Since both eMMC and SD controllers are varient of one IP, use the same device driver for these two devices. Then UUIDs are in below. GRUB names SD with HD0 and eMMC with HD1. The disk numbers are inverted by GRUB. > > add_device(): >    for (p = devices; *p; p = &((*p)->next)) { >      ret = grub_efi_compare_device_paths > (grub_efi_find_last_device_path > ((*p->device_path), > > grub_efi_find_last_device_path->device_path)); >      if (ret == 0) { >        ret = grub_efi_compare_device_paths ((*p)->device_path, >                                             d->device_path); >      } >      if (ret == 0) { >        return; >      } else if (ret > 0) { >        break; >      } >    } >    ... > > In the HiKey platform, I prepared the same driver for both eMMC and SD. > So the device paths are in below. > SD: /HardwareVendor(0d51905b-b77e-452a-a2c0-eca0 > cc8d514a)[9: 00 e0 23 f7 00 00 00 00 00 ]/UnknownMessaging(1a)/EndEntire > eMMC: /HardwareVendor(0d51905b-b77e-452a-a2c0-eca0 > cc8d514a)[9: 00 d0 23 f7 00 00 00 00 00 > ]/UnknownMessaging(1d)/Ctrl(0)/EndEntire > > #define MSG_SD_DP                   0x1A > #define MSG_EMMC_DP                 0x1D > > In the second level, the device paths are different. > > And GRUB resort the sequence by ascending order (with above code). So SD > device always gets higher priority than eMMC device. > > If we always use installer to install OS, it may not an issue. Since > installer could create grub.cfg by itself. But it imports another issue > on lacking of persistent variable storage. And we need to deploy system > without installer on embedded device. > > How to fix the priority issue? Fix in GRUB or something else? > > You shouldn't rely on any particular GRUB device ordering. The easiest > way is to use UUID. I failed to find root by uuid. I don't know why. But I found that I can make use of "-hint" with multiple parameters. Then this issue could be fixed. Great thanks for your help. Best Regards Haojian