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,3 +1,17 @@
# meta-pinephone-diya
Pinephone yocto layer for diya
Pinephone yocto layer for diya
# Notes
To power on the modem
```sh
echo 1 > /sys/class/modem-power/modem-power/device/powered
```
Enable GPS
```sh
mmcli -m 0 --command="AT+QGPS=1,30,50,0,2"
```

View File

@@ -15,7 +15,7 @@ LAYERSERIES_COMPAT_meta-pinephone-diya = "walnascar"
MACHINE ?= "pinephone"
PREFERRED_PROVIDER_virtual/kernel = "linux-megi"
PREFERRED_VERSION_linux-megi = "6.15.0"
PREFERRED_VERSION_linux-megi = "6.15.6"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-megous"
PREFERRED_PROVIDER_u-boot = "u-boot-megous"
@@ -33,4 +33,5 @@ PREFERRED_PROVIDER_u-boot = "u-boot-megous"
# extra kernel CMDLINE_RNDIS option
# CMDLINE_RNDIS += " video=DPI-1:480x640,rotate=90 "
# accept license for wifi and bluetooth firmware
LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch commercial"
LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch commercial"
SERIAL_CONSOLES:append = " ttyS0,115200 "

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:

View File

@@ -0,0 +1,40 @@
DESCRIPTION = "Diya session manager"
DEPENDS = "glib-2.0"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI += "git://git.iohub.dev/dany/eg25-manager.git;protocol=https;branch=master \
file://eg25d"
SRCREV = "${AUTOREV}"
PV = "0.5.2+git${SRCPV}"
S = "${UNPACKDIR}/git"
DEPENDS:append = " libgudev libgpiod libusb curl "
inherit meson pkgconfig
# inherit update-rc.d
# INITSCRIPT_NAME = "diya-sessiond"
# INITSCRIPT_PARAMS = "start 30 5 . stop 10 0 1 6 ."
do_install:append() {
install -d ${D}/etc/init.d
install -m 0755 ${UNPACKDIR}/eg25d ${D}/etc/init.d/
install -d ${D}/etc/udev/
install -d ${D}/etc/udev/rules.d
mv ${D}/usr/lib/udev/rules.d/80-modem-eg25.rules ${D}/etc/udev/rules.d/
rm ${D}/usr/lib/systemd/system/eg25-manager.service
rm -rf ${D}/usr/lib/systemd
install -d ${D}/etc/eg25-manager/
mv ${D}/usr/share/eg25-manager/* ${D}/etc/eg25-manager/
rm -rf ${D}/usr/share
rm -rf ${D}/usr/lib
}
FILES:${PN} = " /etc/init.d/eg25d \
/etc/eg25-manager \
/etc/udev/rules.d/80-modem-eg25.rules \
/usr/bin/eg25-manager "

View File

@@ -0,0 +1,77 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: diya
# Short-Description: EG25 manager daemon
# Description: eg25-manager - Quectel EG25 management daemon
### END INIT INFO
#
# -*- coding: utf-8 -*-
# set -e
# shellcheck disable=SC1091
. /etc/init.d/functions
DAEMON=/usr/bin/eg25-manager
NAME=eg25d
PIDFILE=/var/run/diya/eg25d.pid
DESC="EG25 manager daemon"
DAEMONUSER="root"
PARAMS=
test -x $DAEMON || exit 0
start_it_up()
{
mkdir -p "$(dirname $PIDFILE)"
if [ -e $PIDFILE ]; then
PIDDIR=/proc/$(cat $PIDFILE)
if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
echo "$DESC already started; not starting."
else
echo "Removing stale PID file $PIDFILE."
rm -f $PIDFILE
fi
fi
echo -n "Starting $DESC: "
start-stop-daemon -o --start --quiet --pidfile $PIDFILE \
--user $DAEMONUSER --exec $DAEMON -- $PARAMS
echo "$NAME."
}
shut_it_down()
{
echo -n "Stopping $DESC: "
start-stop-daemon -o --stop --quiet --pidfile $PIDFILE \
--user $DAEMONUSER
# We no longer include these arguments so that start-stop-daemon
# can do its job even given that we may have been upgraded.
# We rely on the pidfile being sanely managed
# --exec $DAEMON -- --system $PARAMS
echo "$NAME."
rm -f $PIDFILE
}
case "$1" in
start)
start_it_up
;;
stop)
shut_it_down
;;
status)
status $DAEMON
exit $?
;;
restart)
shut_it_down
sleep 1
start_it_up
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|status|restart}" >&2
exit 1
;;
esac
exit 0

View File

@@ -2,13 +2,48 @@ hostname = "diya"
do_install:append () {
cat << 'EOF' >> "${D}${sysconfdir}/profile"
export DISK="mmcblk1"
export DISK="mmcblk0"
EOF
cat << EOF >> "${D}${sysconfdir}/modules"
sprdwl_ng
sprdbt_tty
install -d ${D}${sysconfdir}/modules-load.d
cat << EOF >> "${D}${sysconfdir}/modules-load.d/diya.conf"
option
cfg80211
bluetooth
hci_uart
rfcomm
qmi_wwan
usbnet
usb_wwan
usbserial
mii
snd_seq_dummy
snd_hrtimer
842_decompress
842_compress
zram
crct10dif_ce
polyval_ce
8723cs
btbcm
sm4
gpio_vibra
st_magn_spi
st_sensors_spi
sunxi_wdt
snd_soc_ec25
led_class_flash
i2c_gpio
ledtrig_pattern
i2c_algo_bit
ppkb_manager
joydev
sch_fq_codel
crypto_user
loop
fuse
nfnetlink
ip_tables
ipv6
sun4i_lradc_keys
EOF
}

View File

@@ -1,2 +1,2 @@
# IMAGE_BOOT_FILES:append:pinephone = " boot.scr ${KERNEL_DEVICETREE} allwinner/overlay/sun50i-h616-fixup.scr "
IMAGE_INSTALL:append:pinephone = " pinephone-firmware "
IMAGE_BOOT_FILES:append:pinephone = " boot.scr ${KERNEL_DEVICETREE} "
IMAGE_INSTALL:append:pinephone = " pinephone-firmware eg25-manager glibmm "

View File

@@ -1,7 +1,7 @@
image_patch:append () {
# create /etc/fstab
cat << EOF > ${IMAGE_ROOTFS}/etc/fstab
/dev/mmcblk1p1 /boot auto defaults 0 0
/dev/mmcblk1p4 /home auto defaults 0 0
/dev/mmcblk0p1 /boot auto defaults 0 0
/dev/mmcblk0p4 /home auto defaults 0 0
EOF
}

View File

@@ -11,11 +11,11 @@ CONFIG_THREAD_INFO_IN_TASK=y
CONFIG_INIT_ENV_ARG_LIMIT=32
# CONFIG_COMPILE_TEST is not set
# CONFIG_WERROR is not set
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_LOCALVERSION="-diya"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_BUILD_SALT=""
CONFIG_DEFAULT_INIT=""
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_DEFAULT_HOSTNAME="diya"
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_SYSVIPC_COMPAT=y
@@ -1823,25 +1823,27 @@ CONFIG_WLAN=y
# CONFIG_WLAN_VENDOR_ADMTEK is not set
# CONFIG_WLAN_VENDOR_ATH is not set
# CONFIG_WLAN_VENDOR_ATMEL is not set
# CONFIG_WLAN_VENDOR_BROADCOM is not set
CONFIG_WLAN_VENDOR_BROADCOM=y
# CONFIG_WLAN_VENDOR_INTEL is not set
# CONFIG_WLAN_VENDOR_INTERSIL is not set
# CONFIG_WLAN_VENDOR_MARVELL is not set
# CONFIG_WLAN_VENDOR_MEDIATEK is not set
CONFIG_WLAN_VENDOR_MEDIATEK=y
# CONFIG_WLAN_VENDOR_MICROCHIP is not set
# CONFIG_WLAN_VENDOR_PURELIFI is not set
# CONFIG_WLAN_VENDOR_RALINK is not set
# CONFIG_WLAN_VENDOR_REALTEK is not set
CONFIG_WLAN_VENDOR_REALTEK=y
# CONFIG_WLAN_VENDOR_RSI is not set
# CONFIG_WLAN_VENDOR_SILABS is not set
# CONFIG_WLAN_VENDOR_ST is not set
# CONFIG_WLAN_VENDOR_TI is not set
# CONFIG_WLAN_VENDOR_ZYDAS is not set
# CONFIG_WLAN_VENDOR_QUANTENNA is not set
# CONFIG_MAC80211_HWSIM is not set
# CONFIG_VIRT_WIFI is not set
CONFIG_WLAN_VENDOR_QUANTENNA=y
CONFIG_MAC80211_HWSIM=m
CONFIG_VIRT_WIFI=m
# CONFIG_WAN is not set
CONFIG_RTLWIFI=m
CONFIG_RTLWIFI_USB=m
CONFIG_RTLWIFI_DEBUG=y
#
# Wireless WAN
#
@@ -4413,6 +4415,9 @@ CONFIG_VIDEO_SUNXI_CEDRUS=m
# CONFIG_XIL_AXIS_FIFO is not set
# CONFIG_GPIB is not set
CONFIG_RTL8723CS=m
CONFIG_RTW88_8723X=m
CONFIG_RTW88_8723D=m
CONFIG_RTW88_8723DU=m
# CONFIG_GOLDFISH is not set
# CONFIG_CHROME_PLATFORMS is not set
# CONFIG_MELLANOX_PLATFORM is not set

View File

@@ -9,15 +9,15 @@ SRCREV = "${AUTOREV}"
COMPATIBLE_MACHINE = "(sun50i)"
LINUX_PINEPHONE_BRANCH ?= "pp-6.15"
LINUX_PINEPHONE_BRANCH ?= "orange-pi-6.15"
SRC_URI = " \
git://codeberg.org/megi/linux.git;branch=${LINUX_PINEPHONE_BRANCH};protocol=https \
file://defconfig \
file://0217-arm64-dts-allwinner-a64-Add-hdmi-sound-card.patch \
"
KBUILD_DEFCONFIG = "pinephone_defconfig"
# Pull in the devicetree files into the rootfs
RDEPENDS_${KERNEL_PACKAGE_NAME}-base += "kernel-devicetree"
RDEPENDS_${KERNEL_PACKAGE_NAME}-base += "kernel-devicetree u-boot"
KERNEL_EXTRA_ARGS += "LOADADDR=${UBOOT_ENTRYPOINT}"

View File

@@ -1,12 +1,12 @@
# short-description: Create Raspberry Pi SD card image
# long-description: Creates a partitioned SD card image for use with
part u-boot --source rawcopy --sourceparams="file=${SPL_BINARY}" --ondisk mmcblk1 --no-table --align 8
part /boot --source bootimg-partition --ondisk mmcblk1 --fstype=vfat --label boot --active --align 4096 --size 32
part u-boot --source rawcopy --sourceparams="file=${SPL_BINARY}" --ondisk mmcblk0 --no-table --align 8
part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4096 --size 32
# read only roofs
part / --source rootfs --ondisk mmcblk1 --fstype=ext4 --label root --align 4096 --size 150 --exclude-path home/ --exclude-path var/etc/ --exclude-path boot/
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root --align 4096 --size 150 --exclude-path home/ --exclude-path var/etc/ --exclude-path boot/
# modifiable configurations stored in /var/etc
part /var/etc --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/var/etc --ondisk mmcblk1 --fstype=ext4 --label diya --align 1024 --size 32
part /var/etc --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/var/etc --ondisk mmcblk0 --fstype=ext4 --label diya --align 1024 --size 32
# home partition
part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --ondisk mmcblk1 --fstype=ext4 --label home --align 1024 --size 16
# part /home --ondisk mmcblk1 --fstype=vfat --label music --active --align 1024 --size 16
part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --ondisk mmcblk0 --fstype=ext4 --label home --align 1024 --size 16
# part /home --ondisk mmcblk0 --fstype=vfat --label music --active --align 1024 --size 16