mbox series

[v5,00/12] efi_loader: more tightly integrate UEFI disks to driver model

Message ID 20220419010517.47175-1-takahiro.akashi@linaro.org
Headers show
Series efi_loader: more tightly integrate UEFI disks to driver model | expand

Message

AKASHI Takahiro April 19, 2022, 1:05 a.m. UTC
With this patch set[1] applied, UEFI subsystem maintains a list of its
disk objects dynamically at runtime based on block device's probing.
(See "issues" and "prerequisite" below.)

[1] https://github.com/t-akashi/u-boot/tree/efi/dm_disk

For instance,
=> dm tree
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 ...
 pci           0  [ + ]   pci_generic_ecam      |-- pcie@10000000
 ...
 ahci          0  [   ]   ahci_pci              |   |-- ahci_pci
 scsi          0  [   ]   ahci_scsi             |   |   `-- ahci_scsi
 usb           0  [   ]   xhci_pci              |   `-- xhci_pci
 ...
=> efi devices
Missing RNG device for EFI_RNG_PROTOCOL
No EFI system partition
Unable to find TPMv2 device
Device           Device Path
================ ====================
000000013eee88d0 /VenHw(..)
000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
=> scsi rescan
 ...
=> efi devices
Device           Device Path
================ ====================
000000013eee88d0 /VenHw(..)
000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
000000013eefb730 /VenHw(..)/Scsi(0,0)
000000013eefb840 /VenHw(..)/Scsi(0,0)/HD(1,GPT,ce86c5a7-b32a-488f-a346-88fe698e0edc,0x22,0x4c2a)
000000013eefbc80 /VenHw(..)/Scsi(0,0)/HD(2,GPT,aa80aab9-33e6-42b6-b5db-def2cb8d7844,0x5000,0x1a800)
=> usb start
 ...
=> efi devices
Device           Device Path
================ ====================
000000013eee88d0 /VenHw(..)
000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
000000013eefb730 /VenHw(..)/Scsi(0,0)
000000013eefb840 /VenHw(..)/Scsi(0,0)/HD(1,GPT,ce86c5a7-b32a-488f-a346-88fe698e0edc,0x22,0x4c2a)
000000013eefbc80 /VenHw(..)/Scsi(0,0)/HD(2,GPT,aa80aab9-33e6-42b6-b5db-def2cb8d7844,0x5000,0x1a800)
000000013ef01330 /VenHw(..)/UsbClass(0x0,0x0,0x9,0x0,0x3)/UsbClass(0x46f4,0x1,0x0,0x0,0x0)
000000013ef014b0 /VenHw(..)/UsbClass(0x0,0x0,0x9,0x0,0x3)/UsbClass(0x46f4,0x1,0x0,0x0,0x0)/HD(1,GPT,ce86c5a7-b32a-488f-a346-88fe698e0edc,0x22,0x4c2a)
000000013ef018f0 /VenHw(..)/UsbClass(0x0,0x0,0x9,0x0,0x3)/UsbClass(0x46f4,0x1,0x0,0x0,0x0)/HD(2,GPT,aa80aab9-33e6-42b6-b5db-def2cb8d7844,0x5000,0x1a800)
=> dm tree
 ...
 pci           0  [ + ]   pci_generic_ecam      |-- pcie@10000000
 ...
 ahci          0  [ + ]   ahci_pci              |   |-- ahci_pci
 scsi          0  [ + ]   ahci_scsi             |   |   `-- ahci_scsi
 blk           2  [ + ]   scsi_blk              |   |       `-- ahci_scsi.id0lun0
 partition     0  [ + ]   blk_partition         |   |           |-- ahci_scsi.id0lun0:1
 partition     1  [ + ]   blk_partition         |   |           `-- ahci_scsi.id0lun0:2
 usb           0  [ + ]   xhci_pci              |   `-- xhci_pci
 usb_hub       0  [ + ]   usb_hub               |       `-- usb_hub
 usb_mass_s    0  [ + ]   usb_mass_storage      |           |-- usb_mass_storage
 blk           3  [ + ]   usb_storage_blk       |           |   `-- usb_mass_storage.lun0
 partition     2  [ + ]   blk_partition         |           |       |-- usb_mass_storage.lun0:1
 partition     3  [ + ]   blk_partition         |           |       `-- usb_mass_storage.lun0:2
 ...

=> usb stop
stopping USB..
=> efi devices
Device           Device Path
================ ====================
000000013eee88d0 /VenHw(..)
000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
000000013eefb730 /VenHw(..)/Scsi(0,0)
000000013eefb840 /VenHw(..)/Scsi(0,0)/HD(1,GPT,ce86c5a7-b32a-488f-a346-88fe698e0edc,0x22,0x4c2a)
000000013eefbc80 /VenHw(..)/Scsi(0,0)/HD(2,GPT,aa80aab9-33e6-42b6-b5db-def2cb8d7844,0x5000,0x1a800)


Issues:
=======
* For removal case, we may need more consideration since removing handles
  unconditionally may end up breaking integrity of handles
  (as some may still be held and referenced to by a UEFI app).


Prerequisite:
=============
* my patch, "disk: don't compile in partition support for spl/tpl if not
  really necessary"[2]

[2] https://lists.denx.de/pipermail/u-boot/2022-April/481745.html


Patchs:
=======
For easy understandings, patches may be categorized into separate groups
of changes.

Patch#1-#3: DM: add a new feature (DM tag)
Patch#4-#10: UEFI: dynamically create/remove efi_disk's for a raw disk
  and its partitions
Patch#11-#12: UEFI: use udevice read/write interfaces


Change history:
===============
v5 (Apr, 19, 2022)
* modify patch#12 so that CONFIG_PARTITIONS can be treated as optional
  (patch#12)

v4 (Apr, 15, 2022)
* rebased on pre-2022.07-rc1
* removed already-merged patches
* added patch#1 (for better error code)
* merged v3's patch#19 to patch#7 to make bisect work
* split v3's patch#13 into patch#8(create) and patch#10(delete)
* move a function prototype out of "#ifdef CONFIG_PARTITIONS" (patch#4)
* move function prototypes out of "#ifdef CONFIG_PARTITIONS" (patch#11)

v3 (Mar 8, 2022)
* rebased on 2022.04-rc3
* rebased on v2 of Simon's event patch
  (hence removed his patch from this patch set)
* fix a spl-build error in mmc_blk_probe() (patch#3)
* fix a build warning in fsl_ata_probe()/sil_pci_probe() (patch#5)
* remove a problematic log message in efi_disk_probe() (patch#14)

v2 (Feb 10, 2022)
* add/revise an error message if device_probe() fails (patch#3,#5)
* fix a build error in sandbox_spl_defconfig (patch#8)
* fix warnings in 'make htmldocs' (patch#8,#9,#18)
* new commit: split efi_init_obj_list() (patch#14)
* new commit: simplify efi_capsule pytest (patch#21)

v1 (Feb 2, 2022)
* rebased on 2022.04-rc1
* drop patches that have already been merged
* modify a tag-range check with "tag >= DM_TAG_COUNT" (patch#9)
* move dmtag_list to GD (global data) (patch#9)
* add function descriptions and a document about DM tag feature (patch#9,10)
* add tests for DM tag support (patch#11)
* change 'depends on EVENT' to 'select EVENT' for EFI_LOADER (patch#14)
* migrate IF_TYPE_EFI to IF_TYPE_EFI_LOADER (patch#18)

RFCv2 (Dec 10, 2021)
* rebased on 2022-rc3
* re-order and merge some related commits into ones
* call device_probe() in MMC (not bind, but) probe hook (patch#5)
* fix a wrong name of variable (patch#7)
* add patch#9
* invoke device_probe() for virtio devices (patch#10)
* add DM event notification (from Simon) (patch#11)
* add DM tag support (patch#12)
* move UCLASS_PARTITION driver under disk/ (patch#13)
* create partition's dp using its parent's. This change is necessary
  in particular for 'efi_blk' efi_disk (patch#13)
* modify the code so that we will use new features like tags and
  event notification (patch#13,15,16,20)
* rename new functions from blk_read/write() to dev_read/write()
  (patch#17,18)
* isolate changes in efi_driver from the rest (in efi_loader) (patch#19)
* drop the previous patch#22 ("efi_selftest: block device: adjust dp
  for a test") due to the fix in patch#13

RFC (Nov 16, 2021)
* initial RFC

AKASHI Takahiro (12):
  dm: tag: change ENOSPC to ENOMEM
  dm: tag: add some document
  test: dm: add tests for tag support
  dm: disk: add UCLASS_PARTITION
  dm: blk: add a device-probe hook for scanning disk partitions
  efi_loader: split efi_init_obj_list() into two stages
  efi_loader: disk: a helper function to create efi_disk objects from
    udevice
  efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER)
    devices
  efi_loader: disk: a helper function to delete efi_disk objects
  efi_loader: disk: not delete BLK device for BLK(IF_TYPE_EFI_LOADER)
    devices
  dm: disk: add read/write interfaces with udevice
  efi_loader: disk: use udevice instead of blk_desc

 common/board_r.c                    |   2 +-
 common/main.c                       |   7 +-
 disk/Makefile                       |   3 +
 disk/disk-uclass.c                  | 247 +++++++++++++++++++++
 doc/develop/driver-model/design.rst |  20 ++
 drivers/block/blk-uclass.c          |   4 +
 drivers/core/tag.c                  |   4 +-
 include/dm/uclass-id.h              |   1 +
 include/efi_loader.h                |   6 +-
 include/part.h                      |  17 ++
 lib/efi_driver/efi_block_device.c   |  34 +--
 lib/efi_loader/Kconfig              |   3 +
 lib/efi_loader/efi_disk.c           | 321 +++++++++++++++++++++-------
 lib/efi_loader/efi_setup.c          |  62 ++++--
 test/dm/Makefile                    |   1 +
 test/dm/tag.c                       |  84 ++++++++
 16 files changed, 694 insertions(+), 122 deletions(-)
 create mode 100644 disk/disk-uclass.c
 create mode 100644 test/dm/tag.c

Comments

Heinrich Schuchardt April 25, 2022, 8:43 p.m. UTC | #1
On 4/19/22 03:05, AKASHI Takahiro wrote:
> With this patch set[1] applied, UEFI subsystem maintains a list of its
> disk objects dynamically at runtime based on block device's probing.
> (See "issues" and "prerequisite" below.)
>
> [1] https://github.com/t-akashi/u-boot/tree/efi/dm_disk
>
> For instance,
> => dm tree
>   Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>   root          0  [ + ]   root_driver           root_driver
>   ...
>   pci           0  [ + ]   pci_generic_ecam      |-- pcie@10000000
>   ...
>   ahci          0  [   ]   ahci_pci              |   |-- ahci_pci
>   scsi          0  [   ]   ahci_scsi             |   |   `-- ahci_scsi
>   usb           0  [   ]   xhci_pci              |   `-- xhci_pci
>   ...
> => efi devices
> Missing RNG device for EFI_RNG_PROTOCOL
> No EFI system partition
> Unable to find TPMv2 device
> Device           Device Path
> ================ ====================
> 000000013eee88d0 /VenHw(..)
> 000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
> 000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
> => scsi rescan


With the series binding block devices after initializing the UEFI
sub-system works fine. Also unbinding is reflected in the EFI devices.

But this series breaks UEFI compliance. All block devices must be probed
before booting. Without this GRUB will not be able to read the boot
partition with vmlinuz and initrd.

Will you provide the missing patch?

Best regards

Heinrich
AKASHI Takahiro April 25, 2022, 11:44 p.m. UTC | #2
On Mon, Apr 25, 2022 at 10:43:44PM +0200, Heinrich Schuchardt wrote:
> On 4/19/22 03:05, AKASHI Takahiro wrote:
> > With this patch set[1] applied, UEFI subsystem maintains a list of its
> > disk objects dynamically at runtime based on block device's probing.
> > (See "issues" and "prerequisite" below.)
> > 
> > [1] https://github.com/t-akashi/u-boot/tree/efi/dm_disk
> > 
> > For instance,
> > => dm tree
> >   Class     Index  Probed  Driver                Name
> > -----------------------------------------------------------
> >   root          0  [ + ]   root_driver           root_driver
> >   ...
> >   pci           0  [ + ]   pci_generic_ecam      |-- pcie@10000000
> >   ...
> >   ahci          0  [   ]   ahci_pci              |   |-- ahci_pci
> >   scsi          0  [   ]   ahci_scsi             |   |   `-- ahci_scsi
> >   usb           0  [   ]   xhci_pci              |   `-- xhci_pci
> >   ...
> > => efi devices
> > Missing RNG device for EFI_RNG_PROTOCOL
> > No EFI system partition
> > Unable to find TPMv2 device
> > Device           Device Path
> > ================ ====================
> > 000000013eee88d0 /VenHw(..)
> > 000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
> > 000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
> > => scsi rescan
> 
> 
> With the series binding block devices after initializing the UEFI
> sub-system works fine. Also unbinding is reflected in the EFI devices.
> 
> But this series breaks UEFI compliance.

I don't think so.

> All block devices must be probed
> before booting.

This (not enumerating all the devices) is also true even before my patch.

> Without this GRUB will not be able to read the boot
> partition with vmlinuz and initrd.

I'm not sure what you expect here, but
is it enough to define "preboot" variables with any number of
enumerating commands, like "scsi rescan", "usb start" and so on?

# Again, this method can also be applied even without my patch.

-Takahiro Akashi

> Will you provide the missing patch?
> 
> Best regards
> 
> Heinrich
Heinrich Schuchardt April 26, 2022, 1:57 p.m. UTC | #3
On 4/26/22 01:44, AKASHI Takahiro wrote:
> On Mon, Apr 25, 2022 at 10:43:44PM +0200, Heinrich Schuchardt wrote:
>> On 4/19/22 03:05, AKASHI Takahiro wrote:
>>> With this patch set[1] applied, UEFI subsystem maintains a list of its
>>> disk objects dynamically at runtime based on block device's probing.
>>> (See "issues" and "prerequisite" below.)
>>>
>>> [1] https://github.com/t-akashi/u-boot/tree/efi/dm_disk
>>>
>>> For instance,
>>> => dm tree
>>>    Class     Index  Probed  Driver                Name
>>> -----------------------------------------------------------
>>>    root          0  [ + ]   root_driver           root_driver
>>>    ...
>>>    pci           0  [ + ]   pci_generic_ecam      |-- pcie@10000000
>>>    ...
>>>    ahci          0  [   ]   ahci_pci              |   |-- ahci_pci
>>>    scsi          0  [   ]   ahci_scsi             |   |   `-- ahci_scsi
>>>    usb           0  [   ]   xhci_pci              |   `-- xhci_pci
>>>    ...
>>> => efi devices
>>> Missing RNG device for EFI_RNG_PROTOCOL
>>> No EFI system partition
>>> Unable to find TPMv2 device
>>> Device           Device Path
>>> ================ ====================
>>> 000000013eee88d0 /VenHw(..)
>>> 000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
>>> 000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
>>> => scsi rescan
>>
>>
>> With the series binding block devices after initializing the UEFI
>> sub-system works fine. Also unbinding is reflected in the EFI devices.
>>
>> But this series breaks UEFI compliance.
>
> I don't think so.
>
>> All block devices must be probed
>> before booting.
>
> This (not enumerating all the devices) is also true even before my patch.
>
>> Without this GRUB will not be able to read the boot
>> partition with vmlinuz and initrd.
>
> I'm not sure what you expect here, but
> is it enough to define "preboot" variables with any number of
> enumerating commands, like "scsi rescan", "usb start" and so on?

I expect that boards that booted with previous versions of U-Boot using
the respective defconfig still boot. But they don't. Here is one example
(orangepi_pc_defconfig):

     Found U-Boot script /boot.scr.uimg
     189 bytes read in 2 ms (91.8 KiB/s)
     ## Executing script at 43100000
     22979 bytes read in 8 ms (2.7 MiB/s)
     98304 bytes read in 8 ms (11.7 MiB/s)
     Booting /EFI\debian\grubarm.efi
     Welcome to GRUB!

     error: disk `,msdos2' not found.
     grub rescue>

In U-Boot v2022.04 function efi_disk_register() ensured that all block
devices and their partitions were added as EFI handles. But that
function is missing now.

Best regards

Heinrich


>
> # Again, this method can also be applied even without my patch.
>
> -Takahiro Akashi
>
>> Will you provide the missing patch?
>>
>> Best regards
>>
>> Heinrich
AKASHI Takahiro April 26, 2022, 2:44 p.m. UTC | #4
On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
> On 4/26/22 01:44, AKASHI Takahiro wrote:
> > On Mon, Apr 25, 2022 at 10:43:44PM +0200, Heinrich Schuchardt wrote:
> > > On 4/19/22 03:05, AKASHI Takahiro wrote:
> > > > With this patch set[1] applied, UEFI subsystem maintains a list of its
> > > > disk objects dynamically at runtime based on block device's probing.
> > > > (See "issues" and "prerequisite" below.)
> > > > 
> > > > [1] https://github.com/t-akashi/u-boot/tree/efi/dm_disk
> > > > 
> > > > For instance,
> > > > => dm tree
> > > >    Class     Index  Probed  Driver                Name
> > > > -----------------------------------------------------------
> > > >    root          0  [ + ]   root_driver           root_driver
> > > >    ...
> > > >    pci           0  [ + ]   pci_generic_ecam      |-- pcie@10000000
> > > >    ...
> > > >    ahci          0  [   ]   ahci_pci              |   |-- ahci_pci
> > > >    scsi          0  [   ]   ahci_scsi             |   |   `-- ahci_scsi
> > > >    usb           0  [   ]   xhci_pci              |   `-- xhci_pci
> > > >    ...
> > > > => efi devices
> > > > Missing RNG device for EFI_RNG_PROTOCOL
> > > > No EFI system partition
> > > > Unable to find TPMv2 device
> > > > Device           Device Path
> > > > ================ ====================
> > > > 000000013eee88d0 /VenHw(..)
> > > > 000000013ffeb798 /VenHw(..)/Uart(0,0,D,D)
> > > > 000000013eeeb810 /VenHw(..)/MAC(525252525252,1)
> > > > => scsi rescan
> > > 
> > > 
> > > With the series binding block devices after initializing the UEFI
> > > sub-system works fine. Also unbinding is reflected in the EFI devices.
> > > 
> > > But this series breaks UEFI compliance.
> > 
> > I don't think so.
> > 
> > > All block devices must be probed
> > > before booting.
> > 
> > This (not enumerating all the devices) is also true even before my patch.
> > 
> > > Without this GRUB will not be able to read the boot
> > > partition with vmlinuz and initrd.
> > 
> > I'm not sure what you expect here, but
> > is it enough to define "preboot" variables with any number of
> > enumerating commands, like "scsi rescan", "usb start" and so on?
> 
> I expect that boards that booted with previous versions of U-Boot using
> the respective defconfig still boot. But they don't. Here is one example
> (orangepi_pc_defconfig):
> 
>     Found U-Boot script /boot.scr.uimg
>     189 bytes read in 2 ms (91.8 KiB/s)
>     ## Executing script at 43100000
>     22979 bytes read in 8 ms (2.7 MiB/s)
>     98304 bytes read in 8 ms (11.7 MiB/s)
>     Booting /EFI\debian\grubarm.efi
>     Welcome to GRUB!
> 
>     error: disk `,msdos2' not found.
>     grub rescue>
> 
> In U-Boot v2022.04 function efi_disk_register() ensured that all block
> devices and their partitions were added as EFI handles.

Not the all block devices, but the block devices which have already
enumerated when efi_init_obj_list() is called.

> But that
> function is missing now.

What (boot) device are you using here?

Please show me the values of env variables, particularly, "boot_targets".

Please show me the content of boot.scr.uimg, too.

Please show me the output from
=> dm tree
=> efidebug devices
for 2022.04 and 2022.07-rc1.

-Takahiro Akashi



> Best regards
> 
> Heinrich
> 
> 
> > 
> > # Again, this method can also be applied even without my patch.
> > 
> > -Takahiro Akashi
> > 
> > > Will you provide the missing patch?
> > > 
> > > Best regards
> > > 
> > > Heinrich
>
Heinrich Schuchardt April 26, 2022, 5:02 p.m. UTC | #5
On 4/26/22 16:44, AKASHI Takahiro wrote:
> On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
>> On 4/26/22 01:44, AKASHI Takahiro wrote:
>> I expect that boards that booted with previous versions of U-Boot using
>> the respective defconfig still boot. But they don't. Here is one example
>> (orangepi_pc_defconfig):
>>
>>     Found U-Boot script /boot.scr.uimg
>>     189 bytes read in 2 ms (91.8 KiB/s)
>>     ## Executing script at 43100000
>>     22979 bytes read in 8 ms (2.7 MiB/s)
>>     98304 bytes read in 8 ms (11.7 MiB/s)
>>     Booting /EFI\debian\grubarm.efi
>>     Welcome to GRUB!
>>
>>     error: disk `,msdos2' not found.
>>     grub rescue>
>>
>> In U-Boot v2022.04 function efi_disk_register() ensured that all block
>> devices and their partitions were added as EFI handles.
> Not the all block devices, but the block devices which have already
> enumerated when efi_init_obj_list() is called.
>
>> But that
>> function is missing now.
> What (boot) device are you using here?
>
> Please show me the values of env variables, particularly, "boot_targets".
>
> Please show me the content of boot.scr.uimg, too.
>
> Please show me the output from
> => dm tree
> => efidebug devices
> for 2022.04 and 2022.07-rc1.
>
> -Takahiro Akashi
>
>
>


I am booting from mmc. Boot.scr just loads the device-tree from mmc-

mmcblk0     179:0    0 29.8G  0 disk
├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
├─mmcblk0p2 179:2    0    1G  0 part /boot
└─mmcblk0p3 179:3    0 27.8G  0 part /


U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
------------------------------------------------------------------

grub> ls
(hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)

hd0 is a USB stick
hd1 is the SD card

boot.scr
--------

#
# flash-kernel: bootscr.sunxi
#

# boot script for Allwinner SunXi-based devices

# Mainline u-boot v2014.10 introduces a new default environment and
# a new common bootcmd handling for all platforms, which is not fully
# compatible with the old-style environment used by u-boot-sunxi.
# This script therefore needs to check in which environment it
# is running and set some variables accordingly.

# On u-boot-sunxi, this script assumes that ${device} and ${partition}
# are set.

# The new-style environment predefines ${boot_targets}, the old-style
# environment does not.
if test -n "${boot_targets}"
then
  echo "Mainline u-boot / new-style environment detected."
  # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
  # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
  # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
  if test -z "${device}"; then setenv device "${devtype}"; fi
  if test -z "${partition}${distro_bootpart}"; then setenv partition
"${devnum}:${bootpart}"; fi
  if test -z "${partition}"; then setenv partition
"${devnum}:${distro_bootpart}"; fi
else
  echo "U-boot-sunxi / old-style environment detected."
  # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
  # ramdisk_addr_r, so they have to be manually set. Use the values
  # from mainline u-boot v2014.10, except for ramdisk_addr_r,
  # which is set to 0x44300000 to allow for initrds larger than
  # 13MB on u-boot-sunxi.
  setenv kernel_addr_r 0x42000000
  setenv fdt_addr_r 0x43000000
  setenv ramdisk_addr_r 0x44300000
fi

if test -n "${console}"; then
  setenv bootargs "${bootargs} console=${console}"
fi

setenv bootargs  ${bootargs} quiet


if test -z "${image_locations}"; then
   setenv image_locations ${prefix}
fi
if test -z "${image_locations}"; then
   setenv image_locations /boot/ /
fi

if test -z "${fk_kvers}"; then
   setenv fk_kvers '5.16.0-4-armmp-lpae'
fi

if test -n "${fdtfile}"; then
   setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
else
   setenv fdtpath dtb-${fk_kvers}
fi

for pathprefix in ${image_locations}
do
  if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
  then
    load ${device} ${partition} ${kernel_addr_r}
${pathprefix}vmlinuz-${fk_kvers} \
    && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
    && load ${device} ${partition} ${ramdisk_addr_r}
${pathprefix}initrd.img-${fk_kvers} \
    && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
    && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
  fi
done


U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology

=> echo $boot_targets
fel mmc0 usb0 pxe dhcp

=> dm tree
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 video         0  [   ]   sunxi_de2             |-- sunxi_de2
 display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
 simple_bus    0  [ + ]   simple_bus            |-- soc
 mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
 blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
 phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
 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
 clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
 reset         0  [ + ]   sunxi_reset           |   |   `-- reset
 gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
 gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
 gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
 gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
 gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
 gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
 gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
 gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
 gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
 gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
 ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
 watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
 sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
 serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
 clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
 clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
 reset         1  [   ]   sunxi_reset           |   |   `-- reset
 i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
 gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
 gpio         11  [ + ]   gpio_sunxi            |       `-- PL
 clk           3  [ + ]   fixed_clock           |-- osc24M_clk
 clk           4  [   ]   fixed_clock           `-- osc32k_clk



U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology

=> echo $boot_targets
fel mmc0 usb0 pxe dhcp

=> dm tree
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 video         0  [   ]   sunxi_de2             |-- sunxi_de2
 display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
 simple_bus    0  [ + ]   simple_bus            |-- soc
 mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
 blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
 partition     0  [ + ]   blk_partition         |   |   |   |--
mmc@1c0f000.blk:1
 partition     1  [ + ]   blk_partition         |   |   |   |--
mmc@1c0f000.blk:2
 partition     2  [ + ]   blk_partition         |   |   |   `--
mmc@1c0f000.blk:3
 bootdev       0  [   ]   mmc_bootdev           |   |   `--
mmc@1c0f000.bootdev
 phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
 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
 partition     3  [ + ]   blk_partition         |   |           |   `--
usb_mass_storage.lun0:1
 bootdev       3  [   ]   usb_bootdev           |   |           `--
usb_mass_storage.lun0.bootdev
 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
 clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
 reset         0  [ + ]   sunxi_reset           |   |   `-- reset
 pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
 gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
 gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
 gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
 gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
 gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
 gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
 gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
 gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
 pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
 pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
 pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
 pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
 pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
 pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
 pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
 pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
 pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
 pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
 pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
 pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
 pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
 pinconfig    13  [   ]   pinconfig             |   |   |--
uart1-rts-cts-pins
 pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
 pinconfig    15  [   ]   pinconfig             |   |   |--
uart2-rts-cts-pins
 pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
 pinconfig    17  [   ]   pinconfig             |   |   |--
uart3-rts-cts-pins
 pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
 pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
 pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
 pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
 ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
 bootdev       1  [   ]   eth_bootdev           |   |   `--
ethernet@1c30000.bootdev
 watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
 sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
 serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
 clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
 clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
 reset         1  [   ]   sunxi_reset           |   |   `-- reset
 i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
 pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
 gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
 gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
 pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
 pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
 pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
 clk           3  [ + ]   fixed_clock           |-- osc24M_clk
 clk           4  [   ]   fixed_clock           |-- osc32k_clk
 bootstd       0  [   ]   bootstd_drv           `-- bootstd
 bootmeth      0  [   ]   bootmeth_distro           |-- distro
 bootmeth      1  [   ]   bootmeth_efi              |-- efi
 bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
 bootdev       2  [   ]   system_bootdev            `-- system-bootdev

grub rescue> ls
(hd0)

Grub does not see any partition at all.

Loading a device from a partition does not create a handle for the device:

=> efidebug devices
** Unable to read file ubootefi.var **
Failed to load EFI variables
Device   Device Path
======== ====================
79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
79f7f1f8
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
79f7f2a0
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
=> bootefi $kernel_addr_r
Booting /helloworld.efi
invalid image type: 0
Hello, world!
=> efidebug devices
Device   Device Path
======== ====================
79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
79f7f1f8
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
79f7f2a0
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
=>

So the current state is a complete mess.

Best regards

Heinrich
Mark Kettenis April 26, 2022, 5:18 p.m. UTC | #6
> Date: Tue, 26 Apr 2022 19:02:46 +0200
> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> On 4/26/22 16:44, AKASHI Takahiro wrote:
> > On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
> >> On 4/26/22 01:44, AKASHI Takahiro wrote:
> >> I expect that boards that booted with previous versions of U-Boot using
> >> the respective defconfig still boot. But they don't. Here is one example
> >> (orangepi_pc_defconfig):
> >>
> >>     Found U-Boot script /boot.scr.uimg
> >>     189 bytes read in 2 ms (91.8 KiB/s)
> >>     ## Executing script at 43100000
> >>     22979 bytes read in 8 ms (2.7 MiB/s)
> >>     98304 bytes read in 8 ms (11.7 MiB/s)
> >>     Booting /EFI\debian\grubarm.efi
> >>     Welcome to GRUB!
> >>
> >>     error: disk `,msdos2' not found.
> >>     grub rescue>
> >>
> >> In U-Boot v2022.04 function efi_disk_register() ensured that all block
> >> devices and their partitions were added as EFI handles.
> > Not the all block devices, but the block devices which have already
> > enumerated when efi_init_obj_list() is called.
> >
> >> But that
> >> function is missing now.
> > What (boot) device are you using here?
> >
> > Please show me the values of env variables, particularly, "boot_targets".
> >
> > Please show me the content of boot.scr.uimg, too.
> >
> > Please show me the output from
> > => dm tree
> > => efidebug devices
> > for 2022.04 and 2022.07-rc1.
> >
> > -Takahiro Akashi
> >
> >
> >
> 
> 
> I am booting from mmc. Boot.scr just loads the device-tree from mmc-
> 
> mmcblk0     179:0    0 29.8G  0 disk
> ├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
> ├─mmcblk0p2 179:2    0    1G  0 part /boot
> └─mmcblk0p3 179:3    0 27.8G  0 part /
> 
> 
> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> ------------------------------------------------------------------
> 
> grub> ls
> (hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)
> 
> hd0 is a USB stick
> hd1 is the SD card
> 
> boot.scr
> --------
> 
> #
> # flash-kernel: bootscr.sunxi
> #
> 
> # boot script for Allwinner SunXi-based devices
> 
> # Mainline u-boot v2014.10 introduces a new default environment and
> # a new common bootcmd handling for all platforms, which is not fully
> # compatible with the old-style environment used by u-boot-sunxi.
> # This script therefore needs to check in which environment it
> # is running and set some variables accordingly.
> 
> # On u-boot-sunxi, this script assumes that ${device} and ${partition}
> # are set.
> 
> # The new-style environment predefines ${boot_targets}, the old-style
> # environment does not.
> if test -n "${boot_targets}"
> then
>   echo "Mainline u-boot / new-style environment detected."
>   # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
>   # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
>   # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
>   if test -z "${device}"; then setenv device "${devtype}"; fi
>   if test -z "${partition}${distro_bootpart}"; then setenv partition
> "${devnum}:${bootpart}"; fi
>   if test -z "${partition}"; then setenv partition
> "${devnum}:${distro_bootpart}"; fi
> else
>   echo "U-boot-sunxi / old-style environment detected."
>   # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
>   # ramdisk_addr_r, so they have to be manually set. Use the values
>   # from mainline u-boot v2014.10, except for ramdisk_addr_r,
>   # which is set to 0x44300000 to allow for initrds larger than
>   # 13MB on u-boot-sunxi.
>   setenv kernel_addr_r 0x42000000
>   setenv fdt_addr_r 0x43000000
>   setenv ramdisk_addr_r 0x44300000
> fi
> 
> if test -n "${console}"; then
>   setenv bootargs "${bootargs} console=${console}"
> fi
> 
> setenv bootargs  ${bootargs} quiet
> 
> 
> if test -z "${image_locations}"; then
>    setenv image_locations ${prefix}
> fi
> if test -z "${image_locations}"; then
>    setenv image_locations /boot/ /
> fi
> 
> if test -z "${fk_kvers}"; then
>    setenv fk_kvers '5.16.0-4-armmp-lpae'
> fi
> 
> if test -n "${fdtfile}"; then
>    setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
> else
>    setenv fdtpath dtb-${fk_kvers}
> fi
> 
> for pathprefix in ${image_locations}
> do
>   if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
>   then
>     load ${device} ${partition} ${kernel_addr_r}
> ${pathprefix}vmlinuz-${fk_kvers} \
>     && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
>     && load ${device} ${partition} ${ramdisk_addr_r}
> ${pathprefix}initrd.img-${fk_kvers} \
>     && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
>     && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
>   fi
> done
> 
> 
> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> 
> => echo $boot_targets
> fel mmc0 usb0 pxe dhcp
> 
> => dm tree
>  Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>  root          0  [ + ]   root_driver           root_driver
>  video         0  [   ]   sunxi_de2             |-- sunxi_de2
>  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
>  simple_bus    0  [ + ]   simple_bus            |-- soc
>  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>  blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
>  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
>  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
>  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
>  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>  gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
>  gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
>  gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
>  gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
>  gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
>  gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
>  gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
>  gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
>  gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
>  gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
>  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
>  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
>  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
>  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
>  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
>  clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
>  reset         1  [   ]   sunxi_reset           |   |   `-- reset
>  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
>  gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
>  gpio         11  [ + ]   gpio_sunxi            |       `-- PL
>  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
>  clk           4  [   ]   fixed_clock           `-- osc32k_clk
> 
> 
> 
> U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology
> 
> => echo $boot_targets
> fel mmc0 usb0 pxe dhcp
> 
> => dm tree
>  Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>  root          0  [ + ]   root_driver           root_driver
>  video         0  [   ]   sunxi_de2             |-- sunxi_de2
>  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
>  simple_bus    0  [ + ]   simple_bus            |-- soc
>  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>  blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
>  partition     0  [ + ]   blk_partition         |   |   |   |--
> mmc@1c0f000.blk:1
>  partition     1  [ + ]   blk_partition         |   |   |   |--
> mmc@1c0f000.blk:2
>  partition     2  [ + ]   blk_partition         |   |   |   `--
> mmc@1c0f000.blk:3
>  bootdev       0  [   ]   mmc_bootdev           |   |   `--
> mmc@1c0f000.bootdev
>  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
>  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
>  partition     3  [ + ]   blk_partition         |   |           |   `--
> usb_mass_storage.lun0:1
>  bootdev       3  [   ]   usb_bootdev           |   |           `--
> usb_mass_storage.lun0.bootdev
>  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
>  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
>  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>  pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
>  gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
>  gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
>  gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
>  gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
>  gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
>  gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
>  gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
>  gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
>  pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
>  pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
>  pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
>  pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
>  pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
>  pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
>  pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
>  pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
>  pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
>  pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
>  pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
>  pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
>  pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
>  pinconfig    13  [   ]   pinconfig             |   |   |--
> uart1-rts-cts-pins
>  pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
>  pinconfig    15  [   ]   pinconfig             |   |   |--
> uart2-rts-cts-pins
>  pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
>  pinconfig    17  [   ]   pinconfig             |   |   |--
> uart3-rts-cts-pins
>  pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
>  pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
>  pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
>  pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
>  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
>  bootdev       1  [   ]   eth_bootdev           |   |   `--
> ethernet@1c30000.bootdev
>  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
>  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
>  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
>  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
>  clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
>  reset         1  [   ]   sunxi_reset           |   |   `-- reset
>  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
>  pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
>  gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
>  gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
>  pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
>  pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
>  pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
>  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
>  clk           4  [   ]   fixed_clock           |-- osc32k_clk
>  bootstd       0  [   ]   bootstd_drv           `-- bootstd
>  bootmeth      0  [   ]   bootmeth_distro           |-- distro
>  bootmeth      1  [   ]   bootmeth_efi              |-- efi
>  bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
>  bootdev       2  [   ]   system_bootdev            `-- system-bootdev
> 
> grub rescue> ls
> (hd0)
> 
> Grub does not see any partition at all.
> 
> Loading a device from a partition does not create a handle for the device:
> 
> => efidebug devices
> ** Unable to read file ubootefi.var **
> Failed to load EFI variables
> Device   Device Path
> ======== ====================
> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> 79f7f1f8
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> 79f7f2a0
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> => bootefi $kernel_addr_r
> Booting /helloworld.efi
> invalid image type: 0
> Hello, world!
> => efidebug devices
> Device   Device Path
> ======== ====================
> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> 79f7f1f8
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> 79f7f2a0
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> =>
> 
> So the current state is a complete mess.

Also see the breakage I just found concerning raw disk access.

Should this series be reverted?
Tom Rini April 26, 2022, 5:23 p.m. UTC | #7
On Tue, Apr 26, 2022 at 07:18:13PM +0200, Mark Kettenis wrote:
> > Date: Tue, 26 Apr 2022 19:02:46 +0200
> > From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > 
> > On 4/26/22 16:44, AKASHI Takahiro wrote:
> > > On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
> > >> On 4/26/22 01:44, AKASHI Takahiro wrote:
> > >> I expect that boards that booted with previous versions of U-Boot using
> > >> the respective defconfig still boot. But they don't. Here is one example
> > >> (orangepi_pc_defconfig):
> > >>
> > >>     Found U-Boot script /boot.scr.uimg
> > >>     189 bytes read in 2 ms (91.8 KiB/s)
> > >>     ## Executing script at 43100000
> > >>     22979 bytes read in 8 ms (2.7 MiB/s)
> > >>     98304 bytes read in 8 ms (11.7 MiB/s)
> > >>     Booting /EFI\debian\grubarm.efi
> > >>     Welcome to GRUB!
> > >>
> > >>     error: disk `,msdos2' not found.
> > >>     grub rescue>
> > >>
> > >> In U-Boot v2022.04 function efi_disk_register() ensured that all block
> > >> devices and their partitions were added as EFI handles.
> > > Not the all block devices, but the block devices which have already
> > > enumerated when efi_init_obj_list() is called.
> > >
> > >> But that
> > >> function is missing now.
> > > What (boot) device are you using here?
> > >
> > > Please show me the values of env variables, particularly, "boot_targets".
> > >
> > > Please show me the content of boot.scr.uimg, too.
> > >
> > > Please show me the output from
> > > => dm tree
> > > => efidebug devices
> > > for 2022.04 and 2022.07-rc1.
> > >
> > > -Takahiro Akashi
> > >
> > >
> > >
> > 
> > 
> > I am booting from mmc. Boot.scr just loads the device-tree from mmc-
> > 
> > mmcblk0     179:0    0 29.8G  0 disk
> > ├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
> > ├─mmcblk0p2 179:2    0    1G  0 part /boot
> > └─mmcblk0p3 179:3    0 27.8G  0 part /
> > 
> > 
> > U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> > ------------------------------------------------------------------
> > 
> > grub> ls
> > (hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)
> > 
> > hd0 is a USB stick
> > hd1 is the SD card
> > 
> > boot.scr
> > --------
> > 
> > #
> > # flash-kernel: bootscr.sunxi
> > #
> > 
> > # boot script for Allwinner SunXi-based devices
> > 
> > # Mainline u-boot v2014.10 introduces a new default environment and
> > # a new common bootcmd handling for all platforms, which is not fully
> > # compatible with the old-style environment used by u-boot-sunxi.
> > # This script therefore needs to check in which environment it
> > # is running and set some variables accordingly.
> > 
> > # On u-boot-sunxi, this script assumes that ${device} and ${partition}
> > # are set.
> > 
> > # The new-style environment predefines ${boot_targets}, the old-style
> > # environment does not.
> > if test -n "${boot_targets}"
> > then
> >   echo "Mainline u-boot / new-style environment detected."
> >   # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
> >   # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
> >   # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
> >   if test -z "${device}"; then setenv device "${devtype}"; fi
> >   if test -z "${partition}${distro_bootpart}"; then setenv partition
> > "${devnum}:${bootpart}"; fi
> >   if test -z "${partition}"; then setenv partition
> > "${devnum}:${distro_bootpart}"; fi
> > else
> >   echo "U-boot-sunxi / old-style environment detected."
> >   # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
> >   # ramdisk_addr_r, so they have to be manually set. Use the values
> >   # from mainline u-boot v2014.10, except for ramdisk_addr_r,
> >   # which is set to 0x44300000 to allow for initrds larger than
> >   # 13MB on u-boot-sunxi.
> >   setenv kernel_addr_r 0x42000000
> >   setenv fdt_addr_r 0x43000000
> >   setenv ramdisk_addr_r 0x44300000
> > fi
> > 
> > if test -n "${console}"; then
> >   setenv bootargs "${bootargs} console=${console}"
> > fi
> > 
> > setenv bootargs  ${bootargs} quiet
> > 
> > 
> > if test -z "${image_locations}"; then
> >    setenv image_locations ${prefix}
> > fi
> > if test -z "${image_locations}"; then
> >    setenv image_locations /boot/ /
> > fi
> > 
> > if test -z "${fk_kvers}"; then
> >    setenv fk_kvers '5.16.0-4-armmp-lpae'
> > fi
> > 
> > if test -n "${fdtfile}"; then
> >    setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
> > else
> >    setenv fdtpath dtb-${fk_kvers}
> > fi
> > 
> > for pathprefix in ${image_locations}
> > do
> >   if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
> >   then
> >     load ${device} ${partition} ${kernel_addr_r}
> > ${pathprefix}vmlinuz-${fk_kvers} \
> >     && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
> >     && load ${device} ${partition} ${ramdisk_addr_r}
> > ${pathprefix}initrd.img-${fk_kvers} \
> >     && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
> >     && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
> >   fi
> > done
> > 
> > 
> > U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> > 
> > => echo $boot_targets
> > fel mmc0 usb0 pxe dhcp
> > 
> > => dm tree
> >  Class     Index  Probed  Driver                Name
> > -----------------------------------------------------------
> >  root          0  [ + ]   root_driver           root_driver
> >  video         0  [   ]   sunxi_de2             |-- sunxi_de2
> >  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
> >  simple_bus    0  [ + ]   simple_bus            |-- soc
> >  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
> >  blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
> >  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
> >  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
> >  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
> >  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
> >  gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
> >  gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
> >  gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
> >  gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
> >  gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
> >  gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
> >  gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
> >  gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
> >  gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
> >  gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
> >  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
> >  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
> >  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
> >  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
> >  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
> >  clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
> >  reset         1  [   ]   sunxi_reset           |   |   `-- reset
> >  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
> >  gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
> >  gpio         11  [ + ]   gpio_sunxi            |       `-- PL
> >  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
> >  clk           4  [   ]   fixed_clock           `-- osc32k_clk
> > 
> > 
> > 
> > U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology
> > 
> > => echo $boot_targets
> > fel mmc0 usb0 pxe dhcp
> > 
> > => dm tree
> >  Class     Index  Probed  Driver                Name
> > -----------------------------------------------------------
> >  root          0  [ + ]   root_driver           root_driver
> >  video         0  [   ]   sunxi_de2             |-- sunxi_de2
> >  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
> >  simple_bus    0  [ + ]   simple_bus            |-- soc
> >  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
> >  blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
> >  partition     0  [ + ]   blk_partition         |   |   |   |--
> > mmc@1c0f000.blk:1
> >  partition     1  [ + ]   blk_partition         |   |   |   |--
> > mmc@1c0f000.blk:2
> >  partition     2  [ + ]   blk_partition         |   |   |   `--
> > mmc@1c0f000.blk:3
> >  bootdev       0  [   ]   mmc_bootdev           |   |   `--
> > mmc@1c0f000.bootdev
> >  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
> >  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
> >  partition     3  [ + ]   blk_partition         |   |           |   `--
> > usb_mass_storage.lun0:1
> >  bootdev       3  [   ]   usb_bootdev           |   |           `--
> > usb_mass_storage.lun0.bootdev
> >  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
> >  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
> >  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
> >  pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
> >  gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
> >  gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
> >  gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
> >  gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
> >  gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
> >  gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
> >  gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
> >  gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
> >  pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
> >  pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
> >  pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
> >  pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
> >  pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
> >  pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
> >  pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
> >  pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
> >  pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
> >  pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
> >  pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
> >  pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
> >  pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
> >  pinconfig    13  [   ]   pinconfig             |   |   |--
> > uart1-rts-cts-pins
> >  pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
> >  pinconfig    15  [   ]   pinconfig             |   |   |--
> > uart2-rts-cts-pins
> >  pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
> >  pinconfig    17  [   ]   pinconfig             |   |   |--
> > uart3-rts-cts-pins
> >  pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
> >  pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
> >  pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
> >  pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
> >  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
> >  bootdev       1  [   ]   eth_bootdev           |   |   `--
> > ethernet@1c30000.bootdev
> >  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
> >  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
> >  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
> >  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
> >  clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
> >  reset         1  [   ]   sunxi_reset           |   |   `-- reset
> >  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
> >  pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
> >  gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
> >  gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
> >  pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
> >  pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
> >  pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
> >  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
> >  clk           4  [   ]   fixed_clock           |-- osc32k_clk
> >  bootstd       0  [   ]   bootstd_drv           `-- bootstd
> >  bootmeth      0  [   ]   bootmeth_distro           |-- distro
> >  bootmeth      1  [   ]   bootmeth_efi              |-- efi
> >  bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
> >  bootdev       2  [   ]   system_bootdev            `-- system-bootdev
> > 
> > grub rescue> ls
> > (hd0)
> > 
> > Grub does not see any partition at all.
> > 
> > Loading a device from a partition does not create a handle for the device:
> > 
> > => efidebug devices
> > ** Unable to read file ubootefi.var **
> > Failed to load EFI variables
> > Device   Device Path
> > ======== ====================
> > 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> > 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> > 79f7f1f8
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> > 79f7f2a0
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> > 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> > => bootefi $kernel_addr_r
> > Booting /helloworld.efi
> > invalid image type: 0
> > Hello, world!
> > => efidebug devices
> > Device   Device Path
> > ======== ====================
> > 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> > 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> > 79f7f1f8
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> > 79f7f2a0
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> > 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> > =>
> > 
> > So the current state is a complete mess.
> 
> Also see the breakage I just found concerning raw disk access.
> 
> Should this series be reverted?

We're at -rc1, there's plenty of time to figure out what the right
solution is.
AKASHI Takahiro April 27, 2022, 3:26 a.m. UTC | #8
Heinrich,

On Tue, Apr 26, 2022 at 07:02:46PM +0200, Heinrich Schuchardt wrote:
> On 4/26/22 16:44, AKASHI Takahiro wrote:
> > On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
> >> On 4/26/22 01:44, AKASHI Takahiro wrote:
> >> I expect that boards that booted with previous versions of U-Boot using
> >> the respective defconfig still boot. But they don't. Here is one example
> >> (orangepi_pc_defconfig):
> >>
> >>     Found U-Boot script /boot.scr.uimg
> >>     189 bytes read in 2 ms (91.8 KiB/s)
> >>     ## Executing script at 43100000
> >>     22979 bytes read in 8 ms (2.7 MiB/s)
> >>     98304 bytes read in 8 ms (11.7 MiB/s)
> >>     Booting /EFI\debian\grubarm.efi
> >>     Welcome to GRUB!
> >>
> >>     error: disk `,msdos2' not found.
> >>     grub rescue>
> >>
> >> In U-Boot v2022.04 function efi_disk_register() ensured that all block
> >> devices and their partitions were added as EFI handles.
> > Not the all block devices, but the block devices which have already
> > enumerated when efi_init_obj_list() is called.
> >
> >> But that
> >> function is missing now.
> > What (boot) device are you using here?
> >
> > Please show me the values of env variables, particularly, "boot_targets".
> >
> > Please show me the content of boot.scr.uimg, too.
> >
> > Please show me the output from
> > => dm tree
> > => efidebug devices
> > for 2022.04 and 2022.07-rc1.
> >
> > -Takahiro Akashi
> >
> >
> >
> 
> 
> I am booting from mmc. Boot.scr just loads the device-tree from mmc-
> 
> mmcblk0     179:0    0 29.8G  0 disk
> ├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
> ├─mmcblk0p2 179:2    0    1G  0 part /boot
> └─mmcblk0p3 179:3    0 27.8G  0 part /

Okay.

> 
> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> ------------------------------------------------------------------
> 
> grub> ls
> (hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)
> 
> hd0 is a USB stick
> hd1 is the SD card
> 
> boot.scr
> --------
> 
> #
> # flash-kernel: bootscr.sunxi
> #
> 
> # boot script for Allwinner SunXi-based devices
> 
> # Mainline u-boot v2014.10 introduces a new default environment and
> # a new common bootcmd handling for all platforms, which is not fully
> # compatible with the old-style environment used by u-boot-sunxi.
> # This script therefore needs to check in which environment it
> # is running and set some variables accordingly.
> 
> # On u-boot-sunxi, this script assumes that ${device} and ${partition}
> # are set.
> 
> # The new-style environment predefines ${boot_targets}, the old-style
> # environment does not.
> if test -n "${boot_targets}"
> then
>   echo "Mainline u-boot / new-style environment detected."
>   # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
>   # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
>   # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
>   if test -z "${device}"; then setenv device "${devtype}"; fi
>   if test -z "${partition}${distro_bootpart}"; then setenv partition
> "${devnum}:${bootpart}"; fi
>   if test -z "${partition}"; then setenv partition
> "${devnum}:${distro_bootpart}"; fi
> else
>   echo "U-boot-sunxi / old-style environment detected."
>   # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
>   # ramdisk_addr_r, so they have to be manually set. Use the values
>   # from mainline u-boot v2014.10, except for ramdisk_addr_r,
>   # which is set to 0x44300000 to allow for initrds larger than
>   # 13MB on u-boot-sunxi.
>   setenv kernel_addr_r 0x42000000
>   setenv fdt_addr_r 0x43000000
>   setenv ramdisk_addr_r 0x44300000
> fi
> 
> if test -n "${console}"; then
>   setenv bootargs "${bootargs} console=${console}"
> fi
> 
> setenv bootargs  ${bootargs} quiet
> 
> 
> if test -z "${image_locations}"; then
>    setenv image_locations ${prefix}
> fi
> if test -z "${image_locations}"; then
>    setenv image_locations /boot/ /
> fi
> 
> if test -z "${fk_kvers}"; then
>    setenv fk_kvers '5.16.0-4-armmp-lpae'
> fi
> 
> if test -n "${fdtfile}"; then
>    setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
> else
>    setenv fdtpath dtb-${fk_kvers}
> fi
> 
> for pathprefix in ${image_locations}
> do
>   if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
>   then
>     load ${device} ${partition} ${kernel_addr_r}
> ${pathprefix}vmlinuz-${fk_kvers} \
>     && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
>     && load ${device} ${partition} ${ramdisk_addr_r}
> ${pathprefix}initrd.img-${fk_kvers} \
>     && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
>     && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
>   fi
> done

Nothing special done here.

> 
> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> 
> => echo $boot_targets
> fel mmc0 usb0 pxe dhcp
> 
> => dm tree
>  Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>  root          0  [ + ]   root_driver           root_driver
>  video         0  [   ]   sunxi_de2             |-- sunxi_de2
>  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
>  simple_bus    0  [ + ]   simple_bus            |-- soc
>  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>  blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
>  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
>  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
>  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
>  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>  gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
>  gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
>  gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
>  gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
>  gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
>  gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
>  gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
>  gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
>  gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
>  gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
>  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
>  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
>  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
>  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
>  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
>  clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
>  reset         1  [   ]   sunxi_reset           |   |   `-- reset
>  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
>  gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
>  gpio         11  [ + ]   gpio_sunxi            |       `-- PL
>  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
>  clk           4  [   ]   fixed_clock           `-- osc32k_clk
> 
> 
> 
> U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology
> 
> => echo $boot_targets
> fel mmc0 usb0 pxe dhcp
> 
> => dm tree
>  Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>  root          0  [ + ]   root_driver           root_driver
>  video         0  [   ]   sunxi_de2             |-- sunxi_de2
>  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
>  simple_bus    0  [ + ]   simple_bus            |-- soc
>  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>  blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk

A block device detected here.

>  partition     0  [ + ]   blk_partition         |   |   |   |--
> mmc@1c0f000.blk:1
>  partition     1  [ + ]   blk_partition         |   |   |   |--
> mmc@1c0f000.blk:2
>  partition     2  [ + ]   blk_partition         |   |   |   `--
> mmc@1c0f000.blk:3

Apparently, there are three partition devices,
then we should definitely have corresponding efi_disk objects
as an efi_loader hook is registered against *POST_PROBE* event
(of a *block* device).

In my patch c822c1a50bd7 ("mmc: call device_probe() after scanning"),
device_probe() has already been installed to mmc_blk_probe().

Thinking of those circumstances, the natural guess is a *probe* function
for "mmc@1c0f000.blk" device has never been called in your use case
(even when loading an image from a specific partition, /boot/efi?).

To confirm this, you may simply try the followings:
=> mmc list
   ...
=> mmc dev 0 (<- the device number from 'mmc list')
=> efi devices

Then you will find three more efi_disk objects now that the parent
block device is *probed*.

>  bootdev       0  [   ]   mmc_bootdev           |   |   `--
> mmc@1c0f000.bootdev
>  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
>  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
>  partition     3  [ + ]   blk_partition         |   |           |   `--
> usb_mass_storage.lun0:1
>  bootdev       3  [   ]   usb_bootdev           |   |           `--
> usb_mass_storage.lun0.bootdev
>  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
>  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
>  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>  pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
>  gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
>  gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
>  gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
>  gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
>  gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
>  gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
>  gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
>  gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
>  pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
>  pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
>  pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
>  pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
>  pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
>  pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
>  pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
>  pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
>  pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
>  pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
>  pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
>  pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
>  pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
>  pinconfig    13  [   ]   pinconfig             |   |   |--
> uart1-rts-cts-pins
>  pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
>  pinconfig    15  [   ]   pinconfig             |   |   |--
> uart2-rts-cts-pins
>  pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
>  pinconfig    17  [   ]   pinconfig             |   |   |--
> uart3-rts-cts-pins
>  pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
>  pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
>  pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
>  pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
>  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
>  bootdev       1  [   ]   eth_bootdev           |   |   `--
> ethernet@1c30000.bootdev
>  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
>  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
>  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
>  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
>  clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
>  reset         1  [   ]   sunxi_reset           |   |   `-- reset
>  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
>  pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
>  gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
>  gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
>  pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
>  pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
>  pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
>  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
>  clk           4  [   ]   fixed_clock           |-- osc32k_clk
>  bootstd       0  [   ]   bootstd_drv           `-- bootstd
>  bootmeth      0  [   ]   bootmeth_distro           |-- distro
>  bootmeth      1  [   ]   bootmeth_efi              |-- efi
>  bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
>  bootdev       2  [   ]   system_bootdev            `-- system-bootdev
> 
> grub rescue> ls
> (hd0)
> 
> Grub does not see any partition at all.
> 
> Loading a device from a partition does not create a handle for the device:

Actually, loading an image does *not* invoke a probe function at all
under the current implementation (of either "part" command,
scan_dev_for_boot_part or even mmc drivers?).

I think that this is weird as the purpose of "probe" is to activate
the device, or "probe - make a device ready for use" according to
    doc/develop/driver-model/design.rst

So my conclusion is that the current implementation has already broken
the driver model even before my patch was applied.
        -> Simon, you should have a comment here?

That said, fixing a problem is a different matter.
Probably, we will have to modify "part" command or mmc drivers themselves.

-Takahiro Akashi

> => efidebug devices
> ** Unable to read file ubootefi.var **
> Failed to load EFI variables
> Device   Device Path
> ======== ====================
> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> 79f7f1f8
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> 79f7f2a0
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> => bootefi $kernel_addr_r
> Booting /helloworld.efi
> invalid image type: 0
> Hello, world!
> => efidebug devices
> Device   Device Path
> ======== ====================
> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> 79f7f1f8
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> 79f7f2a0
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> =>
> 
> So the current state is a complete mess.
> 
> Best regards
> 
> Heinrich
AKASHI Takahiro April 28, 2022, 4:52 a.m. UTC | #9
On Wed, Apr 27, 2022 at 12:26:09PM +0900, AKASHI Takahiro wrote:
> Heinrich,
> 
> On Tue, Apr 26, 2022 at 07:02:46PM +0200, Heinrich Schuchardt wrote:
> > On 4/26/22 16:44, AKASHI Takahiro wrote:
> > > On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
> > >> On 4/26/22 01:44, AKASHI Takahiro wrote:
> > >> I expect that boards that booted with previous versions of U-Boot using
> > >> the respective defconfig still boot. But they don't. Here is one example
> > >> (orangepi_pc_defconfig):
> > >>
> > >>     Found U-Boot script /boot.scr.uimg
> > >>     189 bytes read in 2 ms (91.8 KiB/s)
> > >>     ## Executing script at 43100000
> > >>     22979 bytes read in 8 ms (2.7 MiB/s)
> > >>     98304 bytes read in 8 ms (11.7 MiB/s)
> > >>     Booting /EFI\debian\grubarm.efi
> > >>     Welcome to GRUB!
> > >>
> > >>     error: disk `,msdos2' not found.
> > >>     grub rescue>
> > >>
> > >> In U-Boot v2022.04 function efi_disk_register() ensured that all block
> > >> devices and their partitions were added as EFI handles.
> > > Not the all block devices, but the block devices which have already
> > > enumerated when efi_init_obj_list() is called.
> > >
> > >> But that
> > >> function is missing now.
> > > What (boot) device are you using here?
> > >
> > > Please show me the values of env variables, particularly, "boot_targets".
> > >
> > > Please show me the content of boot.scr.uimg, too.
> > >
> > > Please show me the output from
> > > => dm tree
> > > => efidebug devices
> > > for 2022.04 and 2022.07-rc1.
> > >
> > > -Takahiro Akashi
> > >
> > >
> > >
> > 
> > 
> > I am booting from mmc. Boot.scr just loads the device-tree from mmc-
> > 
> > mmcblk0     179:0    0 29.8G  0 disk
> > ├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
> > ├─mmcblk0p2 179:2    0    1G  0 part /boot
> > └─mmcblk0p3 179:3    0 27.8G  0 part /
> 
> Okay.
> 
> > 
> > U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> > ------------------------------------------------------------------
> > 
> > grub> ls
> > (hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)
> > 
> > hd0 is a USB stick
> > hd1 is the SD card
> > 
> > boot.scr
> > --------
> > 
> > #
> > # flash-kernel: bootscr.sunxi
> > #
> > 
> > # boot script for Allwinner SunXi-based devices
> > 
> > # Mainline u-boot v2014.10 introduces a new default environment and
> > # a new common bootcmd handling for all platforms, which is not fully
> > # compatible with the old-style environment used by u-boot-sunxi.
> > # This script therefore needs to check in which environment it
> > # is running and set some variables accordingly.
> > 
> > # On u-boot-sunxi, this script assumes that ${device} and ${partition}
> > # are set.
> > 
> > # The new-style environment predefines ${boot_targets}, the old-style
> > # environment does not.
> > if test -n "${boot_targets}"
> > then
> >   echo "Mainline u-boot / new-style environment detected."
> >   # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
> >   # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
> >   # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
> >   if test -z "${device}"; then setenv device "${devtype}"; fi
> >   if test -z "${partition}${distro_bootpart}"; then setenv partition
> > "${devnum}:${bootpart}"; fi
> >   if test -z "${partition}"; then setenv partition
> > "${devnum}:${distro_bootpart}"; fi
> > else
> >   echo "U-boot-sunxi / old-style environment detected."
> >   # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
> >   # ramdisk_addr_r, so they have to be manually set. Use the values
> >   # from mainline u-boot v2014.10, except for ramdisk_addr_r,
> >   # which is set to 0x44300000 to allow for initrds larger than
> >   # 13MB on u-boot-sunxi.
> >   setenv kernel_addr_r 0x42000000
> >   setenv fdt_addr_r 0x43000000
> >   setenv ramdisk_addr_r 0x44300000
> > fi
> > 
> > if test -n "${console}"; then
> >   setenv bootargs "${bootargs} console=${console}"
> > fi
> > 
> > setenv bootargs  ${bootargs} quiet
> > 
> > 
> > if test -z "${image_locations}"; then
> >    setenv image_locations ${prefix}
> > fi
> > if test -z "${image_locations}"; then
> >    setenv image_locations /boot/ /
> > fi
> > 
> > if test -z "${fk_kvers}"; then
> >    setenv fk_kvers '5.16.0-4-armmp-lpae'
> > fi
> > 
> > if test -n "${fdtfile}"; then
> >    setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
> > else
> >    setenv fdtpath dtb-${fk_kvers}
> > fi
> > 
> > for pathprefix in ${image_locations}
> > do
> >   if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
> >   then
> >     load ${device} ${partition} ${kernel_addr_r}
> > ${pathprefix}vmlinuz-${fk_kvers} \
> >     && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
> >     && load ${device} ${partition} ${ramdisk_addr_r}
> > ${pathprefix}initrd.img-${fk_kvers} \
> >     && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
> >     && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
> >   fi
> > done
> 
> Nothing special done here.
> 
> > 
> > U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> > 
> > => echo $boot_targets
> > fel mmc0 usb0 pxe dhcp
> > 
> > => dm tree
> >  Class     Index  Probed  Driver                Name
> > -----------------------------------------------------------
> >  root          0  [ + ]   root_driver           root_driver
> >  video         0  [   ]   sunxi_de2             |-- sunxi_de2
> >  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
> >  simple_bus    0  [ + ]   simple_bus            |-- soc
> >  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
> >  blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
> >  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
> >  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
> >  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
> >  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
> >  gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
> >  gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
> >  gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
> >  gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
> >  gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
> >  gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
> >  gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
> >  gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
> >  gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
> >  gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
> >  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
> >  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
> >  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
> >  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
> >  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
> >  clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
> >  reset         1  [   ]   sunxi_reset           |   |   `-- reset
> >  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
> >  gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
> >  gpio         11  [ + ]   gpio_sunxi            |       `-- PL
> >  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
> >  clk           4  [   ]   fixed_clock           `-- osc32k_clk
> > 
> > 
> > 
> > U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology
> > 
> > => echo $boot_targets
> > fel mmc0 usb0 pxe dhcp
> > 
> > => dm tree
> >  Class     Index  Probed  Driver                Name
> > -----------------------------------------------------------
> >  root          0  [ + ]   root_driver           root_driver
> >  video         0  [   ]   sunxi_de2             |-- sunxi_de2
> >  display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
> >  simple_bus    0  [ + ]   simple_bus            |-- soc
> >  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
> >  blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
> 
> A block device detected here.
> 
> >  partition     0  [ + ]   blk_partition         |   |   |   |--
> > mmc@1c0f000.blk:1
> >  partition     1  [ + ]   blk_partition         |   |   |   |--
> > mmc@1c0f000.blk:2
> >  partition     2  [ + ]   blk_partition         |   |   |   `--
> > mmc@1c0f000.blk:3
> 
> Apparently, there are three partition devices,
> then we should definitely have corresponding efi_disk objects
> as an efi_loader hook is registered against *POST_PROBE* event
> (of a *block* device).
> 
> In my patch c822c1a50bd7 ("mmc: call device_probe() after scanning"),
> device_probe() has already been installed to mmc_blk_probe().
> 
> Thinking of those circumstances, the natural guess is a *probe* function
> for "mmc@1c0f000.blk" device has never been called in your use case
> (even when loading an image from a specific partition, /boot/efi?).
> 
> To confirm this, you may simply try the followings:
> => mmc list
>    ...
> => mmc dev 0 (<- the device number from 'mmc list')
> => efi devices
> 
> Then you will find three more efi_disk objects now that the parent
> block device is *probed*.
> 
> >  bootdev       0  [   ]   mmc_bootdev           |   |   `--
> > mmc@1c0f000.bootdev
> >  phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
> >  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
> >  partition     3  [ + ]   blk_partition         |   |           |   `--
> > usb_mass_storage.lun0:1
> >  bootdev       3  [   ]   usb_bootdev           |   |           `--
> > usb_mass_storage.lun0.bootdev
> >  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
> >  clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
> >  reset         0  [ + ]   sunxi_reset           |   |   `-- reset
> >  pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
> >  gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
> >  gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
> >  gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
> >  gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
> >  gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
> >  gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
> >  gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
> >  gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
> >  pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
> >  pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
> >  pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
> >  pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
> >  pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
> >  pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
> >  pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
> >  pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
> >  pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
> >  pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
> >  pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
> >  pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
> >  pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
> >  pinconfig    13  [   ]   pinconfig             |   |   |--
> > uart1-rts-cts-pins
> >  pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
> >  pinconfig    15  [   ]   pinconfig             |   |   |--
> > uart2-rts-cts-pins
> >  pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
> >  pinconfig    17  [   ]   pinconfig             |   |   |--
> > uart3-rts-cts-pins
> >  pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
> >  pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
> >  pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
> >  pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
> >  ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
> >  bootdev       1  [   ]   eth_bootdev           |   |   `--
> > ethernet@1c30000.bootdev
> >  watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
> >  sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
> >  serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
> >  clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
> >  clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
> >  reset         1  [   ]   sunxi_reset           |   |   `-- reset
> >  i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
> >  pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
> >  gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
> >  gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
> >  pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
> >  pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
> >  pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
> >  clk           3  [ + ]   fixed_clock           |-- osc24M_clk
> >  clk           4  [   ]   fixed_clock           |-- osc32k_clk
> >  bootstd       0  [   ]   bootstd_drv           `-- bootstd
> >  bootmeth      0  [   ]   bootmeth_distro           |-- distro
> >  bootmeth      1  [   ]   bootmeth_efi              |-- efi
> >  bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
> >  bootdev       2  [   ]   system_bootdev            `-- system-bootdev
> > 
> > grub rescue> ls
> > (hd0)
> > 
> > Grub does not see any partition at all.
> > 
> > Loading a device from a partition does not create a handle for the device:
> 
> Actually, loading an image does *not* invoke a probe function at all
> under the current implementation (of either "part" command,
> scan_dev_for_boot_part or even mmc drivers?).
> 
> I think that this is weird as the purpose of "probe" is to activate
> the device, or "probe - make a device ready for use" according to
>     doc/develop/driver-model/design.rst
> 
> So my conclusion is that the current implementation has already broken
> the driver model even before my patch was applied.
>         -> Simon, you should have a comment here?
> 
> That said, fixing a problem is a different matter.
> Probably, we will have to modify "part" command or mmc drivers themselves.

Can you figure out an easy way to reproduce the issue?
(either on sandbox or qemu-arm)
Otherwise, it is difficult for me to investigate it.

-Takahiro Akashi


> -Takahiro Akashi
> 
> > => efidebug devices
> > ** Unable to read file ubootefi.var **
> > Failed to load EFI variables
> > Device   Device Path
> > ======== ====================
> > 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> > 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> > 79f7f1f8
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> > 79f7f2a0
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> > 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> > => bootefi $kernel_addr_r
> > Booting /helloworld.efi
> > invalid image type: 0
> > Hello, world!
> > => efidebug devices
> > Device   Device Path
> > ======== ====================
> > 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> > 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> > 79f7f1f8
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> > 79f7f2a0
> > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> > 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> > =>
> > 
> > So the current state is a complete mess.
> > 
> > Best regards
> > 
> > Heinrich
Heinrich Schuchardt April 28, 2022, 6:45 a.m. UTC | #10
On 4/28/22 06:52, AKASHI Takahiro wrote:
> On Wed, Apr 27, 2022 at 12:26:09PM +0900, AKASHI Takahiro wrote:
>> Heinrich,
>>
>> On Tue, Apr 26, 2022 at 07:02:46PM +0200, Heinrich Schuchardt wrote:
>>> On 4/26/22 16:44, AKASHI Takahiro wrote:
>>>> On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
>>>>> On 4/26/22 01:44, AKASHI Takahiro wrote:
>>>>> I expect that boards that booted with previous versions of U-Boot using
>>>>> the respective defconfig still boot. But they don't. Here is one example
>>>>> (orangepi_pc_defconfig):
>>>>>
>>>>>      Found U-Boot script /boot.scr.uimg
>>>>>      189 bytes read in 2 ms (91.8 KiB/s)
>>>>>      ## Executing script at 43100000
>>>>>      22979 bytes read in 8 ms (2.7 MiB/s)
>>>>>      98304 bytes read in 8 ms (11.7 MiB/s)
>>>>>      Booting /EFI\debian\grubarm.efi
>>>>>      Welcome to GRUB!
>>>>>
>>>>>      error: disk `,msdos2' not found.
>>>>>      grub rescue>
>>>>>
>>>>> In U-Boot v2022.04 function efi_disk_register() ensured that all block
>>>>> devices and their partitions were added as EFI handles.
>>>> Not the all block devices, but the block devices which have already
>>>> enumerated when efi_init_obj_list() is called.
>>>>
>>>>> But that
>>>>> function is missing now.
>>>> What (boot) device are you using here?
>>>>
>>>> Please show me the values of env variables, particularly, "boot_targets".
>>>>
>>>> Please show me the content of boot.scr.uimg, too.
>>>>
>>>> Please show me the output from
>>>> => dm tree
>>>> => efidebug devices
>>>> for 2022.04 and 2022.07-rc1.
>>>>
>>>> -Takahiro Akashi
>>>>
>>>>
>>>>
>>>
>>>
>>> I am booting from mmc. Boot.scr just loads the device-tree from mmc-
>>>
>>> mmcblk0     179:0    0 29.8G  0 disk
>>> ├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
>>> ├─mmcblk0p2 179:2    0    1G  0 part /boot
>>> └─mmcblk0p3 179:3    0 27.8G  0 part /
>>
>> Okay.
>>
>>>
>>> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
>>> ------------------------------------------------------------------
>>>
>>> grub> ls
>>> (hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)
>>>
>>> hd0 is a USB stick
>>> hd1 is the SD card
>>>
>>> boot.scr
>>> --------
>>>
>>> #
>>> # flash-kernel: bootscr.sunxi
>>> #
>>>
>>> # boot script for Allwinner SunXi-based devices
>>>
>>> # Mainline u-boot v2014.10 introduces a new default environment and
>>> # a new common bootcmd handling for all platforms, which is not fully
>>> # compatible with the old-style environment used by u-boot-sunxi.
>>> # This script therefore needs to check in which environment it
>>> # is running and set some variables accordingly.
>>>
>>> # On u-boot-sunxi, this script assumes that ${device} and ${partition}
>>> # are set.
>>>
>>> # The new-style environment predefines ${boot_targets}, the old-style
>>> # environment does not.
>>> if test -n "${boot_targets}"
>>> then
>>>    echo "Mainline u-boot / new-style environment detected."
>>>    # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
>>>    # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
>>>    # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
>>>    if test -z "${device}"; then setenv device "${devtype}"; fi
>>>    if test -z "${partition}${distro_bootpart}"; then setenv partition
>>> "${devnum}:${bootpart}"; fi
>>>    if test -z "${partition}"; then setenv partition
>>> "${devnum}:${distro_bootpart}"; fi
>>> else
>>>    echo "U-boot-sunxi / old-style environment detected."
>>>    # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
>>>    # ramdisk_addr_r, so they have to be manually set. Use the values
>>>    # from mainline u-boot v2014.10, except for ramdisk_addr_r,
>>>    # which is set to 0x44300000 to allow for initrds larger than
>>>    # 13MB on u-boot-sunxi.
>>>    setenv kernel_addr_r 0x42000000
>>>    setenv fdt_addr_r 0x43000000
>>>    setenv ramdisk_addr_r 0x44300000
>>> fi
>>>
>>> if test -n "${console}"; then
>>>    setenv bootargs "${bootargs} console=${console}"
>>> fi
>>>
>>> setenv bootargs  ${bootargs} quiet
>>>
>>>
>>> if test -z "${image_locations}"; then
>>>     setenv image_locations ${prefix}
>>> fi
>>> if test -z "${image_locations}"; then
>>>     setenv image_locations /boot/ /
>>> fi
>>>
>>> if test -z "${fk_kvers}"; then
>>>     setenv fk_kvers '5.16.0-4-armmp-lpae'
>>> fi
>>>
>>> if test -n "${fdtfile}"; then
>>>     setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
>>> else
>>>     setenv fdtpath dtb-${fk_kvers}
>>> fi
>>>
>>> for pathprefix in ${image_locations}
>>> do
>>>    if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
>>>    then
>>>      load ${device} ${partition} ${kernel_addr_r}
>>> ${pathprefix}vmlinuz-${fk_kvers} \
>>>      && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
>>>      && load ${device} ${partition} ${ramdisk_addr_r}
>>> ${pathprefix}initrd.img-${fk_kvers} \
>>>      && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
>>>      && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
>>>    fi
>>> done
>>
>> Nothing special done here.
>>
>>>
>>> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
>>>
>>> => echo $boot_targets
>>> fel mmc0 usb0 pxe dhcp
>>>
>>> => dm tree
>>>   Class     Index  Probed  Driver                Name
>>> -----------------------------------------------------------
>>>   root          0  [ + ]   root_driver           root_driver
>>>   video         0  [   ]   sunxi_de2             |-- sunxi_de2
>>>   display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
>>>   simple_bus    0  [ + ]   simple_bus            |-- soc
>>>   mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>>>   blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
>>>   phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
>>>   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
>>>   clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
>>>   reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>>>   gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
>>>   gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
>>>   gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
>>>   gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
>>>   gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
>>>   gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
>>>   gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
>>>   gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
>>>   gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
>>>   gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
>>>   ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
>>>   watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
>>>   sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
>>>   serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
>>>   clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
>>>   clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
>>>   reset         1  [   ]   sunxi_reset           |   |   `-- reset
>>>   i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
>>>   gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
>>>   gpio         11  [ + ]   gpio_sunxi            |       `-- PL
>>>   clk           3  [ + ]   fixed_clock           |-- osc24M_clk
>>>   clk           4  [   ]   fixed_clock           `-- osc32k_clk
>>>
>>>
>>>
>>> U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology
>>>
>>> => echo $boot_targets
>>> fel mmc0 usb0 pxe dhcp
>>>
>>> => dm tree
>>>   Class     Index  Probed  Driver                Name
>>> -----------------------------------------------------------
>>>   root          0  [ + ]   root_driver           root_driver
>>>   video         0  [   ]   sunxi_de2             |-- sunxi_de2
>>>   display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
>>>   simple_bus    0  [ + ]   simple_bus            |-- soc
>>>   mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>>>   blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
>>
>> A block device detected here.
>>
>>>   partition     0  [ + ]   blk_partition         |   |   |   |--
>>> mmc@1c0f000.blk:1
>>>   partition     1  [ + ]   blk_partition         |   |   |   |--
>>> mmc@1c0f000.blk:2
>>>   partition     2  [ + ]   blk_partition         |   |   |   `--
>>> mmc@1c0f000.blk:3
>>
>> Apparently, there are three partition devices,
>> then we should definitely have corresponding efi_disk objects
>> as an efi_loader hook is registered against *POST_PROBE* event
>> (of a *block* device).
>>
>> In my patch c822c1a50bd7 ("mmc: call device_probe() after scanning"),
>> device_probe() has already been installed to mmc_blk_probe().
>>
>> Thinking of those circumstances, the natural guess is a *probe* function
>> for "mmc@1c0f000.blk" device has never been called in your use case
>> (even when loading an image from a specific partition, /boot/efi?).
>>
>> To confirm this, you may simply try the followings:
>> => mmc list
>>     ...
>> => mmc dev 0 (<- the device number from 'mmc list')
>> => efi devices
>>
>> Then you will find three more efi_disk objects now that the parent
>> block device is *probed*.
>>
>>>   bootdev       0  [   ]   mmc_bootdev           |   |   `--
>>> mmc@1c0f000.bootdev
>>>   phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
>>>   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
>>>   partition     3  [ + ]   blk_partition         |   |           |   `--
>>> usb_mass_storage.lun0:1
>>>   bootdev       3  [   ]   usb_bootdev           |   |           `--
>>> usb_mass_storage.lun0.bootdev
>>>   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
>>>   clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
>>>   reset         0  [ + ]   sunxi_reset           |   |   `-- reset
>>>   pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
>>>   gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
>>>   gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
>>>   gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
>>>   gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
>>>   gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
>>>   gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
>>>   gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
>>>   gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
>>>   pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
>>>   pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
>>>   pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
>>>   pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
>>>   pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
>>>   pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
>>>   pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
>>>   pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
>>>   pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
>>>   pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
>>>   pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
>>>   pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
>>>   pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
>>>   pinconfig    13  [   ]   pinconfig             |   |   |--
>>> uart1-rts-cts-pins
>>>   pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
>>>   pinconfig    15  [   ]   pinconfig             |   |   |--
>>> uart2-rts-cts-pins
>>>   pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
>>>   pinconfig    17  [   ]   pinconfig             |   |   |--
>>> uart3-rts-cts-pins
>>>   pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
>>>   pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
>>>   pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
>>>   pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
>>>   ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
>>>   bootdev       1  [   ]   eth_bootdev           |   |   `--
>>> ethernet@1c30000.bootdev
>>>   watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
>>>   sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
>>>   serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
>>>   clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
>>>   clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
>>>   reset         1  [   ]   sunxi_reset           |   |   `-- reset
>>>   i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
>>>   pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
>>>   gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
>>>   gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
>>>   pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
>>>   pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
>>>   pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
>>>   clk           3  [ + ]   fixed_clock           |-- osc24M_clk
>>>   clk           4  [   ]   fixed_clock           |-- osc32k_clk
>>>   bootstd       0  [   ]   bootstd_drv           `-- bootstd
>>>   bootmeth      0  [   ]   bootmeth_distro           |-- distro
>>>   bootmeth      1  [   ]   bootmeth_efi              |-- efi
>>>   bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
>>>   bootdev       2  [   ]   system_bootdev            `-- system-bootdev
>>>
>>> grub rescue> ls
>>> (hd0)
>>>
>>> Grub does not see any partition at all.
>>>
>>> Loading a device from a partition does not create a handle for the device:
>>
>> Actually, loading an image does *not* invoke a probe function at all
>> under the current implementation (of either "part" command,
>> scan_dev_for_boot_part or even mmc drivers?).

We call efi_disk_init() after the MMC device is probed. Therefore
probing of the MCC device does not trigger EVT_DM_POST_PROBE.

We have to move the efi_disk_init() call before initr_dm().

[PATCH 1/1] efi_loader: call efi_init_early() earlier
https://lists.denx.de/pipermail/u-boot/2022-April/482701.html

With the patch GRUB now sees the MMC device but it is still not seeing
the partitions:

grub rescue> ls
(hd0) (hd1)

This is strange because devices and protocols look rather normal now:

=> dm tree
  Class     Index  Probed  Driver                Name
-----------------------------------------------------------
  root          0  [ + ]   root_driver           root_driver
  simple_bus    0  [ + ]   simple_bus            |-- soc
  mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
  blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
  partition     0  [ + ]   blk_partition         |   |   |   |--
mmc@1c0f000.blk:1
  partition     1  [ + ]   blk_partition         |   |   |   |--
mmc@1c0f000.blk:2
  partition     2  [ + ]   blk_partition         |   |   |   `--
mmc@1c0f000.blk:3
  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
  partition     3  [ + ]   blk_partition         |   |           |   `--
usb_mass_storage.lun0:1
  bootdev       3  [   ]   usb_bootdev           |   |           `--
usb_mass_storage.lun0.bootdev

=> efidebug devices
Device   Device Path
======== ====================
79f701e8 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
79f70cd8 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)
79f70de0
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,MBR,0xb6b4facb,0x800,0x200000)
79f711b0
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,MBR,0xb6b4facb,0x200800,0x200000)
79f71538
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(3,MBR,0xb6b4facb,0x400800,0x379f800)
79f811b8
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
79f81260
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
79fdd748 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)

=> efidebug dh
Handle   Protocols
======== ====================
79f701e8 Device Path, Device Path To Text, Device Path Utilities,
Device-Tree Fixup, Unicode Collation 2, HII String, HII Database, Simple
Text Output, Simple Text Input, Simple Text Input Ex
7dffc7ec Device Path
79f70cd8 Device Path, Block IO
79f70de0 Device Path, Block IO, System Partition, Simple File System
79f711b0 Device Path, Block IO, Simple File System
79f71538 Device Path, Block IO, Simple File System
79f811b8 Device Path, Block IO
79f81260 Device Path, Block IO, System Partition, Simple File System
79f84978 Driver Binding
79fdd748 Simple Network, Device Path, PXE Base Code

This is the console log *before* the patch:

U-Boot 2022.07-rc1-00082-g8b2b125e95-dirty (Apr 28 2022 - 06:01:10
+0000) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi PC
DRAM:  1 GiB
drivers/mmc/sunxi_mmc.c(723)sunxi_mmc_bind:
sunxi_set_gate: (CLK#54) unhandled
Core:  70 devices, 20 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   drivers/mmc/sunxi_mmc.c(667)sunxi_mmc_probe:
mmc@1c0f000: 0
Loading Environment from FAT... drivers/mmc/mmc-uclass.c(487)mmc_blk_probe:
drivers/block/blk-uclass.c(746)blk_post_probe:
drivers/block/blk-uclass.c(752)blk_post_probe:
disk/part.c(242)part_init:
part_init: try 'EFI': ret=-1
part_init: try 'DOS': ret=0
part_create_block_devices: 3 partitions found in mmc@1c0f000.blk
disk/part.c(242)part_init:
part_init: try 'EFI': ret=-1
part_init: try 'DOS': ret=0
Unable to read "uboot.env" from mmc0:1...
In:    serial
Out:   serial
Err:   serial
Net:   phy interface1
eth0: ethernet@1c30000
lib/efi_loader/efi_disk.c(739)efi_disk_init:
starting USB...
Bus usb@1c1a000: USB EHCI 1.00
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1a400: USB OHCI 1.0
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1b000: lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
sunxi_set_gate: (CLK#9) unhandled
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
USB EHCI 1.00
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1b400: USB OHCI 1.0
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1c000: USB EHCI 1.00
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1c400: USB OHCI 1.0
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1d000: USB EHCI 1.00
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
Bus usb@1c1d400: USB OHCI 1.0
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
scanning bus usb@1c1a000 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
scanning bus usb@1c1a400 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
scanning bus usb@1c1b000 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
scanning bus usb@1c1b400 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
scanning bus usb@1c1c000 for devices...
drivers/block/blk-uclass.c(746)blk_post_probe:
drivers/block/blk-uclass.c(752)blk_post_probe:
disk/part.c(242)part_init:
part_init: try 'EFI': ret=-1
part_init: try 'DOS': ret=0
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
part_create_block_devices: 1 partitions found in usb_mass_storage.lun0
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(568)efi_disk_create_part:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
2 USB Device(s) found
scanning bus usb@1c1c400 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
scanning bus usb@1c1d000 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
scanning bus usb@1c1d400 for devices...
lib/efi_loader/efi_disk.c(622)efi_disk_probe:
1 USB Device(s) found
        scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0

Best regards

Heinrich

>>
>> I think that this is weird as the purpose of "probe" is to activate
>> the device, or "probe - make a device ready for use" according to
>>      doc/develop/driver-model/design.rst
>>
>> So my conclusion is that the current implementation has already broken
>> the driver model even before my patch was applied.
>>          -> Simon, you should have a comment here?
>>
>> That said, fixing a problem is a different matter.
>> Probably, we will have to modify "part" command or mmc drivers themselves.
>
> Can you figure out an easy way to reproduce the issue?
> (either on sandbox or qemu-arm)
> Otherwise, it is difficult for me to investigate it.
>
> -Takahiro Akashi
>
>
>> -Takahiro Akashi
>>
>>> => efidebug devices
>>> ** Unable to read file ubootefi.var **
>>> Failed to load EFI variables
>>> Device   Device Path
>>> ======== ====================
>>> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
>>> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
>>> 79f7f1f8
>>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
>>> 79f7f2a0
>>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
>>> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
>>> => bootefi $kernel_addr_r
>>> Booting /helloworld.efi
>>> invalid image type: 0
>>> Hello, world!
>>> => efidebug devices
>>> Device   Device Path
>>> ======== ====================
>>> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
>>> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
>>> 79f7f1f8
>>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
>>> 79f7f2a0
>>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
>>> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
>>> =>
>>>
>>> So the current state is a complete mess.
>>>
>>> Best regards
>>>
>>> Heinrich
Mark Kettenis April 28, 2022, 9:09 a.m. UTC | #11
> Date: Thu, 28 Apr 2022 08:45:51 +0200
> Content-Language: en-US
> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, sjg@chromium.org,
>  ilias.apalodimas@linaro.org, Tom Rini <trini@konsulko.com>,
>  Mark Kettenis <mark.kettenis@xs4all.nl>
> Content-Type: text/plain; charset=UTF-8; format=flowed
> 
> On 4/28/22 06:52, AKASHI Takahiro wrote:
> > On Wed, Apr 27, 2022 at 12:26:09PM +0900, AKASHI Takahiro wrote:
> >> Heinrich,
> >>
> >> On Tue, Apr 26, 2022 at 07:02:46PM +0200, Heinrich Schuchardt wrote:
> >>> On 4/26/22 16:44, AKASHI Takahiro wrote:
> >>>> On Tue, Apr 26, 2022 at 03:57:26PM +0200, Heinrich Schuchardt wrote:
> >>>>> On 4/26/22 01:44, AKASHI Takahiro wrote:
> >>>>> I expect that boards that booted with previous versions of U-Boot using
> >>>>> the respective defconfig still boot. But they don't. Here is one example
> >>>>> (orangepi_pc_defconfig):
> >>>>>
> >>>>>      Found U-Boot script /boot.scr.uimg
> >>>>>      189 bytes read in 2 ms (91.8 KiB/s)
> >>>>>      ## Executing script at 43100000
> >>>>>      22979 bytes read in 8 ms (2.7 MiB/s)
> >>>>>      98304 bytes read in 8 ms (11.7 MiB/s)
> >>>>>      Booting /EFI\debian\grubarm.efi
> >>>>>      Welcome to GRUB!
> >>>>>
> >>>>>      error: disk `,msdos2' not found.
> >>>>>      grub rescue>
> >>>>>
> >>>>> In U-Boot v2022.04 function efi_disk_register() ensured that all block
> >>>>> devices and their partitions were added as EFI handles.
> >>>> Not the all block devices, but the block devices which have already
> >>>> enumerated when efi_init_obj_list() is called.
> >>>>
> >>>>> But that
> >>>>> function is missing now.
> >>>> What (boot) device are you using here?
> >>>>
> >>>> Please show me the values of env variables, particularly, "boot_targets".
> >>>>
> >>>> Please show me the content of boot.scr.uimg, too.
> >>>>
> >>>> Please show me the output from
> >>>> => dm tree
> >>>> => efidebug devices
> >>>> for 2022.04 and 2022.07-rc1.
> >>>>
> >>>> -Takahiro Akashi
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>> I am booting from mmc. Boot.scr just loads the device-tree from mmc-
> >>>
> >>> mmcblk0     179:0    0 29.8G  0 disk
> >>> ├─mmcblk0p1 179:1    0    1G  0 part /boot/efi
> >>> ├─mmcblk0p2 179:2    0    1G  0 part /boot
> >>> └─mmcblk0p3 179:3    0 27.8G  0 part /
> >>
> >> Okay.
> >>
> >>>
> >>> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> >>> ------------------------------------------------------------------
> >>>
> >>> grub> ls
> >>> (hd0) (hd0,msdos1) (hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)
> >>>
> >>> hd0 is a USB stick
> >>> hd1 is the SD card
> >>>
> >>> boot.scr
> >>> --------
> >>>
> >>> #
> >>> # flash-kernel: bootscr.sunxi
> >>> #
> >>>
> >>> # boot script for Allwinner SunXi-based devices
> >>>
> >>> # Mainline u-boot v2014.10 introduces a new default environment and
> >>> # a new common bootcmd handling for all platforms, which is not fully
> >>> # compatible with the old-style environment used by u-boot-sunxi.
> >>> # This script therefore needs to check in which environment it
> >>> # is running and set some variables accordingly.
> >>>
> >>> # On u-boot-sunxi, this script assumes that ${device} and ${partition}
> >>> # are set.
> >>>
> >>> # The new-style environment predefines ${boot_targets}, the old-style
> >>> # environment does not.
> >>> if test -n "${boot_targets}"
> >>> then
> >>>    echo "Mainline u-boot / new-style environment detected."
> >>>    # Mainline u-boot v2014.10 uses ${devtype}, ${devnum} and
> >>>    # ${bootpart} where u-boot-sunxi uses ${device} and ${partition}.
> >>>    # ${distro_bootpart} replaced ${bootpart} in u-boot v2016.01.
> >>>    if test -z "${device}"; then setenv device "${devtype}"; fi
> >>>    if test -z "${partition}${distro_bootpart}"; then setenv partition
> >>> "${devnum}:${bootpart}"; fi
> >>>    if test -z "${partition}"; then setenv partition
> >>> "${devnum}:${distro_bootpart}"; fi
> >>> else
> >>>    echo "U-boot-sunxi / old-style environment detected."
> >>>    # U-boot-sunxi does not predefine kernel_addr_r, fdt_addr_r and
> >>>    # ramdisk_addr_r, so they have to be manually set. Use the values
> >>>    # from mainline u-boot v2014.10, except for ramdisk_addr_r,
> >>>    # which is set to 0x44300000 to allow for initrds larger than
> >>>    # 13MB on u-boot-sunxi.
> >>>    setenv kernel_addr_r 0x42000000
> >>>    setenv fdt_addr_r 0x43000000
> >>>    setenv ramdisk_addr_r 0x44300000
> >>> fi
> >>>
> >>> if test -n "${console}"; then
> >>>    setenv bootargs "${bootargs} console=${console}"
> >>> fi
> >>>
> >>> setenv bootargs  ${bootargs} quiet
> >>>
> >>>
> >>> if test -z "${image_locations}"; then
> >>>     setenv image_locations ${prefix}
> >>> fi
> >>> if test -z "${image_locations}"; then
> >>>     setenv image_locations /boot/ /
> >>> fi
> >>>
> >>> if test -z "${fk_kvers}"; then
> >>>     setenv fk_kvers '5.16.0-4-armmp-lpae'
> >>> fi
> >>>
> >>> if test -n "${fdtfile}"; then
> >>>     setenv fdtpath dtbs/${fk_kvers}/${fdtfile}
> >>> else
> >>>     setenv fdtpath dtb-${fk_kvers}
> >>> fi
> >>>
> >>> for pathprefix in ${image_locations}
> >>> do
> >>>    if test -e ${device} ${partition} ${pathprefix}vmlinuz-${fk_kvers}
> >>>    then
> >>>      load ${device} ${partition} ${kernel_addr_r}
> >>> ${pathprefix}vmlinuz-${fk_kvers} \
> >>>      && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}${fdtpath} \
> >>>      && load ${device} ${partition} ${ramdisk_addr_r}
> >>> ${pathprefix}initrd.img-${fk_kvers} \
> >>>      && echo "Booting Debian ${fk_kvers} from ${device} ${partition}..." \
> >>>      && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
> >>>    fi
> >>> done
> >>
> >> Nothing special done here.
> >>
> >>>
> >>> U-Boot 2022.04 (Apr 26 2022 - 16:02:27 +0000) Allwinner Technology
> >>>
> >>> => echo $boot_targets
> >>> fel mmc0 usb0 pxe dhcp
> >>>
> >>> => dm tree
> >>>   Class     Index  Probed  Driver                Name
> >>> -----------------------------------------------------------
> >>>   root          0  [ + ]   root_driver           root_driver
> >>>   video         0  [   ]   sunxi_de2             |-- sunxi_de2
> >>>   display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
> >>>   simple_bus    0  [ + ]   simple_bus            |-- soc
> >>>   mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
> >>>   blk           0  [ + ]   mmc_blk               |   |   `-- mmc@1c0f000.blk
> >>>   phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
> >>>   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
> >>>   clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
> >>>   reset         0  [ + ]   sunxi_reset           |   |   `-- reset
> >>>   gpio          0  [ + ]   gpio_sunxi            |   |-- pinctrl@1c20800
> >>>   gpio          1  [ + ]   gpio_sunxi            |   |   |-- PA
> >>>   gpio          2  [ + ]   gpio_sunxi            |   |   |-- PB
> >>>   gpio          3  [ + ]   gpio_sunxi            |   |   |-- PC
> >>>   gpio          4  [ + ]   gpio_sunxi            |   |   |-- PD
> >>>   gpio          5  [ + ]   gpio_sunxi            |   |   |-- PE
> >>>   gpio          6  [ + ]   gpio_sunxi            |   |   |-- PF
> >>>   gpio          7  [ + ]   gpio_sunxi            |   |   |-- PG
> >>>   gpio          8  [ + ]   gpio_sunxi            |   |   |-- PH
> >>>   gpio          9  [ + ]   gpio_sunxi            |   |   `-- PI
> >>>   ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
> >>>   watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
> >>>   sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
> >>>   serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
> >>>   clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
> >>>   clk           2  [   ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
> >>>   reset         1  [   ]   sunxi_reset           |   |   `-- reset
> >>>   i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
> >>>   gpio         10  [ + ]   gpio_sunxi            |   `-- pinctrl@1f02c00
> >>>   gpio         11  [ + ]   gpio_sunxi            |       `-- PL
> >>>   clk           3  [ + ]   fixed_clock           |-- osc24M_clk
> >>>   clk           4  [   ]   fixed_clock           `-- osc32k_clk
> >>>
> >>>
> >>>
> >>> U-Boot 2022.07-rc1 (Apr 26 2022 - 07:00:52 +0000) Allwinner Technology
> >>>
> >>> => echo $boot_targets
> >>> fel mmc0 usb0 pxe dhcp
> >>>
> >>> => dm tree
> >>>   Class     Index  Probed  Driver                Name
> >>> -----------------------------------------------------------
> >>>   root          0  [ + ]   root_driver           root_driver
> >>>   video         0  [   ]   sunxi_de2             |-- sunxi_de2
> >>>   display       0  [   ]   sunxi_dw_hdmi         |-- sunxi_dw_hdmi
> >>>   simple_bus    0  [ + ]   simple_bus            |-- soc
> >>>   mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
> >>>   blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
> >>
> >> A block device detected here.
> >>
> >>>   partition     0  [ + ]   blk_partition         |   |   |   |--
> >>> mmc@1c0f000.blk:1
> >>>   partition     1  [ + ]   blk_partition         |   |   |   |--
> >>> mmc@1c0f000.blk:2
> >>>   partition     2  [ + ]   blk_partition         |   |   |   `--
> >>> mmc@1c0f000.blk:3
> >>
> >> Apparently, there are three partition devices,
> >> then we should definitely have corresponding efi_disk objects
> >> as an efi_loader hook is registered against *POST_PROBE* event
> >> (of a *block* device).
> >>
> >> In my patch c822c1a50bd7 ("mmc: call device_probe() after scanning"),
> >> device_probe() has already been installed to mmc_blk_probe().
> >>
> >> Thinking of those circumstances, the natural guess is a *probe* function
> >> for "mmc@1c0f000.blk" device has never been called in your use case
> >> (even when loading an image from a specific partition, /boot/efi?).
> >>
> >> To confirm this, you may simply try the followings:
> >> => mmc list
> >>     ...
> >> => mmc dev 0 (<- the device number from 'mmc list')
> >> => efi devices
> >>
> >> Then you will find three more efi_disk objects now that the parent
> >> block device is *probed*.
> >>
> >>>   bootdev       0  [   ]   mmc_bootdev           |   |   `--
> >>> mmc@1c0f000.bootdev
> >>>   phy           0  [ + ]   sun4i_usb_phy         |   |-- phy@1c19400
> >>>   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
> >>>   partition     3  [ + ]   blk_partition         |   |           |   `--
> >>> usb_mass_storage.lun0:1
> >>>   bootdev       3  [   ]   usb_bootdev           |   |           `--
> >>> usb_mass_storage.lun0.bootdev
> >>>   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
> >>>   clk           0  [ + ]   sun8i_h3_ccu          |   |-- clock@1c20000
> >>>   reset         0  [ + ]   sunxi_reset           |   |   `-- reset
> >>>   pinctrl       0  [ + ]   sunxi-pinctrl         |   |-- pinctrl@1c20800
> >>>   gpio          0  [ + ]   gpio_sunxi            |   |   |-- pinctrl@1c20800
> >>>   gpio          1  [ + ]   gpio_sunxi            |   |   |   |-- PA
> >>>   gpio          2  [ + ]   gpio_sunxi            |   |   |   |-- PB
> >>>   gpio          3  [ + ]   gpio_sunxi            |   |   |   |-- PC
> >>>   gpio          4  [ + ]   gpio_sunxi            |   |   |   |-- PD
> >>>   gpio          5  [ + ]   gpio_sunxi            |   |   |   |-- PE
> >>>   gpio          6  [ + ]   gpio_sunxi            |   |   |   |-- PF
> >>>   gpio          7  [ + ]   gpio_sunxi            |   |   |   `-- PG
> >>>   pinconfig     0  [   ]   pinconfig             |   |   |-- csi-pins
> >>>   pinconfig     1  [   ]   pinconfig             |   |   |-- emac-rgmii-pins
> >>>   pinconfig     2  [   ]   pinconfig             |   |   |-- i2c0-pins
> >>>   pinconfig     3  [   ]   pinconfig             |   |   |-- i2c1-pins
> >>>   pinconfig     4  [   ]   pinconfig             |   |   |-- i2c2-pins
> >>>   pinconfig     5  [ + ]   pinconfig             |   |   |-- mmc0-pins
> >>>   pinconfig     6  [   ]   pinconfig             |   |   |-- mmc1-pins
> >>>   pinconfig     7  [   ]   pinconfig             |   |   |-- mmc2-8bit-pins
> >>>   pinconfig     8  [   ]   pinconfig             |   |   |-- spdif-tx-pin
> >>>   pinconfig     9  [   ]   pinconfig             |   |   |-- spi0-pins
> >>>   pinconfig    10  [   ]   pinconfig             |   |   |-- spi1-pins
> >>>   pinconfig    11  [ + ]   pinconfig             |   |   |-- uart0-pa-pins
> >>>   pinconfig    12  [   ]   pinconfig             |   |   |-- uart1-pins
> >>>   pinconfig    13  [   ]   pinconfig             |   |   |--
> >>> uart1-rts-cts-pins
> >>>   pinconfig    14  [   ]   pinconfig             |   |   |-- uart2-pins
> >>>   pinconfig    15  [   ]   pinconfig             |   |   |--
> >>> uart2-rts-cts-pins
> >>>   pinconfig    16  [   ]   pinconfig             |   |   |-- uart3-pins
> >>>   pinconfig    17  [   ]   pinconfig             |   |   |--
> >>> uart3-rts-cts-pins
> >>>   pinconfig    18  [   ]   pinconfig             |   |   |-- ahci_pwr_pin@0
> >>>   pinconfig    19  [   ]   pinconfig             |   |   |-- usb0_vbus_pin@0
> >>>   pinconfig    20  [   ]   pinconfig             |   |   |-- usb1_vbus_pin@0
> >>>   pinconfig    21  [   ]   pinconfig             |   |   `-- usb2_vbus_pin@0
> >>>   ethernet      0  [ + ]   eth_sun8i_emac        |   |-- ethernet@1c30000
> >>>   bootdev       1  [   ]   eth_bootdev           |   |   `--
> >>> ethernet@1c30000.bootdev
> >>>   watchdog      0  [ + ]   sunxi_wdt             |   |-- watchdog@1c20ca0
> >>>   sysreset      0  [   ]   wdt_reboot            |   |   `-- watchdog@1c20ca0
> >>>   serial        0  [ + ]   ns16550_serial        |   |-- serial@1c28000
> >>>   clk           1  [ + ]   clk_sun6i_rtc         |   |-- rtc@1f00000
> >>>   clk           2  [ + ]   sun6i_a31_r_ccu       |   |-- clock@1f01400
> >>>   reset         1  [   ]   sunxi_reset           |   |   `-- reset
> >>>   i2c           0  [   ]   i2c_mvtwsi            |   |-- i2c@1f02400
> >>>   pinctrl       1  [ + ]   sunxi-pinctrl         |   `-- pinctrl@1f02c00
> >>>   gpio          8  [ + ]   gpio_sunxi            |       |-- pinctrl@1f02c00
> >>>   gpio          9  [ + ]   gpio_sunxi            |       |   `-- PL
> >>>   pinconfig    22  [   ]   pinconfig             |       |-- r-ir-rx-pin
> >>>   pinconfig    23  [   ]   pinconfig             |       |-- r-i2c-pins
> >>>   pinconfig    24  [   ]   pinconfig             |       `-- r-pwm-pin
> >>>   clk           3  [ + ]   fixed_clock           |-- osc24M_clk
> >>>   clk           4  [   ]   fixed_clock           |-- osc32k_clk
> >>>   bootstd       0  [   ]   bootstd_drv           `-- bootstd
> >>>   bootmeth      0  [   ]   bootmeth_distro           |-- distro
> >>>   bootmeth      1  [   ]   bootmeth_efi              |-- efi
> >>>   bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
> >>>   bootdev       2  [   ]   system_bootdev            `-- system-bootdev
> >>>
> >>> grub rescue> ls
> >>> (hd0)
> >>>
> >>> Grub does not see any partition at all.
> >>>
> >>> Loading a device from a partition does not create a handle for the device:
> >>
> >> Actually, loading an image does *not* invoke a probe function at all
> >> under the current implementation (of either "part" command,
> >> scan_dev_for_boot_part or even mmc drivers?).
> 
> We call efi_disk_init() after the MMC device is probed. Therefore
> probing of the MCC device does not trigger EVT_DM_POST_PROBE.
> 
> We have to move the efi_disk_init() call before initr_dm().
> 
> [PATCH 1/1] efi_loader: call efi_init_early() earlier
> https://lists.denx.de/pipermail/u-boot/2022-April/482701.html
> 
> With the patch GRUB now sees the MMC device but it is still not seeing
> the partitions:
> 
> grub rescue> ls
> (hd0) (hd1)
> 
> This is strange because devices and protocols look rather normal now:

Do you have the fix for the raw disk support in your tree?  I suspect
that GRUB needs that to read the partition table.

> => dm tree
>   Class     Index  Probed  Driver                Name
> -----------------------------------------------------------
>   root          0  [ + ]   root_driver           root_driver
>   simple_bus    0  [ + ]   simple_bus            |-- soc
>   mmc           0  [ + ]   sunxi_mmc             |   |-- mmc@1c0f000
>   blk           0  [ + ]   mmc_blk               |   |   |-- mmc@1c0f000.blk
>   partition     0  [ + ]   blk_partition         |   |   |   |--
> mmc@1c0f000.blk:1
>   partition     1  [ + ]   blk_partition         |   |   |   |--
> mmc@1c0f000.blk:2
>   partition     2  [ + ]   blk_partition         |   |   |   `--
> mmc@1c0f000.blk:3
>   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
>   partition     3  [ + ]   blk_partition         |   |           |   `--
> usb_mass_storage.lun0:1
>   bootdev       3  [   ]   usb_bootdev           |   |           `--
> usb_mass_storage.lun0.bootdev
> 
> => efidebug devices
> Device   Device Path
> ======== ====================
> 79f701e8 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> 79f70cd8 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)
> 79f70de0
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,MBR,0xb6b4facb,0x800,0x200000)
> 79f711b0
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,MBR,0xb6b4facb,0x200800,0x200000)
> 79f71538
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(3,MBR,0xb6b4facb,0x400800,0x379f800)
> 79f811b8
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> 79f81260
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> 79fdd748 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> 
> => efidebug dh
> Handle   Protocols
> ======== ====================
> 79f701e8 Device Path, Device Path To Text, Device Path Utilities,
> Device-Tree Fixup, Unicode Collation 2, HII String, HII Database, Simple
> Text Output, Simple Text Input, Simple Text Input Ex
> 7dffc7ec Device Path
> 79f70cd8 Device Path, Block IO
> 79f70de0 Device Path, Block IO, System Partition, Simple File System
> 79f711b0 Device Path, Block IO, Simple File System
> 79f71538 Device Path, Block IO, Simple File System
> 79f811b8 Device Path, Block IO
> 79f81260 Device Path, Block IO, System Partition, Simple File System
> 79f84978 Driver Binding
> 79fdd748 Simple Network, Device Path, PXE Base Code
> 
> This is the console log *before* the patch:
> 
> U-Boot 2022.07-rc1-00082-g8b2b125e95-dirty (Apr 28 2022 - 06:01:10
> +0000) Allwinner Technology
> 
> CPU:   Allwinner H3 (SUN8I 1680)
> Model: Xunlong Orange Pi PC
> DRAM:  1 GiB
> drivers/mmc/sunxi_mmc.c(723)sunxi_mmc_bind:
> sunxi_set_gate: (CLK#54) unhandled
> Core:  70 devices, 20 uclasses, devicetree: separate
> WDT:   Not starting watchdog@1c20ca0
> MMC:   drivers/mmc/sunxi_mmc.c(667)sunxi_mmc_probe:
> mmc@1c0f000: 0
> Loading Environment from FAT... drivers/mmc/mmc-uclass.c(487)mmc_blk_probe:
> drivers/block/blk-uclass.c(746)blk_post_probe:
> drivers/block/blk-uclass.c(752)blk_post_probe:
> disk/part.c(242)part_init:
> part_init: try 'EFI': ret=-1
> part_init: try 'DOS': ret=0
> part_create_block_devices: 3 partitions found in mmc@1c0f000.blk
> disk/part.c(242)part_init:
> part_init: try 'EFI': ret=-1
> part_init: try 'DOS': ret=0
> Unable to read "uboot.env" from mmc0:1...
> In:    serial
> Out:   serial
> Err:   serial
> Net:   phy interface1
> eth0: ethernet@1c30000
> lib/efi_loader/efi_disk.c(739)efi_disk_init:
> starting USB...
> Bus usb@1c1a000: USB EHCI 1.00
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1a400: USB OHCI 1.0
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1b000: lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> sunxi_set_gate: (CLK#9) unhandled
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> USB EHCI 1.00
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1b400: USB OHCI 1.0
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1c000: USB EHCI 1.00
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1c400: USB OHCI 1.0
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1d000: USB EHCI 1.00
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> Bus usb@1c1d400: USB OHCI 1.0
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> scanning bus usb@1c1a000 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
> scanning bus usb@1c1a400 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
> scanning bus usb@1c1b000 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
> scanning bus usb@1c1b400 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
> scanning bus usb@1c1c000 for devices...
> drivers/block/blk-uclass.c(746)blk_post_probe:
> drivers/block/blk-uclass.c(752)blk_post_probe:
> disk/part.c(242)part_init:
> part_init: try 'EFI': ret=-1
> part_init: try 'DOS': ret=0
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> part_create_block_devices: 1 partitions found in usb_mass_storage.lun0
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(568)efi_disk_create_part:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 2 USB Device(s) found
> scanning bus usb@1c1c400 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
> scanning bus usb@1c1d000 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
> scanning bus usb@1c1d400 for devices...
> lib/efi_loader/efi_disk.c(622)efi_disk_probe:
> 1 USB Device(s) found
>         scanning usb for storage devices... 1 Storage Device(s) found
> Hit any key to stop autoboot:  0
> 
> Best regards
> 
> Heinrich
> 
> >>
> >> I think that this is weird as the purpose of "probe" is to activate
> >> the device, or "probe - make a device ready for use" according to
> >>      doc/develop/driver-model/design.rst
> >>
> >> So my conclusion is that the current implementation has already broken
> >> the driver model even before my patch was applied.
> >>          -> Simon, you should have a comment here?
> >>
> >> That said, fixing a problem is a different matter.
> >> Probably, we will have to modify "part" command or mmc drivers themselves.
> >
> > Can you figure out an easy way to reproduce the issue?
> > (either on sandbox or qemu-arm)
> > Otherwise, it is difficult for me to investigate it.
> >
> > -Takahiro Akashi
> >
> >
> >> -Takahiro Akashi
> >>
> >>> => efidebug devices
> >>> ** Unable to read file ubootefi.var **
> >>> Failed to load EFI variables
> >>> Device   Device Path
> >>> ======== ====================
> >>> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> >>> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> >>> 79f7f1f8
> >>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> >>> 79f7f2a0
> >>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> >>> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> >>> => bootefi $kernel_addr_r
> >>> Booting /helloworld.efi
> >>> invalid image type: 0
> >>> Hello, world!
> >>> => efidebug devices
> >>> Device   Device Path
> >>> ======== ====================
> >>> 79f80f08 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> >>> 7dffc7ec /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Uart(0,0,D,D)
> >>> 79f7f1f8
> >>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)
> >>> 79f7f2a0
> >>> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/UsbClass(0x0,0x0,0x9,0x0,0x1)/UsbClass(0x781,0x5571,0x0,0x0,0x0)/HD(1,MBR,0x0c449046,0x800,0x800)
> >>> 79fdc188 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/MAC(0281431d5371,1)
> >>> =>
> >>>
> >>> So the current state is a complete mess.
> >>>
> >>> Best regards
> >>>
> >>> Heinrich
> 
>
Heinrich Schuchardt April 28, 2022, 9:42 a.m. UTC | #12
On 4/28/22 11:09, Mark Kettenis wrote:
>> We call efi_disk_init() after the MMC device is probed. Therefore
>> probing of the MCC device does not trigger EVT_DM_POST_PROBE.
>>
>> We have to move the efi_disk_init() call before initr_dm().
>>
>> [PATCH 1/1] efi_loader: call efi_init_early() earlier
>> https://lists.denx.de/pipermail/u-boot/2022-April/482701.html
>>
>> With the patch GRUB now sees the MMC device but it is still not seeing
>> the partitions:
>>
>> grub rescue> ls
>> (hd0) (hd1)
>>
>> This is strange because devices and protocols look rather normal now:
> Do you have the fix for the raw disk support in your tree?  I suspect
> that GRUB needs that to read the partition table.
>

Do you relate to an existing patch or only to the bug that you reported?

Best regards

Heinrich
Mark Kettenis April 28, 2022, 10:11 a.m. UTC | #13
> Date: Thu, 28 Apr 2022 11:42:19 +0200
> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> On 4/28/22 11:09, Mark Kettenis wrote:
> >> We call efi_disk_init() after the MMC device is probed. Therefore
> >> probing of the MCC device does not trigger EVT_DM_POST_PROBE.
> >>
> >> We have to move the efi_disk_init() call before initr_dm().
> >>
> >> [PATCH 1/1] efi_loader: call efi_init_early() earlier
> >> https://lists.denx.de/pipermail/u-boot/2022-April/482701.html
> >>
> >> With the patch GRUB now sees the MMC device but it is still not seeing
> >> the partitions:
> >>
> >> grub rescue> ls
> >> (hd0) (hd1)
> >>
> >> This is strange because devices and protocols look rather normal now:
> > Do you have the fix for the raw disk support in your tree?  I suspect
> > that GRUB needs that to read the partition table.
> >
> 
> Do you relate to an existing patch or only to the bug that you reported?

There is a patch now:

https://patchwork.ozlabs.org/project/uboot/patch/20220428044916.52250-1-takahiro.akashi@linaro.org/

Cheers,

Mark