grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GRUB issue on device priority


From: Haojian Zhuang
Subject: Re: GRUB issue on device priority
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

On 2017/11/7 23:14, Vladimir 'phcoder' Serbinenko wrote:


On Tue, Nov 7, 2017, 15:23 Haojian Zhuang <address@hidden <mailto:address@hidden>> 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 address@hidden



    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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]