Sunday, January 17, 2021

Performance topic: Running x86 games on Raspberry PI OS 32 bits (Box86/Wine/PiKISS)

If you have tried TwisterOS and had it run your games and wish to get something lighter, this topic is for you.

There is one good thing with TwisterOS: it has it all:

  • RetroPie as an app
  • x86 Wine
  • Box86
  • PiKISS
  • Lutris (which I personally do not like)
  • Steam
  • Overclocking, governor changing and I/O scheduler changing
  • Chromium browser
The only tricky part of TwisterOS is to run a Wine game with the right WINEPREFIX.

The drawback of the completeness is that you will eventually lose performance and will probably have to lower your claims in matter of which game you will be able to run and which game not. Also, Pi 3 users will probably experiment random freezes using TwisterOS. The guys from TwisterOS notify us that there is no real 3/3B+ support since their test machines are Pi 4's.

For Pi 3 owners (and maybe older Pi 2's) having a light setting is important to get some games playable and enjoyable.

You have two routes there:

- Debloat TwisterOS

- Start from a leaner OS (Raspberry Pi OS 32 bits or even Raspberry Pi OS 32 bits Lite + raspberry-ui-mods) and install the needed binaries (here Box86 and Wine-x86).

This post will study the second route: start from a lean OS.

Starting from the leanest: Raspberry Pi OS 32 bits Lite (optional)

  • Install Raspberry Pi OS 32 bits lite from PINN
  • In console mode run
sudo apt-get install raspberry-ui-mods 
sudo raspi-config

    --> Select in boot options graphical interface autologin
  • Reboot
  • This is it, you have a debloated Raspberry Pi OS 32 bits with LXDE-RPD 
Raspberry Pi OS 32 bits Lite stock themed
A stock themed Raspberry PI OS 32 bits Lite
with raspberrypi-ui-mods,
Dark_Olympic theme and Plane icon theme


 

Installing Box86 on Raspberry Pi OS 32 bits, what to know:

  • First of all, Box86 is a static emulator and will recognize your x86 binaries, and will automatically starts itself when you try to invoke a x86 executable.

  • Also, static emulators are managed by systemd-binfmt, the main feature of systemd-binfmt is that there can be only one active static emulator per foreign system. Thinking QEMU? Yes, QEMU and Box86 will conflict each other on one system. Make sure you do not install QEMU static on your system because QEMU will automatically reactivate itself and prevent Box86 from working. Not taking this into account can be an important loss of time.
  • Begin the operations by installing the dependencies, mainly cmake and git:
sudo apt-get install git cmake
  • When installing Box86 in a lean system, you will not have an update_box86.sh script. Since it is a WIP project, it is foreseen that you will have to update it from time to time. It is important to make an update script, because you might forget some compilation setting and wonder during hours why your Box86 is not working anymore. An example of update script would be:
    • #/bin/bash

      cd ~/
      rm -rf box86
      git clone https://github.com/ptitSeb/box86
      cd box86
      mkdir build
      cd build
      cmake .. -DRPI3=1
      make -j1
      sudo make install
      sudo systemctl restart systemd-binfmt

      Save this script for example in /home/pi/

      This script is a little different than the one present on ptitSeb's git for 3 reasons:

  • System here is Pi 3. Can be changed to Pi 4 easily
  • I don't use "make -j4". Using "make -j4" uses the full power of the Raspberry Pi (all the cores) but also fills the /var/swap to the death. you might experience crashes with "make -j4" while plain "make", or explicit "make -j1" will be slower but safer.
  • RelWithDebInfo is not needed, its default.
Update script then can be used as well for installing or updating. You might see an error message "This directory does not exist" when first running it, but it will not trigger afterwards (rm -rf box86 tries to remove a non-existing directory)

You will then be able to run linux x86 binaries. Most important is Wine. Since you do not have a full x86 system, you should install a portable version of Wine in for example /home/pi/winex86/

Getting Wine to run: windows programs

A well underway game of Heroes of Might and Magic 4
on a Raspberry Pi 3B+


 
If you are a Raspberry Pi 3 user, you will need a 3G/1G compiled kernel. If you have a 3B+, you can download my vercingetorix, untar it on some extfs, and
 
cd kernel
./kernel_install.sh

 
If you got another device which needs recompiling, or wish to recompile, instructions are here. Kernel compiling takes 1 to 2 days.
 
I got my Wine from PlayOnLinux, go to this link. I personally got 3.20.Novaspirit's guide uses 3.9. Depending when you are reading this, newer versions can be availlable. You might want to try making older versions work, but 3.x does the job for most applications.

Download it (by clicking or using wget), unzip it (format is bzip2; if needed see below) and place the directory in /home/pi/winex86/

sudo apt-get install bzip2

Another way would be to unpack both debian package binaries gotten from WineHQ (one for wineserver, one for wine client):

wget https://dl.winehq.org/wine-builds/debian/dists/buster/main/binary-i386/wine-stable_5.0.2~buster_i386.deb
wget https://dl.winehq.org/wine-builds/debian/dists/buster/main/binary-i386/wine-stable-i386_5.0.2~buster_i386.deb

unpack with

dpkg-deb --extract wine-stable_5.0.2~buster_i386.deb
dpkg-deb --extract wine-stable-i386_5.0.2~buster_i386.deb

The extracted binaries will be usable with Box86 and you can move them from the extracted path to the desired folder. Keep the subdirectories when doing so or you will be missing dependencies while running Wine. 

Keep in mind: 

  • The newer the Wine version, the heavier the wineprefix will be! Sometimes it is wiser to stick on a Wine v1.5 or on a PlayOnlLnux Wine version, rather than making 4 wineprefixes with Wine 5.0.2 and bloat your device.  
  • Debian stretch (chroot) stops at 5.0.2. If you want to use chroot as tool, do not download newer than 5.0.2. 

Once Box86 and Wine are installed, make your wineprefix

WINEPREFIX=/home/pi/wineprefixes/wine-1/ /home/pi/winex86/bin/wine winecfg
  • Say "no" to "mono" and especially  "gecko" because these will in a first time be useless and eat your disk space (something like 500 MB).
  • Start your game: 
WINEPREFIX=/home/pi/wineprefixes/wine-1/ /home/pi/winex86/bin/wine /path/to/your-game.exe

Making a x86 wineprefix is KEY to avoid most worries playing x86 game, it can give you a week banging your head in the wall trying to run x86 games with an ARM wineprefix.... so beware!

GL4ES (optional)

GL4ES is a native OpenGL driver for Raspberry Pi. This should help you have things running that would not run otherwise, and have a better OpenGL support, meaning better performance, especially for runnables that use OpenGL natively. Considering that Wine converts a lot of calls to OpenGL, it will certainly be a good idea to install it and use it.
  • Check GL4ES instructions to get gl4es working. It must be done at least one time, the updates on this interpreter are less frequent than on Box86.
  • Once cloned and compiled, it doesnt "make install". Instead you will have to write shell scripts like this following:
    • LD_LIBRARY_PATH=/home/pi/gl4es/lib/ /path/to/your/executable
  • GL4ES can be used on native runnables, example: VCMI.

PiKISS

PiKISS will be a very good way to install your games on your fresh installed Raspberry PI OS 32 bits but you have to be careful on RPI3: if you do a full upgrade, PiKISS will upgrade your kernel and revert it to 2G/2G. if you don't have some 3G/1G tar archive with installer, you will have to recompile it again.
 
Note: Do not install GL4ES via PiKISS. It installs the Legacy version and you will mostly need to use the KMS version.
 

Winetricks

Winetricks does not cope well with a gaming OS. You will often meet Wine version conflicts using Winetricks on your ARM system. I personally do my Winetricks in a chroot.
 
See this post if you want Winetricks to work with your x86 wineprefixes.

Heroes of Might and Magic 4 Raspberry Pi game
A /home/pi/ directory with all the hot stuff installed:
Box86, GL4ES (here in subdirectory sc), PiKISS, mesa,
Wine, netsurf ultra light browser and winetricks.


More soft performance gain?

Want more from your Raspberry Pi? You can follow the next performance article here.

TL/DR:

  • Install Raspberry Pi OS 32 bits (or Lite + sudo apt-get install raspberry-ui-mods)
  • Pi 3B+: Install vercingetorix
  • Make sure you do not have QEMU installed
  • sudo apt-get install git cmake make
  • Install GL4ES, instructions here.(optional)
  • Install box86, instructions here; make sure you use make -j1 and not make -j4
  • Download and unzip to /home/pi/winex86/ bzip2 PlayOnlLnux wine binaries from this website.
  • WINEPREFIX=/home/pi/wineprefixes/wine-1/ /home/pi/winex86/bin/wine winecfg
  • Install PiKISS and get some games running with it. Make sure not to full-upgrade a Raspberry Pi 3 from PiKISS 
  • If you installed GL4ES, start your programs with prefix LD_LIBRARY_PATH=/home/pi/gl4es/lib/ (...command...)
  • All set!
The pi gamer

Disclaimer: Make sure you own the rights to play games before setting them on your raspberry pi.

No comments:

Post a Comment

Making XWindow, Wine and Box86 work under RetroArch [Raspberry Pi OS 32 bits lite + RetroArch as an app]

Very similar to my other article (" Making Wine and Box86 work under RetroPie [RetroPie as an OS] "), it will nevertheless show mu...