Skip to content

Instantly share code, notes, and snippets.

@nhobson99
Last active September 28, 2024 11:49
Show Gist options
  • Save nhobson99/98d1542e542d3aa25faa3c817d3f2a67 to your computer and use it in GitHub Desktop.
Save nhobson99/98d1542e542d3aa25faa3c817d3f2a67 to your computer and use it in GitHub Desktop.
Installing box86/box64 and wine on Snapdragon Chromebooks

This will be a step by step guide on exactly how I installed box86 on my Acer Spin 513 equipped with a Snapdragon 7C. This guide should work for several other Snapdragon Chromebooks, though YMMV. Mediatek devices will follow a similar setup, but you will compile the Rockchip (RK3399 or similar) version instead of SD845. Now on with the show:

Step 1 - Setting up Crostini

I've tried this on Crouton, but unfortunately it just doesn't seem to work on my ARM based Chromebook. If you have Crouton installed on an Intel Chromebook, it should work, but I'm not sure about AMD based Chromebooks, as their graphics drivers are different.

It's tempting to immediately create a new Crostini container, but that's actually not what we need here just yet. You see, box86 relies on something called binfmt-support in order to work. Inside Crostini, this means creating a "privileged" lxc container. You may want to have a separate container just for running x86 applications in; for this guide, I'll be using one called "x86" for simplicity.

Go ahead and enable the chrome flag for allowing multiple Crostini containers if you don't already have the option. It can be found at chrome://flags and searching Crostini. It may still be experimental on your device. Next, open up a crosh shell, as we don't actually want to start up a VM container just yet. This is where we create our privileged container. The steps are:

  1. ctrl+alt+t or go to chrome-untrusted://crosh, and type shell
  2. enter vmc container termina x86 --privileged true

A new container will be created titled "x86", and once created, you'll probably see an error and be spat back out to the shell. Type the same command again (vmc container termina x86 --privileged true) and you should be logged in to a shell running bash in your x86 container. The shell prompt at this point should be <your username>@x86. It will be the same username as your Chrome OS login. By default, there is no sudo password. If you want to set one, do so now.

Step 2 - Installing prerequisites

At this point, it should be safe to use Terminal instead of manually entering your virtual machine from crosh.

You'll need a few packages on top of the default linux container offered by Chrome OS. Those are:

  • gcc-arm-linux-gnueabihf
  • libc6:armhf
  • binfmt-support
  • cmake
  • git

One little idiosynchrosy you may have noticed is that you'll need access to armhf libraries for libc6. You'll also need access to some i386 and amd64 libraries, so it's best to enable those repositories now.

sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture i386
sudo dpkg --add-architecture amd64
sudo apt update
sudo apt upgrade -y

The apt upgrade is not necessary, but can be done now to ensure you're running the latest software on your VM. Now, as mentioned before, you need to install the prerequisites:

sudo apt install gcc-arm-linux-gnueabihf libc6:armhf binfmt-support cmake git

This should be all the prerequisites you'll need for now, though if you need any additional libraries or applications later in the guide, I'll make that clear.

Step 3 - Building and installing box86 and box64

This part of the guide is actually the most straightforward, because at this point you've done all you needed to do to set up a multiarch environment for running x86 and x86-64 applications. Now we just follow the guide for compiling box86, utilizing the cmake build preset (known as "targets") for Snapdragon 845 SoC's. For box64, unfortunately the compilation seems to fail with no warning for me when having dynarec enabled, so I'll leave it disabled for now.

box86:

git clone https://github.com/ptitSeb/box86
cd box86
mkdir build; cd build; cmake .. -DSD845=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j8
sudo make install

box64:

git clone https://github.com/ptitSeb/box64
cd box64
mkdir build; cd build; cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j8
sudo make install

There also seems to be a long-standing bug right now with binfmt-support on Debian. I have a working version of both the box86.conf and box64.conf files to put in /usr/share/binfmts/.

/usr/share/binfmts/box86.conf:

package box86
interpreter /usr/local/bin/box86
magic \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00
mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff

/usr/share/binfmts/box64.conf:

package box64
interpreter /usr/local/bin/box64
magic \x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00
mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff

After copying the contents of these files into their respective directories, you can run the following commands to import them and verify that they are functioning correctly:

sudo update-binfmts --import box86.conf
sudo update-binfmts --import box64.conf
sudo update-binfmts --enable
sudo update-binfmts --display

You should see something along the lines of:

box64.conf (enabled):
     package = box64
        type = magic
      offset = 0
       magic = \x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00
        mask = \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
 interpreter = /usr/local/bin/box64
    detector = 
box86.conf (enabled):
     package = box86
        type = magic
      offset = 0
       magic = \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00
        mask = \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
 interpreter = /usr/local/bin/box86
    detector = 
    ...

Finally, we can test both box86 and box64 by installing some basic packages:

$ sudo apt install hello:i386
$ hello
(box86 debug info, if enabled)
Hello, World!
$ sudo apt remove hello:i386
$ sudo apt install hello:amd64
$ hello
(box64 debug info, again, if enabled)
Hello, World!
@DarkevilPT
Copy link

DarkevilPT commented Nov 10, 2023

I got steam working by then after that:

sudo wget https://ryanfortner.github.io/box86-debs/box86.list -O /etc/apt/sources.list.d/box86.list && sudo wget https://ryanfortner.github.io/box64-debs/box64.list -O /etc/apt/sources.list.d/box64.list && wget -qO- https://ryanfortner.github.io/box86-debs/KEY.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/box86-debs-archive-keyring.gpg && wget -qO- https://ryanfortner.github.io/box64-debs/KEY.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/box64-debs-archive-keyring.gpg && sudo aptitude install libd3dadapter9-mesa -y && sudo aptitude update && sudo aptitude upgrade -y

sudo apt install box86:armhf -y
sudo apt install box64-generic-arm -y

Installing ~/box86/install_steam.sh Works now.

https://community.fydeos.io/t/topic/25188/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment