From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::22a; helo=mail-wm0-x22a.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com [IPv6:2a00:1450:400c:c09::22a]) (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 7717D20355234 for ; Wed, 8 Nov 2017 05:49:26 -0800 (PST) Received: by mail-wm0-x22a.google.com with SMTP id y83so10876508wmc.4 for ; Wed, 08 Nov 2017 05:53:27 -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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MtVXp4Klyqg+jWOkYtau1wNgkjF6OeLzgv9rMRSxsW4=; b=aCkMhSCaFKuFEjjksESks6m4xHcp6O9OqN5wBx5tKzIM+5QrfSsBcNu+4H5yGbgNBn LA7EjnvWWNtUSVQjiKg3LCIVxdUDWFxzJzMQE/8Cm/j1j4ETfO4EzBY4D/EhXL1Edq6h uFe2sBwwjI8KIREu0NQD01C7JA1/XlU1yK5Q0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MtVXp4Klyqg+jWOkYtau1wNgkjF6OeLzgv9rMRSxsW4=; b=bcd9LDWDquya1EUyuSUMMv6WZzm6A3l8m0sri7HzrOBeIVB6qkgucbe/YDqGNtGrbv oPZMTJVVJF2DKUArReYMcJ6fVDdLyJ7hcX4eyWqGLPTsQRO1HyFD3c34hJKSpXU5K8q2 yNVWuzFhgeaiMytriXFfF3RZHD/BS1gaORDXS5ZG9xEMtfxuJHPHsSl51a9JMyRAezFh 6jRMp0Oe1UzQ51HbgkBWeDOvwr+6czNfKOx1vIB/wZDd5Ju2OXEi/qyRWFIKZGdJ0ItB IAz/ORU8dhiPmQXTSsl1hj+E5Kg5ZCpwpObh7qD3E1hrAHg2Pb7qt2tQe6/HhEDAR5Kb 23Iw== X-Gm-Message-State: AJaThX6N6op/jzXzBrYDQR/KK3Y1ghsM3uaV8LLtYTovzuWWTAegd4kS IHPsgSvvhM6Dz+V7VCG+Y4c0wQ== X-Google-Smtp-Source: ABhQp+Se63mP3elhG7XWK4OTkhJzsAwS2XGRSO8w5nWx/jzywRn4yIeennVwBkXSrp81crGyeUU7EQ== X-Received: by 10.28.152.76 with SMTP id a73mr439096wme.127.1510149205654; Wed, 08 Nov 2017 05:53:25 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id z108sm6457274wrb.67.2017.11.08.05.53.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Nov 2017 05:53:24 -0800 (PST) Date: Wed, 8 Nov 2017 13:53:22 +0000 From: Leif Lindholm To: Haojian Zhuang Cc: "edk2-devel@lists.01.org" , Fathi Boudra Message-ID: <20171108135322.stnmshxqjaxu5xhx@bivouac.eciton.net> References: <5efb001e-f292-9f22-edae-a617147749c6@linaro.org> MIME-Version: 1.0 In-Reply-To: <5efb001e-f292-9f22-edae-a617147749c6@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) 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 13:49:26 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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? - Where is GRUB located in your SD system? - 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? / Leif