1. KakowiHitoDesu

    OP KakowiHitoDesu Member
    Newcomer

    Joined:
    Dec 12, 2020
    Messages:
    10
    Country:
    Switzerland
    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. Please post any problems here and not in the discord so that others with similar issues can benefit.



    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
    [​IMG]
     
    Last edited by KakowiHitoDesu, Mar 2, 2021 at 10:02 AM
  2. nex86

    nex86 Member
    Newcomer

    Joined:
    May 19, 2017
    Messages:
    42
    Country:
    Gambia, The
    thanks for the tutorial!
    I will set this up, hopefully tomorrow.
     
    Xander_VH likes this.
  3. nex86

    nex86 Member
    Newcomer

    Joined:
    May 19, 2017
    Messages:
    42
    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, Feb 19, 2021
  4. KakowiHitoDesu

    OP KakowiHitoDesu Member
    Newcomer

    Joined:
    Dec 12, 2020
    Messages:
    10
    Country:
    Switzerland
    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 KakowiHitoDesu, Feb 20, 2021
  5. nex86

    nex86 Member
    Newcomer

    Joined:
    May 19, 2017
    Messages:
    42
    Country:
    Gambia, The
    is it normal that /srv in chroot is empty?
    I see chroot/debian-armhf only in host.

    Also did that:


    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, Feb 20, 2021
  6. KakowiHitoDesu

    OP KakowiHitoDesu Member
    Newcomer

    Joined:
    Dec 12, 2020
    Messages:
    10
    Country:
    Switzerland
    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 KakowiHitoDesu, Feb 20, 2021
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - [Tutorial], switch, box86