fix: make it boot on pinephone

This commit is contained in:
DanyLE
2025-07-21 00:10:47 +02:00
parent 1fe7d54ae8
commit 37571d17cc
11 changed files with 238 additions and 58 deletions

View File

@@ -1,7 +1,6 @@
# default values
setenv load_addr "0x45000000"
setenv overlay_error "false"
setenv rootdev "/dev/mmcblk1p2"
setenv verbosity "1"
setenv rootfstype "ext4"
setenv console "both"
@@ -11,18 +10,23 @@ setenv recovery "false"
setenv recovery_image "recovery.initramfs"
# Print boot source
itest.b *0x10028 == 0x00 && echo "U-boot loaded from SD"
itest.b *0x10028 == 0x02 && echo "U-boot loaded from eMMC or secondary SD"
itest.b *0x10028 == 0x03 && echo "U-boot loaded from SPI"
if test ${mmc_bootdev} -eq 0; then
echo "Booting from SD device 0"
setenv rootdev "/dev/mmcblk0p2"
else
echo "Booting from eMMC"
setenv rootdev "/dev/mmcblk2p2"
fi
echo "Boot script loaded from ${devtype}"
echo "Loading environment variables from ${devtype} ${devnum} diya-config.txt"
if test -e ${devtype} ${devnum} diya-config.txt; then
load ${devtype} ${devnum} ${load_addr} diya-config.txt
env import -t ${load_addr} ${filesize}
load ${devtype} ${devnum} ${load_addr} diya-config.txt
env import -t ${load_addr} ${filesize}
fi
if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=ttyS0,115200 console=tty1"; fi
if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=ttyS0,115200 console=tty0"; fi
if test "${console}" = "serial"; then setenv consoleargs "console=ttyS0,115200"; fi
if test "${bootlogo}" = "true"; then
setenv consoleargs "splash plymouth.ignore-serial-consoles ${consoleargs}"
@@ -32,44 +36,48 @@ fi
# get PARTUUID of first partition on SD/eMMC it was loaded from
# mmc 0 is always mapped to device u-boot (2016.09+) was loaded from
if test "${devtype}" = "mmc"; then part uuid mmc 0:1 partuuid; fi
if test "${devtype}" = "mmc"; then part uuid mmc 0:2 partuuid; fi
# consoleblank=0 loglevel=${verbosity}
setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} ubootpart=${partuuid} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"
echo "Root dev PARTUUID is ${partuuid}"
setenv bootargs "root=PARTUUID=${partuuid} rootwait rootfstype=${rootfstype} ${consoleargs} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"
echo "Loading kernel FDT from ${devtype} ${devnum} ${fdtfile}"
load ${devtype} ${devnum} ${fdt_addr_r} ${fdtfile}
fdt addr ${fdt_addr_r}
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} allwinner/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
if load ${devtype} ${devnum} ${load_addr} allwinner/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done
if test "${overlay_error}" = "true"; then
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${fdtfile}
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${fdtfile}
fi
if test "${ethernet_phy}" = "rtl8211f"; then
fdt set /soc/ethernet@5020000 allwinner,rx-delay-ps <3100>
fdt set /soc/ethernet@5020000 allwinner,tx-delay-ps <700>
fi
# if test "${ethernet_phy}" = "rtl8211f"; then
# fdt set /soc/ethernet@5020000 allwinner,rx-delay-ps <3100>
# fdt set /soc/ethernet@5020000 allwinner,tx-delay-ps <700>
# fi
if test "${ethernet_phy}" = "yt8531c"; then
fdt set /soc/ethernet@5020000 allwinner,rx-delay-ps <0>
fdt set /soc/ethernet@5020000 allwinner,tx-delay-ps <600>
fi
# if test "${ethernet_phy}" = "yt8531c"; then
# fdt set /soc/ethernet@5020000 allwinner,rx-delay-ps <0>
# fdt set /soc/ethernet@5020000 allwinner,tx-delay-ps <600>
# fi
echo "Loading kernel from ${devtype} ${devnum} ${kernel_addr_r} Image"
load ${devtype} ${devnum} ${kernel_addr_r} Image
if test "${recovery}" = "true"; then
load ${devtype} ${devnum} ${ramdisk_addr_r} ${recovery_image}
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
echo "Booting Diya in recovery mode"
load ${devtype} ${devnum} ${ramdisk_addr_r} ${recovery_image}
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
else
booti ${kernel_addr_r} - ${fdt_addr_r}
echo "Booting Diya"
booti ${kernel_addr_r} - ${fdt_addr_r}
fi
# Recompile with: