starfive-tech / u-boot

44 stars 33 forks source link

Failed to boot from eMMC on VisionFive 2 #48

Open pinkavaj opened 1 year ago

pinkavaj commented 1 year ago

Boot from eMMc fails on on VisionFive 2. On eMMc is writen the the Debian Image (1) with modifications necessary to boot from eMMc. After running the command bellow in U-Boot the system boots fine.

U-Boot command to fix the boot

setenv fatbootpart 0:3
# saveenv  # - uncomment to save the configuration
boot

It looks like for some reason the fatbootpart partition number is not set from $devnum but mey-be hardcoded to 1:3?

Error

Card did not respond to voltage select! : -110
Couldn't find partition mmc 1:3
Can't set block device
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Card did not respond to voltage select! : -110
Couldn't find partition mmc 1:3
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
Card did not respond to voltage select! : -110
Couldn't find partition mmc 1:3
Retrieving file: /extlinux/extlinux.conf
Card did not respond to voltage select! : -110
Couldn't find partition mmc 1:3
Can't set block device
Error reading config file

1) Debian image: https://drive.google.com/drive/folders/1cctIVdCfbPhKpyQ0PcmCQ92KCQjJ8JI5 2) The U-Boot/SLP were updated to the ones provided by release: VisionFive2 Software v2.11.5

pinkavaj commented 1 year ago

I'm kind of suspecting this part of the code https://github.com/starfive-tech/u-boot/blob/688befadf1d337dee3593e6cc0fe1c737cc150bd/include/configs/starfive-visionfive2.h#L136-L140

I would expect the fatbootpart will be set correctly, but for some reason it probably does not work as-expected.

MichaIng commented 1 year ago

Indeed too many things are hardcoded, including the fact that it is fatbootpart and not just generic bootpart using load instead of fatload to be compatible with any filesystem type.

When not following the 4 partitions layout, so that bootcmd_distro fails, bootcmd_mmc0 is used next which has a generic partitions scanning for first extlinux>boot.scr>EFI on the SD card, which I would usually expect right from the start. But there is no mmc1 boot target defined to do the same for the eMMC.

Using an all generic method however makes it more complicated to do the as well hardcoded starfive_visionfive2.dtb rewrite on every boot to enable 8 GiB RAM support and Ethernet for the A1.2 variant. Doing all this properly with this vendor U-Boot seems to be a too large rewrite to be realistic. I hope the upstream implementation comes with a sane generic ordered boot partition detection across all storage devices, partition numbers and filesystem types.