Skip to content

Commit 15e454b

Browse files
authored
Initial Support for Orange pi 5 pro board (#8348)
* Add initial support for Orangepi 5 Pro Tested and Working: Wireless & Bluetooth USB 2.0 + USB 3.1 HDMI 2.1 Gigabit Ethernet (PCIe to RJ45 - Need drivers YT6801) NVMe PCIe 2.0 MicroSD Audio Controller es8388 - Audio Out FAN PWM LEDs PWM Not Working: Onboard Microphone HDMI 2.0 (DP-HDMI - rockchip,rk3588-dp No Driver) Not Tested: Camera 1,2 eMMC * OPi 5 Pro: Ethernet Driver Installation on First Boot Implemented a simple script to install the driver during first boot using the installation headers included in the image. Takes just a few seconds on first boot. Disclaimer: Attempted installation in a chroot env but failed. * fix: Make first-boot Ethernet driver install more robust The `eth-driver-firstboot.service` would sometimes fail on first boot with a "Resource temporarily unavailable" error. This happened when another process had a lock on `dpkg`. To fix this, the installation script now waits for any `dpkg` locks to be released before attempting to install the driver package. It also includes a retry mechanism (3 attempts) in case of a transient failure. This ensures the network driver is successfully installed, providing a better out-of-box experience.
1 parent fa8604e commit 15e454b

File tree

3 files changed

+1368
-2
lines changed

3 files changed

+1368
-2
lines changed

config/boards/orangepi5pro.csc

Lines changed: 144 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BOARD_MAINTAINER=""
55
BOOTCONFIG="orangepi_5_pro_defconfig" # vendor name, not standard, see hook below, set BOOT_SOC below to compensate
66
BOOTCONFIG_SATA="orangepi_5_pro_sata_defconfig"
77
BOOT_SOC="rk3588"
8-
KERNEL_TARGET="vendor"
8+
KERNEL_TARGET="vendor,edge"
99
FULL_DESKTOP="yes"
1010
BOOT_LOGO="desktop"
1111
BOOT_FDT_FILE="rockchip/rk3588s-orangepi-5-pro.dtb"
@@ -49,9 +49,151 @@ function post_uboot_custom_postprocess__create_sata_spi_image() {
4949
dd if=u-boot.itb of=rkspi_loader_sata.img seek=16384 conv=notrunc
5050
}
5151

52+
function post_family_config_branch_edge__orangepi5pro_use_mainline_uboot() {
53+
display_alert "$BOARD" "Mainline U-Boot overrides for $BOARD - $BRANCH" "info"
54+
declare -g BOOTCONFIG="orangepi-5-pro-rk3588s_defconfig"
55+
declare -g BOOTDELAY=1
56+
declare -g BOOTSOURCE="https://github.com/u-boot/u-boot.git"
57+
declare -g BOOTBRANCH="tag:v2024.04"
58+
declare -g BOOTPATCHDIR="v2024.04"
59+
declare -g BOOTDIR="u-boot-${BOARD}"
60+
declare -g UBOOT_TARGET_MAP="BL31=${RKBIN_DIR}/${BL31_BLOB} ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB};;u-boot-rockchip.bin u-boot-rockchip-spi.bin"
61+
declare -g INSTALL_HEADERS="yes"
62+
unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd
63+
64+
function write_uboot_platform() {
65+
dd "if=$1/u-boot-rockchip.bin" "of=$2" bs=32k seek=1 conv=notrunc status=none
66+
}
67+
68+
function write_uboot_platform_mtd() {
69+
flashcp -v -p "$1/u-boot-rockchip-spi.bin" /dev/mtd0
70+
}
71+
}
72+
73+
# Install Ethernet Driver during first boot
74+
function pre_customize_image__orangepi5pro_add_phy_driver() {
75+
local deb_file="tuxedo-yt6801_1.0.28-1_all.deb"
76+
local service_name="eth-driver-firstboot.service"
77+
78+
display_alert "Setting up Ethernet driver build for first boot" "$BOARD" "info"
79+
80+
# Pre-install dependencies
81+
chroot_sdcard apt-get update
82+
chroot_sdcard apt-get install -y dkms build-essential
83+
84+
# Create directory and download .deb (Not installing due to chroot issue with dkms and kernel headers)
85+
chroot_sdcard mkdir -p /usr/local/share/eth-driver
86+
chroot_sdcard wget "https://github.com/dante1613/Motorcomm-YT6801/raw/main/tuxedo-yt6801/${deb_file}" -O "/usr/local/share/eth-driver/${deb_file}"
87+
88+
# Make script to Auto-Install Ethernet Driver Only on first boot
89+
cat << 'EOF' > "${SDCARD}/usr/local/bin/install-eth-driver.sh"
90+
#!/bin/bash
91+
set -e
92+
93+
DEB_FILE="/usr/local/share/eth-driver/tuxedo-yt6801_1.0.28-1_all.deb"
94+
LOG_FILE="/var/log/eth-driver-install.log"
95+
96+
# Wait for dpkg locks to be released
97+
wait_for_dpkg() {
98+
echo "Checking package manager locks..." >> $LOG_FILE
99+
100+
# Wait for up to 1 minute
101+
local timeout=60
102+
local start_time=$(date +%s)
103+
104+
while true; do
105+
# Check if we've exceeded timeout
106+
local current_time=$(date +%s)
107+
if [ $((current_time - start_time)) -gt $timeout ]; then
108+
echo "Timeout waiting for locks to be released. Continuing anyway..." >> $LOG_FILE
109+
break
110+
fi
111+
112+
# Check for dpkg locks
113+
if lsof /var/lib/dpkg/lock >/dev/null 2>&1 || \
114+
lsof /var/lib/apt/lists/lock >/dev/null 2>&1 || \
115+
lsof /var/cache/apt/archives/lock >/dev/null 2>&1 || \
116+
lsof /var/cache/debconf/config.dat >/dev/null 2>&1; then
117+
echo "Waiting for package manager locks to be released... ($(date))" >> $LOG_FILE
118+
sleep 1
119+
continue
120+
else
121+
echo "All package manager locks are available" >> $LOG_FILE
122+
break
123+
fi
124+
done
125+
}
126+
127+
# Install driver package without internet
128+
install_driver() {
129+
echo "Starting driver install" >> $LOG_FILE
130+
local max_attempts=3
131+
local attempt=1
132+
local success=false
133+
134+
while [ $attempt -le $max_attempts ]; do
135+
echo "Installation attempt $attempt of $max_attempts" >> $LOG_FILE
136+
# Always wait for dpkg locks before attempting
137+
wait_for_dpkg
138+
139+
# Try to install the package
140+
if dpkg -i $DEB_FILE >> $LOG_FILE 2>&1; then
141+
echo "Installation successful on attempt $attempt" >> $LOG_FILE
142+
success=true
143+
break
144+
else
145+
echo "Installation attempt $attempt failed" >> $LOG_FILE
146+
sleep 5
147+
attempt=$((attempt + 1))
148+
fi
149+
done
150+
151+
if [ "$success" = true ]; then
152+
echo "Ethernet driver installed correctly." >> $LOG_FILE
153+
# Clean up files
154+
rm -f $DEB_FILE
155+
# Disable service
156+
systemctl disable eth-driver-firstboot.service
157+
return 0
158+
else
159+
echo "Failed to install driver after $max_attempts attempts." >> $LOG_FILE
160+
# Don't exit with error to avoid service failure
161+
return 0
162+
fi
163+
}
164+
165+
# Execute installation
166+
install_driver
167+
EOF
168+
169+
# Make executable script
170+
chmod +x "${SDCARD}/usr/local/bin/install-eth-driver.sh"
171+
172+
# Creating the service
173+
cat << EOF > "${SDCARD}/etc/systemd/system/${service_name}"
174+
[Unit]
175+
Description=Install YT6801 Ethernet driver on first boot
176+
After=systemd-modules-load.service
177+
Before=network.target network-online.target
178+
179+
[Service]
180+
Type=oneshot
181+
ExecStart=/usr/local/bin/install-eth-driver.sh
182+
RemainAfterExit=true
183+
184+
[Install]
185+
WantedBy=multi-user.target
186+
EOF
187+
188+
# Enable service for First Boot
189+
chroot_sdcard systemctl enable "${service_name}"
190+
191+
display_alert "Ethernet driver setup complete" "Will be installed on first boot (offline)" "info"
192+
}
193+
52194
# Override family config for this board; let's avoid conditionals in family config.
53195
function post_family_config__orangepi5pro_use_vendor_uboot() {
54196
BOOTSOURCE='https://github.com/orangepi-xunlong/u-boot-orangepi.git'
55197
BOOTBRANCH='branch:v2017.09-rk3588'
56198
BOOTPATCHDIR="legacy"
57-
}
199+
}

0 commit comments

Comments
 (0)