├── README.md ├── armbian-fixups └── orangepi5-usb2fixup.sh ├── gpu-envs.md ├── mesa-armhf.md └── rk3588-enhance ├── README.md ├── balance-governor.sh ├── deploy.sh └── performance-governor.sh /README.md: -------------------------------------------------------------------------------- 1 | # RK3588(S) 游戏教程 2 | 3 | 一步步教你在RK3588(Debian-based OS)上运行各种游戏 4 | 5 | 注意: 本文只是个用作参考的操作手册,不保证在某些刁钻的场景下适用 6 | 7 | # 快速开始 8 | - 注: 标注为可选的, 可以暂时忽略 9 | - 0、 安装、启动malior 10 | ```bash 11 | wget -O - https://github.com/ChisBread/malior/raw/main/install.sh > /tmp/malior-install.sh && bash /tmp/malior-install.sh && rm /tmp/malior-install.sh 12 | malior 'echo hello arm!' 13 | ``` 14 | - 1、 (可选)按照[性能优化](./rk3588-enhance/README.md)无痛解锁大约30%的性能 15 | - 2、 桌面环境 16 | - 部分官方镜像自带的桌面系统(比如香橙派5)不支持panfrost驱动 17 | - 注意, 有两个选择 18 | ```bash 19 | # 选择a: 替换官方桌面; 方便安装兼容性更好的panfrost驱动,但可能导致部分应用失效 20 | sudo apt-mark unhold xserver-common xserver-xorg-core xserver-xorg-dev xserver-xorg-legacy 21 | sudo apt update && sudo apt dist-upgrade 22 | # 选择b: 安装blob(闭源)驱动, malior命令前加上MALI_BLOB=x11; 只支持到OpenGL 2.1, 并且只支持x11应用, 不支持wayland 23 | malior install libmali-g610-blob && malior install gl4es 24 | MALI_BLOB=x11 malior glmark2 # 测试x11+OpenGL 25 | ``` 26 | - 3、 (可选)如果确认桌面环境OK, 则按照[环境安装](./gpu-envs.md)教程,安装开源GPU驱动 27 | - 4、 (可选)安装wine 32位版本(会自动安装box86、box64); war3, 星际争霸 都需要wine 28 | ```bash 29 | malior install wine # 会有弹窗, 如果乱码了就凭感觉点一个 30 | # 下载wine很慢? 使用环境变量WINE_BUILDS_MIRROR,替换wine镜像源 31 | ## WINE_BUILDS_MIRROR=mirrors.tuna.tsinghua.edu.cn malior install wine 32 | malior winetricks -q fakechinese wenquanyi # 安装wine中文环境 33 | echo $LANG 34 | # 如果显示不是zh_CN.UTF-8, 运行wine时要加上LC_ALL来保证wine为中文环境 35 | malior LC_ALL=zh_CN.UTF-8 winecfg 36 | # 如果期望未来都是中文显示, 把`export LC_ALL=zh_CN.UTF-8`加到`~/.config/malior/envs.sh` 37 | ``` 38 | - 5、 (可选)安装steam-wip, box86下的steam暂时还不稳定, 一些独立小游戏可以跑 39 | ```bash 40 | malior install steam-wip 41 | ``` 42 | # 可能出现异常 43 | 1. 固件没有正确安装 44 | ```bash 45 | # 下载并覆盖固件 46 | sudo wget https://github.com/JeffyCN/rockchip_mirrors/raw/libmali/firmware/g610/mali_csffw.bin -O /lib/firmware/mali_csffw.bin 47 | ``` 48 | 2. 使用了官方闭源桌面+开源驱动, 或者使用闭源驱动执行了wayland应用 49 | # 例子 50 | - 魔兽争霸:冰封王座 51 | - 下载免安装中文版war3, 自行搜索; 可以的话请支持正版(但我们需要免安装版…) 52 | - 确保malior和wine已经安装 53 | - 解压war3到 `~/.local/malior/war3-1.24e` 确保目录下有 `War3.exe` 54 | - 运行 `malior LC_ALL=zh_CN.UTF-8 wine "~/.local/malior/war3-1.24e/War3.exe -opengl -windows"` 55 | - 如果是闭源驱动, 运行 `MALI_BLOB=x11-32 malior LC_ALL=zh_CN.UTF-8 wine "~/.local/malior/war3-1.24e/War3.exe -opengl -windows"` 56 | -------------------------------------------------------------------------------- /armbian-fixups/orangepi5-usb2fixup.sh: -------------------------------------------------------------------------------- 1 | sudo bash -c 'cat > /etc/systemd/system/orangepi5_usb2_init.service < /sys/kernel/debug/usb/fc000000.usb/mode" 8 | Type=oneshot 9 | 10 | [Install] 11 | WantedBy=default.target 12 | EOF' 13 | sudo systemctl daemon-reload 14 | sudo systemctl enable orangepi5_usb2_init 15 | sudo systemctl start orangepi5_usb2_init 16 | echo "ACTION==\"remove\", SUBSYSTEM==\"typec\", RUN+=\"/usr/bin/bash -c 'echo host > /sys/kernel/debug/usb/fc000000.usb/mode'\"" > /tmp/83-typec.rules 17 | sudo bash -c 'mv /tmp/83-typec.rules /etc/udev/rules.d/' 18 | sudo udevadm control --reload-rules -------------------------------------------------------------------------------- /gpu-envs.md: -------------------------------------------------------------------------------- 1 | ## GPU驱动 2 | 3 | 因为RK3588(S)的Linux补丁还没进主线,所以RK3588(S)内核版本暂停在了RockChip提供的5.10版本上 4 | 而5.10版本的内核,还没有合并Valhall(Mali-G57, Mali-G610 ...)支持 5 | 6 | RK3588的厂商出场驱动可能会带上libmali, 支持OpenGL(ESv2) API,但可惜的是让它正确工作需要付出额外的成本 7 | 想让所有应用在默认情况下工作,我们需要mesa/panfrost支持 8 | 9 | ### Panfork简介 10 | 11 | 按我的理解, panfork是mesa/panfrost的User Space移植;驱动原理和libmali一样,但开源(意味着可以在自制系统上使用)、性能和兼容性更好. 12 | 而且作为mesa的移植, 如果作者积极维护, 我们就能及时用上Linux主线的GPU驱动更新, 比如PanVK(Mali GPU的Vulkan驱动) 13 | 14 | 总之, 在默认情况下, panfork运转良好 15 | 16 | - refs 17 | ```txt 18 | panfork https://gitlab.com/panfork/mesa 19 | ``` 20 | ### Panfork 安装步骤(PPA版) 21 | 22 | Ubuntu 22.04(Jammy)用户, 可以从ppa安装 23 | 24 | ```bash 25 | # step1. 下载GPU固件到/lib/firmware 26 | sudo wget https://github.com/JeffyCN/rockchip_mirrors/raw/libmali/firmware/g610/mali_csffw.bin -O /lib/firmware/mali_csffw.bin 27 | # step2. 添加ppa 28 | sudo add-apt-repository ppa:liujianfeng1994/panfork-mesa 29 | # step3. 使用中科大ppa反代(可选) 30 | sudo sed -i -e "s@http.*://ppa.launchpadcontent.net@https://launchpad.proxy.ustclug.org@g" /etc/apt/sources.list.d/* 31 | sudo apt update 32 | # step4. 原地升级 33 | sudo apt dist-upgrade 34 | # step5. 安装32位环境(可选) 35 | sudo apt install -y libegl-mesa0:armhf libgbm1:armhf libgl1-mesa-dri:armhf libglapi-mesa:armhf libglx-mesa0:armhf 36 | ``` 37 | ### Panfork 安装步骤(git版编译安装) 38 | 39 | 这一段照搬 [panfork](https://gitlab.com/panfork/mesa) ,并假设你的架构是aarch64 40 | 41 | 如果需要32位版本GPU驱动(比如通过box86运行Steam Linux) 42 | 43 | 在安装完成64位版以后, 参考[Panfork 32位版 编译安装](./mesa-armhf.md) 44 | 45 | 46 | ```bash 47 | # step0. 内核编译参数(也许不是必选) 48 | #编译内核时关闭 CONFIG_DRM_IGNORE_IOTCL_PERMIT 49 | # step1. 下载GPU固件到/lib/firmware 50 | sudo wget https://github.com/JeffyCN/rockchip_mirrors/raw/libmali/firmware/g610/mali_csffw.bin -O /lib/firmware/mali_csffw.bin 51 | # step2. 安装环境依赖 52 | sudo apt install build-essential cmake meson git python3-mako libexpat1-dev bison flex libwayland-egl-backend-dev libxext-dev libxfixes-dev libxcb-glx0-dev libxcb-shm0-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-present-dev libxshmfence-dev libxxf86vm-dev libxrandr-dev libwayland-dev libx11-xcb-dev 53 | # step3. 编译安装libdrm (覆盖原有的旧版) 54 | git clone https://gitlab.freedesktop.org/mesa/drm 55 | mkdir drm/build 56 | cd drm/build 57 | meson 58 | sudo ninja install 59 | # step4. 编译安装wayland-protocols 60 | git clone https://gitlab.freedesktop.org/wayland/wayland-protocols 61 | mkdir wayland-protocols/build 62 | cd wayland-protocols/build 63 | git checkout 1.24 64 | meson 65 | sudo ninja install 66 | # step5. 编译安装panfork (安装到/opt/panfrost) 67 | git clone https://gitlab.com/panfork/mesa 68 | mkdir mesa/build 69 | cd mesa/build 70 | meson -Dgallium-drivers=panfrost -Dvulkan-drivers= -Dllvm=disabled --prefix=/opt/panfrost 71 | sudo ninja install 72 | ``` 73 | 74 | ### git版编译安装版使用(PPA版不需要) 75 | - 全局默认 76 | ```bash 77 | echo /opt/panfrost/lib/aarch64-linux-gnu | sudo tee /etc/ld.so.conf.d/0-panfrost.conf 78 | # 如果存在 /etc/ld.so.conf.d/00-aarch64-mali.conf 79 | # 要保证0-panfrost.conf优先级最高 80 | # sudo mv /etc/ld.so.conf.d/00-aarch64-mali.conf /etc/ld.so.conf.d/1-aarch64-mali.conf 81 | sudo ldconfig 82 | ``` 83 | - 临时使用(不推荐) 84 | ```bash 85 | LD_LIBRARY_PATH=/opt/panfrost/lib/aarch64-linux-gnu glmark2 86 | ``` 87 | 88 | ### 验证gpu负载 89 | ``` 90 | watch --no-title "cat /sys/devices/platform/fb000000.gpu/devfreq/fb000000.gpu/load | cut -d '@' -f 1 | awk '{ print \"GPU load: \"\$1\"%\"}'" 91 | ``` 92 | 93 | ## 第二章: Box86与Box64 94 | - 建议ppa安装,box86在aarch64下的编译较为麻烦 95 | -------------------------------------------------------------------------------- /mesa-armhf.md: -------------------------------------------------------------------------------- 1 | # Panfork 32位版 交叉编译&安装 2 | - step1. 安装环境依赖 3 | ```bash 4 | sudo dpkg --add-architecture armhf 5 | sudo apt update 6 | # 这里顺便安装了部分常见依赖, 可以按需去除 7 | sudo apt install libc6:armhf libncurses5:armhf libsdl2\*:armhf libopenal\*:armhf libpng\*:armhf libfontconfig\*:armhf libXcomposite\*:armhf libbz2-dev:armhf libXtst\*:armhf 8 | # 这些是工具链和编译环境, 如果提示缺少依赖, google一下就能找到对应的包 9 | sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf 10 | sudo apt install libexpat1-dev:armhf libwayland-egl-backend-dev:armhf libxext-dev:armhf libxfixes-dev:armhf libxcb-glx0-dev:armhf libxcb-shm0-dev:armhf libxcb-dri2-0-dev:armhf libxcb-dri3-dev:armhf libxcb-present-dev:armhf libxshmfence-dev:armhf libxxf86vm-dev:armhf libxrandr-dev:armhf libx11-xcb-dev:armhf 11 | ``` 12 | - step2. 编译安装libdrm 13 | ``` bash 14 | cd drm/build 15 | sudo rm -rf * 16 | CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ meson 17 | sudo ninja install 18 | ``` 19 | - step3. 创建文件 mesa/cross_armhf.txt 并复制以下设置 20 | ```conf 21 | [binaries] 22 | # we could set exe_wrapper = qemu-arm-static but to test the case 23 | # when cross compiled binaries can't be run we don't do that 24 | c = '/usr/bin/arm-linux-gnueabihf-gcc' 25 | cpp = '/usr/bin/arm-linux-gnueabihf-g++' 26 | ar = '/usr/arm-linux-gnueabihf/bin/ar' 27 | strip = '/usr/arm-linux-gnueabihf/bin/strip' 28 | pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config' 29 | ld = '/usr/bin/arm-linux-gnueabihf-ld' 30 | 31 | [properties] 32 | root = '/usr/arm-linux-gnueabihf' 33 | 34 | has_function_printf = true 35 | has_function_hfkerhisadf = false 36 | 37 | skip_sanity_check = true 38 | 39 | [host_machine] 40 | system = 'linux' 41 | cpu_family = 'arm' 42 | cpu = 'armv7' # Not sure if correct. 43 | endian = 'little' 44 | ``` 45 | - step4. 编译安装panfork (安装到/opt/panfrost/arm-linux-gnueabihf) 46 | ```bash 47 | cd mesa/build 48 | PKG_CONFIG_PATH=/usr/local/lib/arm-linux-gnueabihf/pkgconfig CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ meson -Dgallium-drivers=panfrost -Dvulkan-drivers=panfrost -Dllvm=disabled --prefix=/opt/panfrost/arm-linux-gnueabihf --cross-file cross_armhf.txt 49 | ``` 50 | - step5. 开启全局默认 51 | ```bash 52 | sudo bash -c "echo '/opt/panfrost/arm-linux-gnueabihf/lib' >> /etc/ld.so.conf.d/0-panfrost.conf" 53 | sudo ldconfig 54 | ``` -------------------------------------------------------------------------------- /rk3588-enhance/README.md: -------------------------------------------------------------------------------- 1 | # rk3588性能优化 2 | ## 使用 3 | - rk3588(s) 通用优化 4 | ```bash 5 | # step1. 部署系统优化服务 6 | wget -O - https://github.com/ChisBread/rk3588-gaming-step-by-step/raw/main/rk3588-enhance/deploy.sh | sudo bash 7 | # step2. 默认平衡模式 8 | echo 'RK3588_GOVERNOR_DEFAULT=balance' > /etc/sysctl.d/rk3588-governor 9 | ## or 默认性能模式 10 | # echo 'RK3588_GOVERNOR_DEFAULT=performance' > /etc/sysctl.d/rk3588-governor 11 | # step3. 即时生效(重启则自动生效) 12 | systemctl start rk3588-governor 13 | ``` 14 | - 临时切换 15 | ```bash 16 | balance-governor.sh 17 | # performance-governor.sh 18 | ``` 19 | - 香橙派5 CPU、GPU满血dtb, 以及带GPU性能优化补丁的kernel 20 | - 见[release](https://github.com/ChisBread/linux-orangepi/releases) 21 | - linux-dtb-* 加压超频dtb: ⚠️注意!⚠️加压有风险,请确保供电和散热足够 22 | - linux-image-* 内核 -------------------------------------------------------------------------------- /rk3588-enhance/balance-governor.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sudo /bin/bash 2 | echo simple_ondemand > /sys/class/devfreq/fb000000.gpu/governor 3 | echo ondemand > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor 4 | echo ondemand > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor 5 | echo ondemand > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor 6 | echo dmc_ondemand > /sys/class/devfreq/dmc/governor 7 | echo 20 > /sys/devices/platform/dmc/devfreq/dmc/upthreshold 8 | prefix="/sys/devices/system/cpu" 9 | find "${prefix}" -name cpuinfo_cur_freq -exec chmod +r {} \; 10 | grep -q ondemand /etc/default/cpufrequtils 11 | if [ $? -eq 0 ]; then 12 | CPUFreqPolicies=($(ls -d ${prefix}/cpufreq/policy? | sed 's/freq\/policy//')) 13 | if [ ${#CPUFreqPolicies[@]} -eq 1 -a -d "${prefix}/cpufreq" ]; then 14 | # if there's just a single cpufreq policy ondemand sysfs entries differ 15 | CPUFreqPolicies=${prefix} 16 | fi 17 | for i in ${CPUFreqPolicies[@]}; do 18 | affected_cpu=$(tr -d -c '[:digit:]' <<< ${i}) 19 | echo ondemand >${prefix}/cpu${affected_cpu:-0}/cpufreq/scaling_governor 20 | echo 1 >${i}/cpufreq/ondemand/io_is_busy 21 | echo 25 >${i}/cpufreq/ondemand/up_threshold 22 | echo 10 >${i}/cpufreq/ondemand/sampling_down_factor 23 | echo 200000 >${i}/cpufreq/ondemand/sampling_rate 24 | done 25 | fi -------------------------------------------------------------------------------- /rk3588-enhance/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sudo /bin/bash 2 | wget https://github.com/ChisBread/rk3588-gaming-step-by-step/raw/main/rk3588-enhance/balance-governor.sh -O /usr/local/bin/balance-governor.sh 3 | chmod +x /usr/local/bin/balance-governor.sh 4 | wget https://github.com/ChisBread/rk3588-gaming-step-by-step/raw/main/rk3588-enhance/performance-governor.sh -O /usr/local/bin/performance-governor.sh 5 | chmod +x /usr/local/bin/performance-governor.sh 6 | cat > /etc/sysctl.d/rk3588-governor < /etc/systemd/system/rk3588-governor.service < /sys/class/devfreq/fb000000.gpu/governor 3 | echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor 4 | echo performance > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor 5 | echo performance > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor 6 | echo performance > /sys/class/devfreq/dmc/governor --------------------------------------------------------------------------------