Anbox on jetson nano

hi all,

Has anybody got Anbox successfully working on the jetson nano ?
https://anbox.io/

https://anbox.io/https://github.com/HarleyPato/anbox-arm64/

It requires a couple of kernel modules ( anbox-modules-dkms) as given here:

https://github.com/HarleyPato/anbox-arm64/blob/master/docs/install.md

But on installing the build fails because L4T has the kernel 4.9, but the modules required kernel above 4.15.

Some log here…

It is likely that 4.9.140-tegra belongs to a chroot's host Building for 4.15.0-124-generic and 4.9.140-tegra Building initial module for 4.15.0-124-generic Done.

Building initial module for 4.9.140-tegra
ERROR (dkms apport): kernel package linux-headers-4.9.140-tegra is not supported
Error! Bad return status for module build on kernel: 4.9.140-tegra (aarch64)
Consult /var/lib/dkms/anbox/1/build/make.log for more information.

Thanks

We never tried this, not sure if can work or not, may other developers share experiences if they done something similar.

Will jetson eventually get a kernel update. Is it in the pipeline ?

Yes, we plan to upgrade kernel to new version at 2021/2H.

So I figured out:

While its not possible to use dkms, we can still build the modules in-tree with a kernel build.

Just edit the file:
Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig file
and add these lines at the end

#Anbox Configuration
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ANDROID_BINDER_IPC_SELFTEST=y
CONFIG_ASHMEM=y

And do a kernel build with nvbuild.sh and install the modules and new kernel. And you now have the /dev/binder and /dev/ashmem

So now I am able to run Anbox on jetson nano. Its a pretty long process for 18.04. I will be quite simple once Nvidia updates to 20.04.

If anyone wants to do this, let me know. I will post the process here…

Step 1: We need /dev/binder and /dev/ashmem devices for android support.

Because the kernel is 4.9.140, its not possible dkms, or build them as loadable modules. But we can still build the modules in-tree with a kernel build.

Edit the file:
Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig file
and add these lines at the end

#Anbox Configuration
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ANDROID_BINDER_IPC_SELFTEST=y
CONFIG_ASHMEM=y

And do a kernel build with nvbuild.sh and install the modules and new kernel. Now we have the /dev/binder and /dev/ashmem.

Step 2: Set the permissions for the special files

cd /etc/udev/rules.d

Add a new file called 99-anbox.rules with content as:
KERNEL==“ashmem”, NAME="%k", MODE=“0666”
KERNEL==“binder”, NAME="%k", MODE=“0666”

then
sudo udevadm control --reload-rules && udevadm trigger

Step 3: Install an upgraded libSDL2 library

Due to a bug in the libSDL2 library available in 18.04, we need an upgraded version to be built from sources.

Download the libSDL2 sources of 19.04 from here:

https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libsdl2/2.0.9+dfsg1-1ubuntu1.19.04.1/libsdl2_2.0.9+dfsg1-1ubuntu1.19.04.1.debian.tar.xz

Extract and build:
sudo apt-get build-dep libsdl2-2.0-0
./configure
make
sudo make install

Step 4: Build anbox arm64 from sources

Get the anbox arm64 sources from here:

https://github.com/HarleyPato/anbox-arm64

(Have no idea how upto-date it is, but this is the only source I know of. It seems a work in progress and some crashes occur now and then)

Follow the instruction to install all the pre-requisites, and the build steps, except one small change is required before you do the step “cmake …

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

which will allow cmake to find the upgraded libSDL2 library.

continue with make and then sudo make install.

Step 5: Make it a proper installation

The Step 4 build and install of anbox is not a complete installation unfortunately. We need android image and services and launcher to be setup.

Download a sample android image from here:

http://anbox.postmarketos.org/android-7.1.2_r39-anbox_arm64-userdebug.img

Copy to /var/lib/anbox and rename it as android.img

Since we have to make it a proper installation, we refer to 20.04 arm64 deb of anbox. Its found here:
http://ports.ubuntu.com/pool/multiverse/a/anbox/anbox_0.0~git20191115-1build1_arm64.deb

Extract the deb file and make a copy of the files in data folder in our filesystem with a few changes.
i) copy the anbox executable from /usr/local/bin to /usr/bin
ii) Add this line:
Environment=“DISPLAY=:0”
before ExecStart in /usr/lib/systemd/user/anbox-session-manager.service file
iii) Remove the lines
ExecStartPre=/sbin/modprobe ashmem_linux
ExecStartPre=/sbin/modprobe binder_linux

In file lib/systemd/system/anbox-container-manager.service because there are built into the kernel.

Step 6: Start the anbox services

sudo systemctl unmask anbox-container-manager.service
sudo systemctl start anbox-container-manager.service
sudo systemctl enable anbox-container-manager.service

systemctl --user unmask anbox-session-manager.service
systemctl --user start anbox-session-manager.service
systemctl --user enable anbox-session-manager.service

// Check status of the services
sudo systemctl status anbox-container-manager.service
systemctl --user status anbox-session-manager.service

reboot

Check the anbox launcher in the search and launch it!

You can install more apps by using adb. Just check on the net.
Or you can use F-Droid repos

wget https://f-droid.org/FDroid.apk
adb install FDroid.apk

I can try this,but my kernel is 4.9.201. maybe this tutorial for me is outdated ? why didn’t you use the kernel 201 ? it is upgraded and correctly configured for running kvm. Maybe with it is also possible to do dkms and build them as loadable modules.

I used the kernel 4.9.201, the latest. But it does not matter. Anything below 4.17 will not have dkms supported modules. We have to build it in tree.

Update to this tutorial:

We need not use the https://github.com/HarleyPato/anbox-arm64 repo.

The main itself can be used which will be more up to date:

https://github.com/anbox/anbox

But we need to update to CMake to a more later version than installed (build from source)

And in the CMakeLists.txt of the anbox dir, comment out tests

#add_subdirectory(tests)

Rest of steps should be same…

I can’t add this line:

Environment=“DISPLAY=:0”

before ExecStart in /usr/lib/systemd/user/anbox-session-manager.service file

otherwise I get the following error :

ziomario-desktop systemd[7681]: /usr/lib/systemd/user/anbox-session-manager.service:6: Invalid environment assignment, ignoring: “DISPLAY=:0”

without that argument,I get this error :

root@ziomario-desktop:# systemctl --user status anbox-session-manager.service
● anbox-session-manager.service - Anbox Session Manager
Loaded: loaded (/usr/lib/systemd/user/anbox-session-manager.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-03-17 22:32:05 CET; 1min 1s ago
Docs: man:anbox(1)
Main PID: 26084 (code=exited, status=1/FAILURE)

ziomario-desktop systemd[7681]: Started Anbox Session Manager.
ziomario-desktop anbox[26084]: Failed to initialize SDL: No available video device
ziomario-desktop systemd[7681]: anbox-session-manager.service: Main process exited, code=exited, status=1/FAILURE
ziomario-desktop systemd[7681]: anbox-session-manager.service: Failed with result ‘exit-code’.

what do u think ?

Update 2

The libSDL2 file is here:

Download the libSDL2 sources of 19.04 from here:

Download the file:
libsdl2_2.0.9+dfsg1.orig.tar.xz

@kayccc , Request one of Nvidia moderators to edit my post for correctness. Thanks.

Failed to initialize SDL: No available video device

is resolved by setting DISPLAY:=0. I am not sure about it. Maybe check on the Anbox Telegram group ? I got a lot of help from that group…

Hi,

Not everyone uses headless mode and the “tutorial” is not intended to replace your own research and googling. So its not “crucial” information for everyone. I just shared what worked for me in a little bit of detail with the hope it will be helpful and save time.
If you have found the way how to get it to work with headless mode you can just share it in the thread.

So you need to adapt to what works for you. With a little bit of googling you could find the correct libSDL2 source link. With a little bit of reading you can find the correct way of building it.

The fact is that what I wrote has actually saved more time that you spent. Anyway next time I will make it “exercise for reader” with generic hints :) :)

You forgot the most important thing to explain. It is not trivial at all and hard to find the answer. How to start anbox application manager on the nano because there is no icon to click on the desktop manager. it is not installed by default. So,the command is this :

anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity

In addition to this crucial information,for me it works correctly only adding these lines to the file : /usr/lib/systemd/user/anbox-session-manager.service

Environment=“DISPLAY=:1”
Environment=XAUTHORITY=/run/user/1000/gdm/

I think that this configuration is necessary for a lot of people.

I think I have given the correct information. As I said you have make it a proper installation by doing the same things that are there on the Ubuntu 20.04 deb data folder.

If you had extracted the deb file you would have found the control.tar.gz and data.tar.gz which when extracted will give all the files that would get copied during deb file installation.

Within the data/usr/share/applications you will find the anbox.desktop which is the launcher. If that file is copied to its right place, you can launch it just like any other application.

So when you have a question on the statement like this "We need android image and services and launcher to be setup. ", you can ask that question directly.

it does not work for me. this is the error that I get :

This could be the problem, but I am not sure.

The LD_LIBRARY_PATH must be setup before cmake. If that step is missed, then correct SDL is not linked.

To confirm run :

rreddy78@jetson-nano:/usr/bin$ ldd anbox
linux-vdso.so.1 (0x0000007f87a66000)
libgtk3-nocsd.so.0 => /usr/lib/aarch64-linux-gnu/libgtk3-nocsd.so.0 (0x0000007f876dc000)
libdw.so.1 => /usr/lib/aarch64-linux-gnu/libdw.so.1 (0x0000007f8768b000)
libboost_log.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_log.so.1.65.1 (0x0000007f875a0000)
libboost_thread.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_thread.so.1.65.1 (0x0000007f8756a000)
libboost_program_options.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_program_options.so.1.65.1 (0x0000007f874d8000)
libSDL2-2.0.so.0 => /usr/local/lib/libSDL2-2.0.so.0 (0x0000007f87389000)

Here you can see that the one installed in the /usr/local/lib is linked.

root@zio-desktop:/usr/bin# ldd anbox
linux-vdso.so.1 (0x0000007f9ee97000)
libdw.so.1 => /usr/lib/aarch64-linux-gnu/libdw.so.1 (0x0000007f9ead1000)
libboost_log.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_log.so.1.65.1 (0x0000007f9e9e6000)
libboost_thread.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_thread.so.1.65.1 (0x0000007f9e9b0000)
libboost_program_options.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_program_options.so.1.65.1 (0x0000007f9e91e000)
libSDL2-2.0.so.0 => /usr/local/lib/libSDL2-2.0.so.0 (0x0000007f9e7cf000)
libSDL2_image-2.0.so.0 => /usr/lib/aarch64-linux-gnu/libSDL2_image-2.0.so.0 (0x0000007f9e793000)
liblxc.so.1 => /usr/lib/aarch64-linux-gnu/liblxc.so.1 (0x0000007f9e6aa000)
libsystemd.so.0 => /lib/aarch64-linux-gnu/libsystemd.so.0 (0x0000007f9e625000)
libboost_iostreams.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_iostreams.so.1.65.1 (0x0000007f9e5fa000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f9e5ca000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f9e5b6000)
libprotobuf-lite.so.10 => /usr/lib/aarch64-linux-gnu/libprotobuf-lite.so.10 (0x0000007f9e555000)
libboost_filesystem.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_filesystem.so.1.65.1 (0x0000007f9e52b000)
libboost_system.so.1.65.1 => /usr/lib/aarch64-linux-gnu/libboost_system.so.1.65.1 (0x0000007f9e516000)
libstdc++.so.6 => /usr/lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f9e382000)
libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f9e35d000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f9e1ea000)
/lib/ld-linux-aarch64.so.1 (0x0000007f9ee67000)
libelf.so.1 => /usr/lib/aarch64-linux-gnu/libelf.so.1 (0x0000007f9e1c0000)
libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007f9e193000)
liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000007f9e163000)
libbz2.so.1.0 => /lib/aarch64-linux-gnu/libbz2.so.1.0 (0x0000007f9e143000)
librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007f9e12b000)
libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f9e07e000)
libsndio.so.6.1 => /usr/lib/aarch64-linux-gnu/libsndio.so.6.1 (0x0000007f9e05f000)
libpng16.so.16 => /usr/lib/aarch64-linux-gnu/libpng16.so.16 (0x0000007f9e024000)
libjpeg.so.8 => /usr/lib/aarch64-linux-gnu/libjpeg.so.8 (0x0000007f9dfda000)
libtiff.so.5 => /usr/lib/aarch64-linux-gnu/libtiff.so.5 (0x0000007f9df5f000)
libwebp.so.6 => /usr/lib/aarch64-linux-gnu/libwebp.so.6 (0x0000007f9df07000)
libgnutls.so.30 => /usr/lib/aarch64-linux-gnu/libgnutls.so.30 (0x0000007f9dda6000)
libselinux.so.1 => /lib/aarch64-linux-gnu/libselinux.so.1 (0x0000007f9dd73000)
libseccomp.so.2 => /lib/aarch64-linux-gnu/libseccomp.so.2 (0x0000007f9dd19000)
libutil.so.1 => /lib/aarch64-linux-gnu/libutil.so.1 (0x0000007f9dd05000)
libcap.so.2 => /lib/aarch64-linux-gnu/libcap.so.2 (0x0000007f9dcef000)
liblz4.so.1 => /usr/lib/aarch64-linux-gnu/liblz4.so.1 (0x0000007f9dcc3000)
libgcrypt.so.20 => /lib/aarch64-linux-gnu/libgcrypt.so.20 (0x0000007f9dc08000)
libasound.so.2 => /usr/lib/aarch64-linux-gnu/libasound.so.2 (0x0000007f9db12000)
libbsd.so.0 => /lib/aarch64-linux-gnu/libbsd.so.0 (0x0000007f9daf0000)
libjbig.so.0 => /usr/lib/aarch64-linux-gnu/libjbig.so.0 (0x0000007f9dad1000)
libp11-kit.so.0 => /usr/lib/aarch64-linux-gnu/libp11-kit.so.0 (0x0000007f9d9bf000)
libidn2.so.0 => /usr/lib/aarch64-linux-gnu/libidn2.so.0 (0x0000007f9d993000)
libunistring.so.2 => /usr/lib/aarch64-linux-gnu/libunistring.so.2 (0x0000007f9d810000)
libtasn1.so.6 => /usr/lib/aarch64-linux-gnu/libtasn1.so.6 (0x0000007f9d7ef000)
libnettle.so.6 => /usr/lib/aarch64-linux-gnu/libnettle.so.6 (0x0000007f9d7ac000)
libhogweed.so.4 => /usr/lib/aarch64-linux-gnu/libhogweed.so.4 (0x0000007f9d76b000)
libgmp.so.10 => /usr/lib/aarch64-linux-gnu/libgmp.so.10 (0x0000007f9d6ee000)
libpcre.so.3 => /lib/aarch64-linux-gnu/libpcre.so.3 (0x0000007f9d67c000)
libgpg-error.so.0 => /lib/aarch64-linux-gnu/libgpg-error.so.0 (0x0000007f9d65a000)
libffi.so.6 => /usr/lib/aarch64-linux-gnu/libffi.so.6 (0x0000007f9d640000)

can u make a little experiment ? can u try to launch anbox as root ?