Skip to content

Commit

Permalink
feat:Try to add rock 5a armbian support
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnchainw committed Mar 4, 2024
1 parent 4d62648 commit 21e3498
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
44 changes: 38 additions & 6 deletions rockpi-penta/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
#!/bin/sh -e
#!/bin/bash -e

checkReboot(){
checkReboot() {
echo Installation will take effect after reboot!!!
}

is_armbian() {
if [ -f /boot/armbianEnv.txt ] || [ -f /boot/dietpiEnv.txt ]; then
echo true
else
echo false
fi
}

armbian_require_overlay() {
envFile='/boot/armbianEnv.txt'
[ -f /boot/dietpiEnv.txt ] && envFile='/boot/dietpiEnv.txt'
overlays=$(grep '^overlays=' "$envFile" | cut -d'=' -f2)
for arg in "$@"; do
if grep -qE "(^|[[:space:]])$arg([[:space:]]|$)" <<< $overlays; then
echo "Overlay ${arg} was already added to $envFile, skip..."
else
overlays="${overlays} ${arg}"
echo "Added overlay: $arg"
fi
done
if grep -q "^overlays=" $envFile; then
sed -i '/^overlays=/c\'"overlays=$overlays" $envFile
else
echo "overlays=$overlays" >> $envFile
fi
}

if [ "$(python3 -c 'import sys; print(f"{sys.version_info.minor >= 11}")')" = "True" ]; then
pip3 install adafruit-circuitpython-ssd1306 --break-system-packages
else
Expand All @@ -26,10 +53,15 @@ case "$model" in
systemctl start rockpi-penta.service
;;
*"ROCK 5"*)
mv /boot/dtbo/rk3588-i2c8-m2.dtbo.disabled /boot/dtbo/rk3588-i2c8-m2.dtbo || true
mv /boot/dtbo/rk3588-pwm14-m1.dtbo.disabled /boot/dtbo/rk3588-pwm14-m1.dtbo.dtbo || true
cp /usr/bin/rockpi-penta/env/rock_5a.env /etc/rockpi-penta.env
u-boot-update || true
if [ "$(is_armbian)" = "true" ]; then
armbian_require_overlay rk3588-i2c8-m2 rk3588-pwm14-m1
cp /usr/bin/rockpi-penta/env/rock_5a_armbian.env /etc/rockpi-penta.env
else
mv /boot/dtbo/rk3588-i2c8-m2.dtbo.disabled /boot/dtbo/rk3588-i2c8-m2.dtbo || true
mv /boot/dtbo/rk3588-pwm14-m1.dtbo.disabled /boot/dtbo/rk3588-pwm14-m1.dtbo || true
cp /usr/bin/rockpi-penta/env/rock_5a.env /etc/rockpi-penta.env
u-boot-update || true
fi
checkReboot
;;
*"ROCK3 Model C"*)
Expand Down
7 changes: 7 additions & 0 deletions rockpi-penta/usr/bin/rockpi-penta/env/rock_5a_armbian.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SDA=I2C8_SDA_M4
SCL=I2C8_SCL_M4
OLED_RESET=GPIO1_A5
PWMCHIP=1
BUTTON_CHIP=4
BUTTON_LINE=11
HARDWARE_PWM=1

0 comments on commit 21e3498

Please sign in to comment.