Add orange pi 4/4b support

This commit is contained in:
leeboby 2021-02-05 14:55:31 +08:00
parent cc92154127
commit daf1061335
14 changed files with 10730 additions and 2249 deletions

1
.gitignore vendored
View File

@ -35,4 +35,5 @@ external/cache/sources/sunxi-tools
external/cache/sources/rkbin-tools
external/cache/sources/orangepi-firmware
external/cache/sources/orangepi-firmware-git
external/cache/sources/rk3399_gst_xserver_libs
external/cache/sources/arm-trusted-firmware-sunxi-mainline

5
external/config/boards/orangepi4.conf vendored Normal file → Executable file
View File

@ -2,7 +2,6 @@
BOARD_NAME="OrangePi 4"
BOARDFAMILY="rk3399"
BOOTCONFIG="orangepi-4-rk3399_defconfig"
KERNEL_TARGET="current"
FULL_DESKTOP="yes"
ASOUND_STATE="asound.state.rt5651"
KERNEL_TARGET="legacy"
FULL_DESKTOP="no"
BOOT_LOGO="desktop"

File diff suppressed because it is too large Load Diff

77
external/config/sources/families/include/rockchip64_common.inc vendored Normal file → Executable file
View File

@ -10,6 +10,7 @@ SERIALCON=${SERIALCON:=$([ $BRANCH == "legacy" ] && echo "ttyFIQ0:1500000" || ec
GOVERNOR="ondemand"
BOOTBRANCH="branch:v2020.07-rockchip64"
PACKAGE_LIST_FAMILY="ethtool"
PACKAGE_LIST_DESKTOP_FAMILY="fcitx fonts-wqy-zenhei"
RKBIN_DIR="$EXTER/cache/sources/rkbin-tools"
@ -150,22 +151,22 @@ uboot_custom_postprocess()
elif [[ $BOOT_RK3399_LEGACY_HYBRID == yes ]]; then
# 3399
tools/mkimage -n rk3399 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rksd_loader.img
tools/mkimage -n rk3399 -T rksd -d $EXTER/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rksd_loader.img
cat spl/u-boot-spl.bin >> rksd_loader.img
dd if=u-boot.itb of=rksd_loader.img seek=448 conv=notrunc
cp rksd_loader.img $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
tools/mkimage -n rk3399 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rkspi_loader.img
cp rksd_loader.img $EXTER/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
tools/mkimage -n rk3399 -T rksd -d $EXTER/cache/sources/rkbin-tools/rk33/rk3399_ddr_933MHz_v1.13.bin rkspi_loader.img
cat spl/u-boot-spl.bin >> rkspi_loader.img
for i in `seq 1 128`; do dd count=4 status=none; dd if=/dev/zero count=4 status=none; done < rkspi_loader.img > rkspi_loader.tmp
mv rkspi_loader.tmp rkspi_loader.img
dd if=u-boot.itb of=rkspi_loader.img seek=1024 conv=notrunc
cp rkspi_loader.img $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
cp rkspi_loader.img $EXTER/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
elif [[ $BOOT_RK3328_USE_AYUFAN_ATF == yes ]]; then
# 3328
tools/mkimage -n rk3328 -T rksd -d $SRC/cache/sources/rkbin-tools/rk33/rk3328_ddr_786MHz_v1.13.bin idbloader.bin
cat $SRC/cache/sources/rkbin-tools/rk33/rk3328_miniloader_v2.46.bin >> idbloader.bin
tools/mkimage -n rk3328 -T rksd -d $EXTER/cache/sources/rkbin-tools/rk33/rk3328_ddr_786MHz_v1.13.bin idbloader.bin
cat $EXTER/cache/sources/rkbin-tools/rk33/rk3328_miniloader_v2.46.bin >> idbloader.bin
loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000
else
@ -229,7 +230,6 @@ setup_write_uboot_platform()
fi
}
atf_custom_postprocess()
{
@ -243,10 +243,49 @@ atf_custom_postprocess()
family_tweaks()
{
# execute specific tweaks function if present
[[ $(type -t family_tweaks_s) == function ]] && family_tweaks_s
if [[ $BOARD == orangepi4 && $BRANCH == legacy ]]; then
# Gstreamer library
GST_DIR="$EXTER/cache/sources/rk3399_gst_xserver_libs/gstreamer"
[[ ! -d "${SDCARD}"/usr/libexec ]] && mkdir -p "${SDCARD}"/usr/libexec
cp ${GST_DIR}/${RELEASE}_build/etc/iqfiles ${SDCARD}/etc/ -rfa
cp ${GST_DIR}/${RELEASE}_build/usr/bin/* ${SDCARD}/usr/bin/ -rfa
cp ${GST_DIR}/${RELEASE}_build/usr/include/* ${SDCARD}/usr/include/ -rfa
cp ${GST_DIR}/${RELEASE}_build/usr/lib/* ${SDCARD}/usr/lib/ -rfa
cp ${GST_DIR}/${RELEASE}_build/usr/share/* ${SDCARD}/usr/share/ -rfa
cp ${GST_DIR}/overlay/etc/udev/rules.d/* ${SDCARD}/etc/udev/rules.d/ -rfa
cp ${GST_DIR}/overlay/usr/local/bin/* ${SDCARD}/usr/local/bin/ -rfa
cp ${GST_DIR}/others/gstreamer/usr/bin/* ${SDCARD}/usr/bin/ -rfa
cp ${GST_DIR}/others/gstreamer/usr/include/* ${SDCARD}/usr/include/ -rfa
cp ${GST_DIR}/others/gstreamer/usr/lib/* ${SDCARD}/usr/lib/ -rfa
cp ${GST_DIR}/others/gstreamer/usr/libexec/* ${SDCARD}/usr/libexec/ -rfa
cp ${GST_DIR}/others/gstreamer/usr/local/* ${SDCARD}/usr/local/ -rfa
cp ${GST_DIR}/others/gstreamer/usr/share/* ${SDCARD}/usr/share/ -rfa
# Mail GPU library
sed 's/^#\(deb-src\)/\1/' -i ${SDCARD}/etc/apt/sources.list
chroot $SDCARD /bin/bash -c "apt-get -q update >/dev/null 2>&1"
chroot $SDCARD /bin/bash -c "apt-get -y build-dep xserver-xorg-core >/dev/null 2>&1"
chroot $SDCARD /bin/bash -c "apt-get remove -y --purge libegl1-mesa-dev:arm64 libgbm-dev:arm64 >/dev/null 2>&1"
chroot $SDCARD /bin/bash -c "apt-get install -q -y --no-install-recommends libxcb-xkb-dev libxfont-dev wayland-protocols >/dev/null 2>&1"
install_deb_chroot "$EXTER/cache/debs/rk3399/libmali-rk-dev_1.6-2_arm64.deb"
install_deb_chroot "$EXTER/cache/debs/rk3399/libmali-rk-midgard-t86x-r14p0_1.6-2_arm64.deb"
rm -rf ${SDCARD}/usr/lib/aarch64-linux-gnu/mesa-egl
XSERVER_DIR="$EXTER/cache/sources/rk3399_gst_xserver_libs/xserver"
cp ${XSERVER_DIR}/xserver_for_${RELEASE}/usr/bin/* ${SDCARD}/usr/bin/ -rfa
cp ${XSERVER_DIR}/xserver_for_${RELEASE}/usr/include/* ${SDCARD}/usr/include/ -rfa
cp ${XSERVER_DIR}/xserver_for_${RELEASE}/usr/lib/* ${SDCARD}/usr/lib/ -rfa
cp ${XSERVER_DIR}/xserver_for_${RELEASE}/usr/share/* ${SDCARD}/usr/share/ -rfa
cp ${XSERVER_DIR}/xserver_for_${RELEASE}/usr/libexec/* ${SDCARD}/usr/libexec/ -rfa
fi
if [[ $BOARD == orangepir1plus ]]; then
# execute specific tweaks function if present
[[ $(type -t family_tweaks_s) == function ]] && family_tweaks_s
# rename USB based network to lan0
mkdir -p $SDCARD/etc/udev/rules.d/
@ -257,13 +296,13 @@ family_tweaks()
#echo " iface eth0 inet dhcp" >> $SDCARD/etc/network/interfaces
#echo "auto lan0" >> $SDCARD/etc/network/interfaces
#echo " iface lan0 inet dhcp" >> $SDCARD/etc/network/interfaces
fi
elif [[ -f $SDCARD/lib/systemd/system/rk3399-bluetooth.service ]]; then
if [[ -f $SDCARD/lib/systemd/system/rk3399-bluetooth.service ]]; then
# install and enable Bluetooth
chroot $SDCARD /bin/bash -c "apt-get -y -qq install rfkill bluetooth bluez bluez-tools"
chroot $SDCARD /bin/bash -c "apt-get -y -qq install rfkill bluetooth bluez bluez-tools >/dev/null 2>&1"
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable rk3399-bluetooth.service >/dev/null 2>&1"
fi
}
@ -281,4 +320,18 @@ family_tweaks_bsp()
EndSection
EOF
fi
if [[ ${BOARD} == orangepi4 ]]; then
# Bluetooth for most of others (custom patchram is needed only in legacy)
install -m 755 $EXTER/packages/bsp/rk3399/brcm_patchram_plus_rk3399 $destination/usr/bin
cp $EXTER/packages/bsp/rk3399/rk3399-bluetooth.service $destination/lib/systemd/system/
fi
# Graphics and media
mkdir -p $destination/etc/udev/rules.d
cp $EXTER/packages/bsp/rk3399/50-mali.rules $destination/etc/udev/rules.d/
cp $EXTER/packages/bsp/rk3399/50-rk3399-vpu.rules $destination/etc/udev/rules.d/
mkdir -p $destination/etc/sysfs.d
cp $EXTER/packages/bsp/rk3399/20-gpu-governor.conf $destination/etc/sysfs.d/
}

39
external/config/sources/families/rk3399.conf vendored Normal file → Executable file
View File

@ -2,25 +2,39 @@ source "${BASH_SOURCE%/*}/include/rockchip64_common.inc"
BOOTPATCHDIR="u-boot-rockchip64-mainline"
BOOT_SOC="rk3399"
ASOUND_STATE="asound.state.rk3399"
BOOTBRANCH="branch:v2020.04-rockchip64"
LINUXCONFIG='linux-rk3399-'$BRANCH
LINUXFAMILY=rk3399
case $BRANCH in
legacy)
KERNELSOURCE='https://github.com/friendlyarm/kernel-rockchip'
KERNELBRANCH='branch:nanopi4-linux-v4.4.y'
KERNELDIR="${SRC}/kernel"
KERNELCONFIG='linux-rockchip64'
KERNELBRANCH='branch:orange-pi-4.4-rockchip64'
KERNEL_USE_GCC='> 7.0'
KERNEL_COMPILER='aarch64-linux-gnu-'
if [[ $RELEASE == xenial ]]; then
PACKAGE_LIST_FAMILY="bison flex libffi-dev libmount-dev libpcre3 libpcre3-dev zlib1g-dev libssl-dev gtk-doc-tools \
automake autoconf libtool gettext make autopoint g++ xz-utils net-tools libasound2-dev \
libx11-dev unzip libxext-dev libjpeg62-dev gdisk librtmp-dev libxv-dev libpulse-dev libgl1-mesa-dev libgles2-mesa \
v4l-utils libpng16-16 cmake make"
;;
PACKAGE_LIST_FAMILY_REMOVE="gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio \
gstreamer1.0-plugins-ugly-amr libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 libgstreamer1.0-0"
fi
;;
current)
KERNELBRANCH='branch:orange-pi-5.4-rockchip64'
;;
esac
if [[ $BOARD == roc-rk3399-pc ]]; then
BOOT_USE_MAINLINE_ATF=yes
elif [[ $BOARD == nanopim4v2 || $BOARD == orangepi4 ]]; then
if [[ $BOARD == orangepi4 ]]; then
BOOT_USE_BLOBS=yes
DDR_BLOB='rk33/rk3399_ddr_933MHz_v1.24.bin'
@ -36,6 +50,11 @@ else
fi
family_tweaks_s()
{
:
}
prepare_boot_configuration
atf_custom_postprocess()

View File

@ -2,18 +2,6 @@ source "${BASH_SOURCE%/*}/include/rockchip64_common.inc"
BOOTPATCHDIR="u-boot-rockchip64-mainline"
case $BRANCH in
legacy)
KERNELSOURCE='https://github.com/ayufan-rock64/linux-kernel'
KERNELBRANCH='tag:4.4.202-1237-rockchip-ayufan'
KERNELDIR='linux-rockchip64'
;;
esac
family_tweaks_bsp()
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
# Set "performance" GPU devfreq governor, "simple_ondemand" works bad in recent kernels
devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/governor = performance

View File

@ -0,0 +1,2 @@
KERNEL=="mali*", MODE="0660", GROUP="video"

View File

@ -0,0 +1,3 @@
KERNEL=="vpu_service", MODE="0660", GROUP="video"
KERNEL=="rkvdec", MODE="0660", GROUP="video"
KERNEL=="rga", MODE="0660", GROUP="video"

Binary file not shown.

View File

@ -0,0 +1,15 @@
[Unit]
Description=Bluetooth Rockpi
After=bluetooth.target
[Service]
Type=exec
ExecStartPre=/usr/sbin/rfkill unblock all
ExecStart=/usr/bin/brcm_patchram_plus_rk3399 -d --enable_hci --no2bytes --use_baudrate_for_download --tosleep 200000 --baudrate 1500000 --patchram /lib/firmware/brcm/BCM4345C5.hcd /dev/ttyS0
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target

View File

@ -153,7 +153,8 @@ if [[ -z $BOARD ]]; then
options+=("orangepilite2" "Allwinner H6 quad core 1GB RAM WiFi/BT USB3")
options+=("orangepioneplus" "Allwinner H6 quad core 1GB RAM GBE")
options+=("orangepizero2" "Allwinner H616 quad core 512MB/1GB RAM WiFi/BT GBE SPI")
options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI")
options+=("orangepi4" "Rockchip RK3399 hexa core 4GB RAM GBE eMMc USB3 USB-C WiFi/BT")
options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI")
menustr="Please choose a Board."
BOARD=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \
@ -238,11 +239,14 @@ if [[ ${BUILD_OPT} == image || ${BUILD_OPT} == rootfs ]]; then
if [[ $LINUXFAMILY == sun50iw9 || $LINUXFAMILY == sun50iw6 ]]; then
RELEASE_TARGET="buster bionic focal"
elif [[ $LINUXFAMILY == rk3399 ]]; then
RELEASE_TARGET="xenial"
else
RELEASE_TARGET="xenial"
fi
elif [[ $BRANCH == current || $BRANCH == dev ]]; then
elif [[ $BRANCH == current ]]; then
RELEASE_TARGET="buster bionic focal"
[[ $LINUXFAMILY == sun50iw6 ]] && RELEASE_TARGET="buster focal"
@ -380,6 +384,10 @@ display_alert "Downloading sources" "" "info"
fetch_from_repo "https://github.com/linux-sunxi/sunxi-tools" "${EXTER}/cache/sources/sunxi-tools" "branch:master"
fetch_from_repo "https://github.com/armbian/rkbin" "${EXTER}/cache/sources/rkbin-tools" "branch:master"
if [[ $BOARD == orangepi4 ]]; then
fetch_from_repo "https://github.com/orangepi-xunlong/rk3399_gst_xserver_libs.git" "${EXTER}/cache/sources/rk3399_gst_xserver_libs" "branch:main"
fi
fi
compile_sunxi_tools