Tutorial [Tutorial] Run x86 apps on l4t switch with box86

  • Thread starter Deleted User
  • Start date
  • Views 9,990
  • Replies 10
  • Likes 6
D

Deleted User

Guest
OP
There are two methods for running x86 apps on the switch:

1) This tutorial uses box86 for running x86 apps in general in L4T ubuntu: This is useful for old opengl apps in general especially if they are from the early 2000s.

2) The second method uses Exagear windows emulator in switchroot Android 10. This method supports very limited range of directx games. It is however quite useful for visual novels. Go to the discord for https://www.reddit.com/r/AndroidVisualNovels. Use the "alternate method" for Exagear emulator in #faq-and-guide. I tested umineko chiru (2017- steam version) with ps3 sprites. There is lag (which should not matter much for a vn) but sound and voices works perfectly.

Green Joy-Con D-Pad Shells for Nintendo Switch


Box86 tutorial:

Hello everyone, if you have been in the official switchroot discord you would have noticed that @Heasterian have managed to run opengl x86 apps on l4t. This tutorial will cover what he did in the most noob-friendly way possible.


Tested games after UPDATE:
GTA Vice City: Average 15 fps, unstable, stutters when driving and fps drops when loading the map
Star Wars Battlefront II: stable 10 fps on the spawn screen, Xephyr has an issue with mouse input so could not get into the game
Worms 4 mayhem: stable 25 fps
Warcraft 3 demo: stable 27 fps

Green Joy-Con D-Pad Shells for Nintendo Switch
Green Joy-Con D-Pad Shells for Nintendo Switch



Outcome
If you follow this guide step-by-step you should be at the very least capable of running x86 apps on l4t. FPS will vary depending on what app and configurations you use (See above for tested games). For this tutorial, we will run Warcraft III demo on the switch.

Setting up schroot and box86
Source rna on armbian: https://forum.armbian.com/topic/16584-install-box86-on-arm64/

1) Open a terminal on l4t and enter the following commands one by one:
Code:
sudo apt install schroot debootstrap

sudo mkdir /srv/chroot

sudo mkdir /srv/chroot/debian-armhf

sudo debootstrap --arch armhf --foreign buster /srv/chroot/debian-armhf http://debian.xtdv.net/debian

sudo chroot "/srv/chroot/debian-armhf" /debootstrap/debootstrap --second-stage

2) Create a config file for the chroot by entering the following command:
Code:
sudo nano /etc/schroot/chroot.d/debian-armhf.conf

3) Copy and paste the following and replace <username> with your ubuntu username: (to save in nano press CTRL+X, Then Y, then Enter)
Code:
[debian-armhf]
description=Debian Armhf chroot
aliases=debian-armhf
type=directory
directory=/srv/chroot/debian-armhf
profile=desktop
personality=linux
preserve-environment=true
root-users=<username>
users=<username>

4) Edit the nssdatabases like so:
Code:
sudo nano /etc/schroot/desktop/nssdatabases

5) Overwrite what is already there with the following: (Use CTRL+SHIFT+6 with the cursor in the beginning of the file then use the arrow keys to move to the end of the file, then press CTRL+K to delete the selection)
Code:
# System databases to copy into the chroot from the host system.
#
# <database name>
#passwd
shadow
#group
gshadow
services
protocols
#networks
#hosts
#user

6) Edit the stateoverride like so:
Code:
sudo nano /srv/chroot/debian-armhf/var/lib/dpkg/statoverride

7) Overwrite what is already there with the following:
Code:
root root 2755 /usr/bin/crontab

8) Now you can schroot with:
Code:
sudo schroot -c debian-armhf

9) Edit the bashrc like this:
Code:
nano ~/.bashrc

10) Add the following: (if the file is not empty, add the following at the end of the file)
Code:
export LANGUAGE="C"
export LC_ALL="C"
export DISPLAY=:1
export LIBGL_ALWAYS_SOFTWARE=1
export GALLIUM_DRIVER=virpipe

11) Edit sources.list in chroot like so:
Code:
nano /etc/apt/sources.list

12) Overwrite what is there with:
Code:
deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free

deb http://security.debian.org/debian-security buster/updates main contrib
deb-src http://security.debian.org/debian-security buster/updates main contrib

13) Run update and upgrade like so: (enter y when prompted after apt upgrade)
Code:
apt update

apt upgrade

14) Install some required packages like so: (enter y when prompted)
Code:
apt install git wget cmake build-essential python3

apt install gcc-arm-linux-gnueabihf

apt install python3-setuptools

apt install sudo

15) Clone and compile box86 like this:
Code:
git clone https://github.com/ptitSeb/box86

cd box86

mkdir build; cd build; cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo; make

16) Install wine like this:
Code:
wget https://twisteros.com/wine.tgz

tar zxvf wine.tgz

17) Install Zenity like this:
Code:
apt install zenity

18) Exit schroot with:
Code:
exit

Build mesa on schroot

1) Enter schroot with:
Code:
sudo schroot -c debian-armhf

2) Install build dependencies like this:
Code:
sudo apt-get build-dep mesa

3) Clone mesa and build: (run these commands one by one):
Code:
git clone https://gitlab.freedesktop.org/mesa/mesa.git -b 20.1

cd mesa

meson build

cd build

ninja && sudo ninja install

4) Exit schroot:
Code:
exit


Build virglrenderer on host

1) Open a new terminal window and run the following commands:
Code:
sudo apt update

sudo apt upgrade

sudo apt install python3-pip

sudo pip3 install meson

Code:
sudo apt install libegl1-mesa-dev

sudo apt install libgbm-dev

sudo apt install ninja-build

sudo apt install git-all

git clone https://github.com/anholt/libepoxy

cd libepoxy

mkdir _build && cd _build

meson

ninja

sudo ninja install

Code:
git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git

cd virglrenderer

git checkout c7c102ba

meson build

cd build

ninja && sudo ninja install

2) Mount host tmp to chroot like this:
Code:
sudo mount --bind /tmp /srv/chroot/debian-armhf/tmp

3) Close the terminal window

Run a game

1) Open a terminal window and enter schroot with:
Code:
sudo schroot -c debian-armhf

2) Open a new terminal window and enter the following commands:
Code:
cd virglrenderer/build/vtest

./virgl_test_server --use-glx

3) Open a new terminal and enter the following command:
Code:
sudo DISPLAY=:0 Xephyr :1

4) Download W3demo.exe from https://archive.org/details/WarcraftIiiReignOfChaosDemo

5) On the schroot terminal run: (replace path to exe with where you downloaded W3demo.exe)
Code:
sudo ~/box86/build/box86 ~/wine/bin/wine 'path to exe'


UPDATE : virgl server was not using the gpu but was doing software rendering. To fix this delete the lines in nano ~/.bashrc, restart the switch then type the following lines on a terminal then run schroot in that terminal.
Code:
export LANGUAGE="C"
export LC_ALL="C"
export DISPLAY=:1
export LIBGL_ALWAYS_SOFTWARE=1
export GALLIUM_DRIVER=virpipe
Note: I do not know if this is safe so proceed at your own risk. Afterwards, overclock your switch and use
Code:
sudo jetson_clocks
0MUnWLb
 
Last edited by ,

nex86

Active Member
Newcomer
Joined
May 19, 2017
Messages
42
Trophies
0
Age
35
XP
94
Country
Gambia, The
ok I'm at the point to start a game, but wine is bitching..
err: winediag:nodrvr_CreateWindow Make sure that your X server is running and that $Display is set correctly.

fixed my issue.
I forgot to start the virgl test server.

I got an old demo to run, but with an abysmal framerate of 1fps.
I don't think its using the GPU, even though I followed the steps in the update part.
 
Last edited by nex86,
D

Deleted User

Guest
OP
ok I'm at the point to start a game, but wine is bitching..
err: winediag:nodrvr_CreateWindow Make sure that your X server is running and that $Display is set correctly.

fixed my issue.
I forgot to start the virgl test server.

I got an old demo to run, but with an abysmal framerate of 1fps.
I don't think its using the GPU, even though I followed the steps in the update part.

What demo are you using? And yes, it does not seem to be using the GPU.

1) First use binfmt to automatically run box86 like this (in chroot):
Code:
cd box86/build
sudo make install box86

2) Copy box86.conf in /srv/chroot/debian-armhf/etc/binfmt.d to /etc/binfmt.d
To do that I used:
Code:
sudo nautilus

3) Then in host use :
Code:
sudo systemctl restart systemd-binfmt

4) Exit chroot and then enter again with:
Code:
exit
sudo schroot -c debian-armhf

5) In chroot use:
Code:
sudo apt install mesa-utils

6) Then in chroot post the output of of the following commands:
Code:
sudo GALLIUM_DRIVER=virpipe glxinfo -B


The output you should get should be similar to this:
Code:
name of display: :1
display: :1  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Red Hat (0x1af4)
    Device: virgl (0x1010)
    Version: 20.1.10
    Accelerated: yes
    Video memory: 0MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.1
OpenGL vendor string: Red Hat
OpenGL renderer string: virgl
OpenGL core profile version string: 4.3 (Core Profile) Mesa 20.1.10 (git-bdf94921c0)
OpenGL core profile shading language version string: 4.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 20.1.10 (git-bdf94921c0)
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.1.10 (git-bdf94921c0)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10

Notice that its using the gpu:
Code:
Device: virgl (0x1010)

7) So if you get this output then run wine with GALLIUM_DRIVER=virpipe. The command can get quite messy so first copy the wine executable to the bin folder like this (in chroot):
Code:
cd /wine/bin

sudo ln -s wine /usr/local/bin/wine
sudo ln -s wineserver /usr/local/bin/winserver
sudo ln -s winecfg /usr/local/bin/winecfg
sudo ln -s winefile /usr/local/bin/winefile

8) Now typing wine in chroot should automatically run box86 and wine and you should get an output like this:
Code:
Box86 with Dynarec v0.2.1 9cc69095 built on Feb 16 2021 14:56:19
Usage: wine PROGRAM [ARGUMENTS...]   Run the specified program
       wine --help                   Display this help and exit
       wine --version                Output version information and exit


9) Now run wine with explorer mode and GALLIUM_DRIVER=virpipe then navigate to the exe file like this:
Code:
sudo GALLIUM_DRIVER=virpipe winefile /desktop=shell,800x600
 
Last edited by ,

nex86

Active Member
Newcomer
Joined
May 19, 2017
Messages
42
Trophies
0
Age
35
XP
94
Country
Gambia, The
is it normal that /srv in chroot is empty?
I see chroot/debian-armhf only in host.

Also did that:


cd /wine/bin

sudo ln -s wine /usr/local/bin/wine
sudo ln -s wineserver /usr/local/bin/winserver
sudo ln -s winecfg /usr/local/bin/winecfg
sudo ln -s winefile /usr/local/bin/winefile

but its not /wine/bin, its ~/wine/bin
but still, its saying command not found when I just type wine
I checked and the symbolic link exists.
 
Last edited by nex86,
D

Deleted User

Guest
OP
is it normal that /srv in chroot is empty?
I see chroot/debian-armhf only in host.

Also did that:


cd /wine/bin

sudo ln -s wine /usr/local/bin/wine
sudo ln -s wineserver /usr/local/bin/winserver
sudo ln -s winecfg /usr/local/bin/winecfg
sudo ln -s winefile /usr/local/bin/winefile
but its not /wine/bin, its ~/wine/bin
but still, its saying command not found when I just type wine
I checked and the symbolic link exists.

Solved gpu usage on discord, for others just use GALLIUM_DRIVER=virpipe on wine commands. Symbolic link did not work because of a wrong directory.
 
Last edited by ,

magelof

Well-Known Member
Newcomer
Joined
Jul 29, 2006
Messages
53
Trophies
0
XP
392
Country
United States
Hi, thank you very much for this tutorial. I'm trying to install the Sims (no-install, rip version as seen here)

I need to edit the registry file in order for it to find the game files. The registry file currently reads:
[HKEY_LOCAL_MACHINE\Software\Maxis]

[HKEY_LOCAL_MACHINE\Software\Maxis\The Sims]
"SIMS_SKU"=dword:00000001
"SIMS_LANGUAGE"="USEnglish"
"SIMS_MUSIC"=".\\Music\\"
"SIMS_SOUND"=".\\SoundData"
"SIMS_DATA"=".\\"
"InstallPath"=".\\"
"Version"="1.0"
"Language"=dword:00000409
"BetaSite"=dword:00000001
"Installed"="1"

[HKEY_LOCAL_MACHINE\Software\Maxis\The Sims\1.00.001]

How can I change the HKEY paths above to point to my game files in Ubuntu? What is the windows path in box86/wine? Where should I put my game files? Thank you in advance for your insight here.
 

BrandonSWITCH

Member
Newcomer
Joined
Nov 13, 2021
Messages
8
Trophies
0
XP
27
Country
United Kingdom
Thanks for the tutorial, I am gonna test this later on after I have moved my Atmpsphere EmuMMC, Android 10, L4T Ubuntu, and Lakka across to my new 512GB SD Card. Hopefully then I will have enough space after resizing my EXT4 partition for ubuntu. :)
 
General chit-chat
Help Users
  • Julie_Pilgrim @ Julie_Pilgrim:
    youre acting like a ds being stolen is some sort of tragic event that no one should ever joke about
    Gift
  • Sicklyboy @ Sicklyboy:
    Any way to get the stuff available over mystery gift in brilliant diamond / shining pearl on a modded switch?
    +1
    Gift
  • Sicklyboy @ Sicklyboy:
    since, like... connecting to the internet with it isn't the best idea
    +1
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    play a better game ;o;
    Gift
  • Gift
  • TheZander @ TheZander:
    were you even joking about the ds? also a stolen ds is a huge tragedy. I'm beginning
    to wonder where your priorities lie
    +2
    Gift
  • Gift
  • Ophelia_Later @ Ophelia_Later:
    TheZander
    @ TheZander: were you even joking about the ds? also a stolen ds is a huge tragedy. I'm beginningto wonder where your priorities lie
    Gift
  • Ophelia_Later @ Ophelia_Later:
    not a joke it was stolen and yes streetpass was turned on but i don't have a mac id or any clue of who did it. is there any hope of getting it back ive invested over $1,000 in it
    Gift
  • Gift
  • Sonic Angel Knight @ Sonic Angel Knight:
    This mac n cheese is bad
    +1
    Gift
  • Sicklyboy @ Sicklyboy:
    how tf do you invest over a grand in a DS?

    Signed, someone who has invested over $700 in a mechanical keyboard
    +1
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    ive broken 4 digits
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    (ok, not me technically, since i myself didnt spend the money,my parents did, but still)
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    also on a related note, i should start treating my keyboard better, my friend saw my keyboard while visiting my house and he said "holy shit why is it this dirty do you like shove it up your ass right after you clean it or something"
    Gift
  • KennieDaMeanie @ KennieDaMeanie:
    Lol you'd imagine anyone that can put 1k towards a ds would have fuck it money and just buy it again
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    (and for those of you wondering, no i dont shove it up my ass i just eat while gaming)
    Gift
  • KennieDaMeanie @ KennieDaMeanie:
    I swear some of these new users are duplicate accounts just to troll the shitbox lol
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    i mean, let's not pretend we contribute great stuff here normally
    Gift
  • KennieDaMeanie @ KennieDaMeanie:
    So you admit to having duplicate accounts? Sickly you know the offense for that :0
    +1
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    although it does have it's moments, where else would i have to specify i dont shove keyboards up my ass
    Gift
  • KennieDaMeanie @ KennieDaMeanie:
    Fun fact I didn't really realize the big pack in little Debbie's meant big snacks I thought they were double layred so I got home and was amazed and felt sick after finishing a big Christmas tree
    +1
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    oh shit it's almost christmas, i need to make a christmas pfp like last year
    Gift
  • KennieDaMeanie @ KennieDaMeanie:
    Why yes it usually happens every December unless you're Jewish
    Gift
  • Julie_Pilgrim @ Julie_Pilgrim:
    im muslim, what does that mean for me
    Gift
    Julie_Pilgrim @ Julie_Pilgrim: im muslim, what does that mean for me