RK3566流畅运行X64 win应用?
Well, Windows x64 binaries now mostly seem to be working well on Wine (x64, Dynarec for ARM64) on Incus/LXC containers on Armbian aarch64 on an ARM SBC like RasPi or its counterparts with Rockchip RK3xxx series processors.
Btw, let’s celebrate the 1st LTS release of Incus, version 6.0.
在Linux平台使用wine运行win32程序?
Wine项目距今30多年历史了,完全不稀奇。
如果是跑在Linux arm64/aarch64上呢?
也还好……纯软件转译x86指令集,应该跑的像幻灯片吧?之前你不是KVM装过一次Win7 x64,玩成了行为艺术咩?
如果是一张价钱不足100块的RK3566 sbc,先跑Armbian,其上跑incus(lxc)容器,再跑Wine x64,最后运行Win64程序,然后我说除了启动慢点儿(毕竟emmc就那点io),运行还蛮流畅,您怎么想?
只是四核1.8 GHz Cortex-A55?那换成手机8 gen3还不得上天?
如果手里有一块树莓派4b,这组套娃的安装过程都是大佬给做好的,复制一个安装脚本运行一下,其余就是点两下等着自动化脚本装包了。
假设您是跟我一样,对host OS的干净程度比较在意,希望大部分试验包都是虚拟化/容器化运行,也好办。接下来简单聊下incus/lxc容器化的安装过程,估计感兴趣的有限,就不写保姆级了,主要步骤列一下。
首先,由于整个系统要允许运行x86_64格式的二进制文件,而容器的隔离程度又不及虚拟机,所以这次host OS不能完全看热闹,要装两个包。
【注】要关注box64这个包有针对多种不同的arm处理器代次的编译结果,如果是pi 4b就选rpi4。此处我选rpi3主要是因为pi 3b的A53架构,跟我的RK3566 A55架构相对接近。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# root @ panther-x2-01 in ~ [20:13:56] $ cat << EOF > /etc/apt/sources.list.d/box64.sources Types: deb URIs: https://Pi-Apps-Coders.github.io/box64-debs/debian Suites: ./ Signed-By: /usr/share/keyrings/box64-archive-keyring.gpg EOF # root @ panther-x2-01 in ~ [20:14:04] $ wget -qO- https://Pi-Apps-Coders.github.io/box64-debs/KEY.gpg | sudo gpg --dearmor -o /usr/share/keyrings/box64-archive-keyring.gpg # root @ panther-x2-01 in ~ [20:14:10] $ apt update && apt install libmspack0 box64-rpi3arm64 Hit:1 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm InRelease Get:2 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates InRelease [55.4 kB] Get:3 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports InRelease [56.5 kB] Get:4 https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security InRelease [48.0 kB] Hit:5 https://mirrors.tuna.tsinghua.edu.cn/armbian bookworm InRelease Get:6 https://Pi-Apps-Coders.github.io/box64-debs/debian ./ InRelease [2,155 B] Get:7 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports/main arm64 Packages.diff/Index [63.3 kB] Get:8 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports/main all Contents (deb).diff/Index [63.6 kB] Get:9 https://pkgs.zabbly.com/incus/stable bookworm InRelease [7,369 B] Get:10 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports/main arm64 Packages T-2024-04-04-2004.55-F-2024-04-04-2004.55.pdiff [2,268 B] Get:10 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports/main arm64 Packages T-2024-04-04-2004.55-F-2024-04-04-2004.55.pdiff [2,268 B] Get:11 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports/main all Contents (deb) T-2024-04-04-2004.55-F-2024-04-04-2004.55.pdiff [40 B] Get:11 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports/main all Contents (deb) T-2024-04-04-2004.55-F-2024-04-04-2004.55.pdiff [40 B] Get:12 https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security/main arm64 Packages [147 kB] Get:13 https://Pi-Apps-Coders.github.io/box64-debs/debian ./ Packages [3,239 B] Get:14 https://pkgs.zabbly.com/incus/stable bookworm/main arm64 Packages [3,089 B] Fetched 452 kB in 9s (50.4 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 2 packages can be upgraded. Run 'apt list --upgradable' to see them. Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: box64-rpi3arm64 libmspack0 0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded. Need to get 9,819 kB of archives. After this operation, 70.3 MB of additional disk space will be used. Get:1 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main arm64 libmspack0 arm64 0.11-1 [48.2 kB] Get:2 https://Pi-Apps-Coders.github.io/box64-debs/debian ./ box64-rpi3arm64 0.2.7+20240405T063140.a4142f6-1 [9,771 kB] Fetched 9,819 kB in 6s (1,645 kB/s) Selecting previously unselected package libmspack0:arm64. (Reading database ... 176315 files and directories currently installed.) Preparing to unpack .../libmspack0_0.11-1_arm64.deb ... Unpacking libmspack0:arm64 (0.11-1) ... Selecting previously unselected package box64-rpi3arm64. Preparing to unpack .../box64-rpi3arm64_0.2.7+20240405T063140.a4142f6-1_arm64.deb ... Unpacking box64-rpi3arm64 (0.2.7+20240405T063140.a4142f6-1) ... Setting up libmspack0:arm64 (0.11-1) ... Setting up box64-rpi3arm64 (0.2.7+20240405T063140.a4142f6-1) ... Restarting systemd-binfmt... Processing triggers for libc-bin (2.36-9+deb12u4) ... # root @ panther-x2-01 in ~ [20:15:39] $ apt search box64 Sorting... Done Full Text Search... Done box64-android/unknown 0.2.7+20240405T062405.a4142f6-1 arm64 Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64bit little-endian) box64-generic-arm/unknown 0.2.7+20240405T062016.a4142f6-1 arm64 Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64bit little-endian) box64-rk3399/unknown 0.2.7+20240405T063920.a4142f6-1 arm64 Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64bit little-endian) box64-rpi3arm64/unknown,now 0.2.7+20240405T063140.a4142f6-1 arm64 [installed] Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64bit little-endian) box64-rpi4arm64/unknown 0.2.7+20240405T062753.a4142f6-1 arm64 Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64bit little-endian) box64-tegrax1/unknown 0.2.7+20240405T063532.a4142f6-1 arm64 Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64bit little-endian) |
然后就是easy mode了,如果机器没有incus/lxd可以自己装一下,我之前有篇文章写过从lxd到incus的迁移过程,也可视为安装过程。
至于如何在3分钟内初始化incus服务,下载并解开一个标准debian 12镜像呢,超出本文范围,请自行看文档解决哈。
由于大佬封装的pi apps服务依赖图形化界面安装,因此incus容器是需要一个桌面的,再说win app不用桌面的实话说也不多。而远程访问容器桌面,多少需要个remote desktop service,这个就随意了,相比vnc我更喜欢xrdp,所以加起来需要以下几个包。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 登入新建的debian 12 bookworm容器 incus exec deb12-wine-x64 -- bash # 安装需要的包,zsh非必须,只是我习惯用而已 apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils xrdp zsh wget curl # 增加一个普通用户,pi-apps安装需要普通用户 useradd -m wine -s "/usr/bin/zsh" # 给该用户增加sudo权限,最好nopasswd visudo # 设置自己的时区,因为容器一般默认是UTC timedatectl set-timezone Asia/Shanghai # 切换到新用户,就能装pi-apps了 su - wine wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash |
容器内系统如果不用incus/lxd管理的网桥,直接bridge到外部网卡,也就是有内网独立ip,那么什么都不用做rdp client可以直接访问。
但如果容器按incus/lxd标配使用nat网络(我也习惯这么用),那么如下可以搞定端口映射。该映射方式用于临时使用,如果希望长期使用(重启后自动保持),请参考incus的 incus network forward 命令行操作文档。
1 2 3 4 5 6 7 8 9 10 |
# root @ panther-x2-01 in ~ [20:40:31] $ incus list -c nsum4N +----------------+---------+-----------+--------------+-----------------------+-----------+ | NAME | STATE | CPU USAGE | MEMORY USAGE | IPV4 | PROCESSES | +----------------+---------+-----------+--------------+-----------------------+-----------+ | deb12-wine-x64 | RUNNING | 8s | 93.79MiB | 10.108.101.115 (eth0) | 8 | +----------------+---------+-----------+--------------+-----------------------+-----------+ # root @ panther-x2-01 in ~ [20:40:34] $ iptables -t nat -A PREROUTING -m tcp -p tcp --dport 3389 -j DNAT --to-destination 10.108.101.115:3389 |
前边命令行已经装好Pi Apps,用rdp client(win可以直接使用远程桌面客户端,mac装MS remote desktop应用)访问容器里的xrdp服务,用wine账户登录就能打开桌面,使用Pi Apps继续安装wine x64。
然后……就不需要然后了,如果运行wine命令能得到 Dynarec for ARM64 字样,就可以使用wine来安装需要的win64程序并使用了。
1 2 3 4 5 6 7 8 9 |
╭─wine@deb12-wine-x64 ~ ╰─$ wine Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 PageSize:4096 Running on Cortex-A55 with 4 Cores Will use Hardware counter measured at 24.0 MHz emulating 768 MHz Params database has 61 entries Box64 with Dynarec v0.2.7 4a889e39 built on Apr 4 2024 06:16:49 BOX64: Wine64 detected, WINEPRELOADRESERVE="" BOX64: Detected 48bits at least of address space ... |
要说感想的话,前两天“九边”公众号提到,说现代AI技术和战争武器自动化,都直接或间接得益于游戏宅真金白银对CPU/GPU硬件性能的推动。
虽然不玩游戏好多年,但Linux aarch64流畅模拟Win x64,这个软硬结合的大型系统工程,我觉得也有游戏玩家的不懈推动在里面,不信的话,SteamOS、DXVK等一众技术了解一下?
更新 2024.04.30,Pi 5B运行war 3:
文章的脚注信息由WordPress的wp-posturl插件自动生成