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:c00::22b; helo=mail-pf0-x22b.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf0-x22b.google.com (mail-pf0-x22b.google.com [IPv6:2607:f8b0:400e:c00::22b]) (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 84E752034BBFA for ; Thu, 9 Nov 2017 01:06:05 -0800 (PST) Received: by mail-pf0-x22b.google.com with SMTP id n89so3823665pfk.11 for ; Thu, 09 Nov 2017 01:10:06 -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=CASBBWbvYymRtnlB4cLtTVsSqtWqhKhJeOiOisVfu84=; b=BstjlvWiJtCePNIIbUrLJpGnAa3khAsf9ip0b9TqA2yoZY6Jf7nXbw+2JyoMcHi83X aVSpMthX+kdvLz+ghp7IoogPDamCjeA3Dgpiyf5kziN4qQYICC4bTXC3YvJMr2kUrpTk 827wgQt9ruAYrALwwPEHH8LV4edQROrBU4IeA= 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=CASBBWbvYymRtnlB4cLtTVsSqtWqhKhJeOiOisVfu84=; b=RMWHhnTDL7hSRYodx0fV2B5sL7A4/NTG21W7MGeQesfzotEpj7e/PEtgAkXFQc4FoN NX2hbaIhZ4pwInMaQUB85sIdL4WaB7RxGi2JgkonC4/TnZWaACHR0UUZa7uyJx3ZgnUy nun4sQtCU+Kjdcf4wanzySmePLKFuowtijEhkgrv1uFV7/yF/2J1+puF4TtKbPNwIaMG xmKU9PVuv+A2raAPa5ZaSr9HnI8Ma/+WnyW/qiyn2nYDutpt7Co7k7fy8u+uUM1TEhEA uY1EX91MhuxxOUkoUaqcdjvWrrGvqGuNiBB8FCl+DfQR6tshDi0puxupEfxKp4cd44Gv 8o+Q== X-Gm-Message-State: AJaThX6RblJz+vyHMbgOb8m5FYRWmdGky4tJ2v4NwAl6F3MfwKB4qons JovVVXPTBYR5OP1HuXcsPbCFOmRlW2Q= X-Google-Smtp-Source: ABhQp+QORe0r3O4phqwlCA/0+or2XJbY6M6Z+w3jTU6tAxUBDgpndRQ+erNnpnREPL+ppUAIOfEFgA== X-Received: by 10.98.247.4 with SMTP id h4mr3473677pfi.16.1510218606547; Thu, 09 Nov 2017 01:10:06 -0800 (PST) Received: from CY1PR15MB0730.namprd15.prod.outlook.com ([132.245.253.237]) by smtp.gmail.com with ESMTPSA id c9sm13419481pfj.76.2017.11.09.01.10.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Nov 2017 01:10:05 -0800 (PST) Received: from [192.168.9.22] (10.170.160.32) by CY1PR15MB0730.namprd15.prod.outlook.com (10.169.21.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12 via Mailbox Transport; Thu, 9 Nov 2017 08:42:06 +0000 Reply-To: haojian.zhuang@linaro.org To: Leif Lindholm Cc: "edk2-devel@lists.01.org" , Fathi Boudra References: <5efb001e-f292-9f22-edae-a617147749c6@linaro.org> <20171108135322.stnmshxqjaxu5xhx@bivouac.eciton.net> From: Haojian Zhuang Message-ID: Date: Thu, 9 Nov 2017 16:41:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 In-Reply-To: <20171108135322.stnmshxqjaxu5xhx@bivouac.eciton.net> X-MS-Exchange-Organization-Network-Message-Id: e4789857-5f5a-450a-dd59-08d5274dc2b9 X-MS-Exchange-Organization-AuthSource: CY1PR15MB0730.namprd15.prod.outlook.com X-MS-Exchange-Organization-AuthAs: Anonymous X-TMN: [pLSMz5BO+QxVWEWvXpss6Fbf5OfXwAGd] 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: Thu, 09 Nov 2017 09:06:05 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 2017/11/8 21:53, Leif Lindholm wrote: > On Tue, Nov 07, 2017 at 10:02:30PM +0800, Haojian Zhuang wrote: >> Hi all, >> >> It seems there's a device priority issue in GRUB. > > GRUB is behaving as expected. > >> 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. >> 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; >> } >> } >> ... > > UEFI guarantees no ordering of block devices. GRUB is a UEFI > application, so it cannot assume anything with regards to device > ordering. > >> 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-eca0cc8d514a)[9: 00 e0 23 f7 00 00 00 00 00 ]/UnknownMessaging(1a)/EndEntire >> eMMC: /HardwareVendor(0d51905b-b77e-452a-a2c0-eca0cc8d514a)[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. > > Yes, this is the bit which is interesting, and why I requested you > post this problem to edk2-devel. > > I believe that we need to have a sensible way to deal with embedded > platforms that do not have operating systems "installed" to them, but > rather written as images to flash devices. > > So, can you clarify a few things for me?: > - Where is GRUB located in your (pre-SD) system? In eMMC. > - Where is GRUB located in your SD system? In SD. > - Are you looking for a way to support GRUB being located on either > eMMC or SD? Or are you looking to always have GRUB loaded from eMMC? GRUB could be located in either in eMMC or SD. Best Regards Haojian