1. KakowiHitoDesu

    OP KakowiHitoDesu Newbie Newcomer

    Joined:
    Dec 12, 2020
    Messages:
    6
    Country:
    Switzerland
    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: http://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 http://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 http://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:
    apt-get build-dep mesa
    3) Clone mesa and build: (run these commands one by one):
    Code:
    git clone http://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
    
    git clone http://github.com/anholt/libepoxy
    
    cd libepoxy
    
    mkdir _build && cd _build
    
    meson
    
    ninja
    
    sudo ninja install
    
    Code:
    git clone http://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 http://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, Feb 16, 2021 at 8:06 PM
  2. nex86

    nex86 Member Newcomer

    Joined:
    May 19, 2017
    Messages:
    39
    Country:
    Gambia, The
    thanks for the tutorial!
    I will set this up, hopefully tomorrow.
     
    Xander_VH likes this.
Draft saved Draft deleted
Loading...

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

Share this thread:

Facebook Twitter Reddit Tumblr Telegram WhatsApp
Site Map