This is a guide on how to run x86 on ARM including wine! I have put a lot of time and effort into creating this guide along with breaking down a few older tutorials to give you guys a up to date guide on running x86 on arm (i.e raspberry pi or tinkerboard). Hope you guys appreciate this and thanks for the view!!

Equipment List

Raspberry Pi 3 ► Amazon | Ebay

Software List

Raspbian Pixel ► https://www.raspberrypi.org/downloads/

Balena Etcher  ► https://www.balena.io/etcher/ 

POL Wine Binary  ► https://www.playonlinux.com/wine/binaries/linux-x86/

Reference List

these are the references i followed

https://github.com/mikerr/RPi-QEMU-x86-wine

https://sourceforge.net/projects/pi-qemu-wine/

https://www.raspberrypi.org/forums/viewtopic.php?t=204547

https://github.com/AlbrechtL/RPi-QEMU-x86-wine

https://forum.winehq.org/viewtopic.php?f=8&t=17701&start=25#p84325

x86 on ARM (i.e. Raspberry Pi)

Step 1: Install Raspbian Pixel

First you will need to download Raspbian Pixel Desktop version.

download pixel

Now we will need a piece of software called etcher to write the image onto our SD card and USB Storage device.

etcher

Step 2: Check for updates

It is always a good idea to check for updates even if it is a freshly installed OS.

$ sudo apt-get update
$ sudo apt-get upgrade

Step 2a: Compiling Kernel (needed for wine to work)

This next step is required for Wine to work under chroot and arm environment. Since Wine comes pre-compiled with support only for 3G/1G vmsplit we will need to compile our kernel to be compatible, this is only the case if your kernel is not compiled with 3G/1G. Raspberry pi come pre-compiled with 2G/2G vmsplit

Follow this guide from official raspberry pi to compile your raspberry pi kernel. (if you are not using raspberry pi, you will need to find the steps to compiling and installing there kernel)

https://www.raspberrypi.org/documentation/linux/kernel/building.md

you will need to modify the .config after the

make bcm2709_defconfig

by commenting out the

# VMSPLIT_2G=y

and remove the comment block from

# VMSPLIT_3G=y

there might be some cases (ie tinkerboard) where you will need to enable binfmt_misc so check for that as well in the .config

Step 3: Downloading Prerequisites

Open up a terminal and type

$ sudo apt-get update && apt-get install qemu qemu-user qemu-user-static binfmt-support debootstrap binutils

this should only take a few mins, once done extract the source codes with this command

Step 4: Debootstrap

We are now going to download Debian x86 environment using debootstrap and separating into two stages with this command

$ sudo debootstrap --foreign --arch i386 stretch ./chroot-stretch-i386 http://ftp.us.debian.org/debian

this should only take about 5 or so mins. then on to mounting. if you didn’t deviate from the current directory of /home/pi/ then next command is as follows

$ sudo mount -t sysfs sys ./chroot-stretch-i386/sys/
$ sudo mount -t proc proc ./chroot-stretch-i386/proc/
$ sudo mount --bind /dev ./chroot-stretch-i386/dev/
$ sudo mount --bind /dev/pts ./chroot-stretch-i386/dev/pts/
$ sudo mount --bind /dev/shm ./chroot-stretch-i386/dev/shm/

This is how the magic works…. we need to copy qemu-i386-static over to the bin folder

$ sudo cp /usr/bin/qemu-i386-static ./chroot-stretch-i386/usr/bin/

we should now be ready for stage 2 of debootstrap. this will take awhile (59min~ on pi3b+)

$ sudo chroot ./chroot-stretch-i386/ /debootstrap/debootstrap --second-stage

one that is completed we should have a freshly installed x86 debian working.

Step 5: Configuring Chroot

with our freshly created debian x86 chroot system. we will now need to test it and configure a user account

$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l root

we might need to setup some variables (needed for p) and would be wise to insert this to the bottom of the .bashrc file so we don’t need to type it in every time we launch our chroot root user

export LANGUAGE=”C”
export LC_ALL=”C”
export DISPLAY=:0

if you added the lines to the .bashrc file you will need to refresh it by using source

$ source ~/.bashrc

lets go ahead update the x86 debian

$ apt update

now we can create a user, in my video i have used the same user as the system user which requires us to know the uid of that user by typing in “id” in the terminal (not x86 terminal), and in our case the “pi” uid is “1000”

$ adduser -uid 1000 pi

follow the prompts and continue

before we exit root i would like to install a x86 gui application, this way it will install the requirements to run gui. so i went with something like “leafpad”

$ apt install leafpad

notice how large the installation compaired to a standard leafpad install.

with that done. we can now test our newly created user account (pi). You can either start up a new lxterminal or exit the current root terminal and use this command.

$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l pi

we will need to do the same as the root user and add some varibles to the .bashrc file

export LANGUAGE=”C”
export LC_ALL=”C”
export DISPLAY=:0l
$ source ~/.bashrc

if everything went well we should have no problems running “leafpad”

$ leafpad

Step 6: Setting up WINE

If you are not planning to use wine you can skip this step completely and move on to the next.

We will first need to download a precompiled binary version of wine from Play on linux. head over to there site and look for the latest version of wine, in my case the making of this video/tutorial the latest version i have found is 3.9.

using the root account of x86

$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l root

we can now download the wine binaries

wget https://www.playonlinux.com/wine/binaries/linux-x86/PlayOnLinux-wine-3.9-linux-x86.pol

in my case i forgot i needed bzip2 so we need to go ahead and install that as well

apt install bzip2

lets extract our wine binaries and move them over to the “/opt”

tar -jxf PlayOnLinux-wine-3.9-linux-x86.pol --strip-components=1

we need to now rename a file for wine to run correctly

mv ./3.9/bin/wine-preloader ./3.9/bin/wine-preloader.renamed

now we can move the wine folder to “/opt” and rename the folder to wine-3.9

mv ./3.9 /opt/wine-3.9/

lets export some paths so we can reach wine.

echo PATH=/opt/wine-3.9/bin/:$PATH >> ~/.bashrc

lets refresh our .bashrc file again

source ./.bashrc

since root is not able to use the exported display (“export DISPLAY=:0”) we will need to login to the user account to test wine

$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l pi

we now need to export the path in the pi user account as well

echo PATH=/opt/wine-3.9/bin/:$PATH >> ~/.bashrc

lets refresh our .bashrc file again

source ./.bashrc

with that all completed we can now test wine.

winecfg

at this rate you should be able to see winecfg pop up

i have an modified version of winetricks working for our x86 debian environment

http://github.com/novaspirit/winetricks

Step 7: Finalizing configs

now that we have everything tested and working lets clean stuff up and create startup services so we don’t have to keep mounting our partitions everytime we need to use chroot x86

I started by creating a fold called “/opt/chrootscript”

$ sudo mkdir /opt/chrootscript/

now in there i’m going to make our first script “chrootmount”

$ sudo nano /opt/chrootscript/chrootmount

and input the following

#!/bin/bash
mount -t sysfs sys /tmp/mnt/sys/
mount -t proc proc /tmp/mnt/proc/
mount –bind /dev /tmp/mnt/dev/
mount –bind /dev/pts /tmp/mnt/dev/pts/
mount –bind /dev/shm /tmp/mnt/dev/shm/

now we can create a service for that script so it will boot up everytime

sudo nano /etc/systemd/system/chrootmount.service

in there we need to add some properties

[Unit]
Description = mounts chroot on boot

[Service]
Type=one-shot
ExecStart=/usr/bin/chrootmount

[Install]
WantedBy=multi-user.target

we can now enable the service with this command

$ sudo systemctl enable chrootmount.service

with that in place we can make 2 scripts to start our x86 environment, one for user and one for root

$ sudo nano /opt/chrootscript/start_x86_user

input the following

#!/bin/sh
/usr/sbin/chroot /home/pi/chroot-stretch-i386/ /bin/su -l pi

and

$ sudo nano /opt/chrootscript/start_x86_root

input the following

#!/bin/sh
/usr/sbin/chroot /home/pi/chroot-stretch-i386/ /bin/su -l root

now we can generate some desktop shortcuts by right clicking on the desktop and selecting New > empty file and name it “chroot_user.desktop”

input the following

[Desktop Entry]
Type=Application
Comment=Start Wine x86 Environment
Name=Wine x86 User
Exec=lxterminal -e sudo /opt/chrootscript/start_x86_user
Icon=
Terminal=false
Categories=Utility
StartupNotify=True

and do the same for root. right click desktop and select New > empty file and name it “chroot_root.desktop”

input the following

[Desktop Entry]
Type=Application
Comment=Start Wine x86 Environment
Name=Wine x86 Root
Exec=lxterminal -e sudo /opt/chrootscript/start_x86_root
Icon=
Terminal=false
Categories=Utility
StartupNotify=True

whew!!!!! that was a lot! but now you should be all set to go in your x86 ventures.

TIP: