Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Solution for building binder and ashmem modules on kernel version above 5.7 #75

Open
SoulInfernoDE opened this issue Feb 27, 2021 · 57 comments

Comments

@SoulInfernoDE
Copy link

Hello,
here are the log:

ASHMEM

DKMS make.log for anbox-ashmem-1 for kernel 5.11.0-051100-generic (x86_64) Sa 27. Feb 08:00:47 CET 2021 make -C /lib/modules/5.11.0-051100-generic/build V=0 M=$PWD make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird betreten CC [M] /var/lib/dkms/anbox-ashmem/1/build/deps.o CC [M] /var/lib/dkms/anbox-ashmem/1/build/ashmem.o LD [M] /var/lib/dkms/anbox-ashmem/1/build/ashmem_linux.o MODPOST /var/lib/dkms/anbox-ashmem/1/build/Module.symvers ERROR: modpost: "kallsyms_lookup_name" [/var/lib/dkms/anbox-ashmem/1/build/ashmem_linux.ko] undefined! make[2]: *** [scripts/Makefile.modpost:111: /var/lib/dkms/anbox-ashmem/1/build/Module.symvers] Fehler 1 make[2]: *** Datei „/var/lib/dkms/anbox-ashmem/1/build/Module.symvers“ wird gelöscht make[1]: *** [Makefile:1710: modules] Fehler 2 make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird verlassen make: *** [Makefile:12: all] Fehler 2

BINDER

DKMS make.log for anbox-binder-1 for kernel 5.11.0-051100-generic (x86_64) Sa 27. Feb 08:00:50 CET 2021 make -C /lib/modules/5.11.0-051100-generic/build V=0 M=$PWD make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird betreten CC [M] /var/lib/dkms/anbox-binder/1/build/deps.o CC [M] /var/lib/dkms/anbox-binder/1/build/binder.o /var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘task_get_unused_fd_flags’: /var/lib/dkms/anbox-binder/1/build/binder.c:444:9: error: implicit declaration of function ‘__alloc_fd’ [-Werror=implicit-function-declaration] 444 | return __alloc_fd(files, 0, rlim_cur, flags); | ^~~~~~~~~~ /var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘task_fd_install’: /var/lib/dkms/anbox-binder/1/build/binder.c:454:3: error: implicit declaration of function ‘__fd_install’; did you mean ‘fd_install’? [-Werror=implicit-function-declaration] 454 | __fd_install(proc->files, fd, file); | ^~~~~~~~~~~~ | fd_install /var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘task_close_fd’: /var/lib/dkms/anbox-binder/1/build/binder.c:467:11: error: implicit declaration of function ‘__close_fd’; did you mean ‘close_fd’? [-Werror=implicit-function-declaration] 467 | retval = __close_fd(proc->files, fd); | ^~~~~~~~~~ | close_fd /var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘binder_mmap’: /var/lib/dkms/anbox-binder/1/build/binder.c:3498:16: error: implicit declaration of function ‘get_files_struct’; did you mean ‘put_files_struct’? [-Werror=implicit-function-declaration] 3498 | proc->files = get_files_struct(current); | ^~~~~~~~~~~~~~~~ | put_files_struct cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:279: /var/lib/dkms/anbox-binder/1/build/binder.o] Fehler 1 make[1]: *** [Makefile:1806: /var/lib/dkms/anbox-binder/1/build] Fehler 2 make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird verlassen make: *** [Makefile:8: all] Fehler 2

@rizzini
Copy link

rizzini commented Mar 2, 2021

Same here.

@choff
Copy link

choff commented Mar 7, 2021

Hello all,

I just came across the same problem. After some research on this topic, I found out that the build fails because "kallsyms_lookup_name()" is now no longer exported by the kernel for reasons described here: https://lwn.net/Articles/813350 . However, Anbox kernel modules are using kallsyms_lookup_name() to access some internal kernel functions that they otherwise wouldn't be able to call (such as "zap_page_range"). The Anbox kernel modules should never have used these functions in the first place as they are not supposed to be used by kernel modules (they are lacking an "EXPORT_SYMBOL()" annotation).

There is probably nothing that we can do to get these kernel modules to compile for kernels 5.10 and 5.11 anymore. To solve the problems, changes to the upstream kernel would be required to export the (up to now) internal functions like "zap_page_range()" and add an EXPORT_SYMBOL annotation to them.

You are probably best off by asking the kernel maintainers of your Linux distribution to include binder and ashmem in their kernels per default. The way it looks right now, building ashmen and binder as kernel modules is no longer a way to go. To make it work again, the Linux kernel devs would need to expose a whole lot of up-to-now internal functions - I am not sure if even they's be willing to do that.

Best regards,

Christian

@choff
Copy link

choff commented Mar 8, 2021

Essentially, this is a duplicate of issue #49 , though the error message you see is slightly different. Please check my last commit in that issue if you really need a solution that makes binder and ashmem work again as modules with the latest kernels. I am using it with kernel 5.10 and it works fine.

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Mar 9, 2021

So okay im writing down how i am trying to fix the issue for me. (12.03.21 - i reviewed the procedure after some testing.)

New edit: successfully compiled and tested! - [13.03.21]


Compile kernel with android options enabled:

-->> Scripts for automate the following steps can be obtained and improved here:
https://github.com/SoulInfernoDE/compile-kernel-from-source

.

[28.03.23]
### For the lazy ones a modern one liner for copy and paste to your terminal for the first use:

rm cfs_noguimerge.sh*; wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/nogui/cfs_noguimerge.sh && chmod +x cfs_noguimerge.sh && ./cfs_noguimerge.sh

.

### For the second use you need to delete all files generated by the script / tool to work correctly again:

rm cfs_noguimerge.sh*; sudo rm -f ~/Downloads/linux-*.deb ~/Downloads/linux-*.buildinfo ~/Downloads/linux-*.changes ~/Downloads/ashmemk6.tar.xz*; sudo rm -R -f ~/Downloads/kernel/ ~/Downloads/anboxashmem/; wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/nogui/cfs_noguimerge.sh && chmod +x cfs_noguimerge.sh && ./cfs_noguimerge.sh

.

i am using Linux Mint 21.1 with Kernel 6.1.12 from UKUU utility which downloads and installs the kernels from official source. (you can always manually download and install them on http://kernel.ubuntu.com/~kernel-ppa/mainline/ but ukuu automates that with a nice gui - its not for free so manually installing them is the recommend way for most ppl.)


Steps to manually compile your kernel with ANDROID options:

Show your current installed kernel:
uname -a
Linux 5.11.6-051106-generic #202103111435 SMP Thu Mar 11 14:42:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Installing propably needed dependencies:
Installing propably needed dependencies:

sudo apt install git dwarves build-essential fakeroot bc kmod cpio libncurses5-dev libgtk2.0-dev libglib2.0-dev libglade2-dev libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev dpkg-dev autoconf libdw-dev cmake zstd

**download and install dependency dwarves: (deprecated since newer linux versions already include this) **
http://archive.ubuntu.com/ubuntu/pool/universe/d/dwarves-dfsg/dwarves_1.21-0ubuntu1~20.04_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/d/dwarves-dfsg/dwarves_1.17-1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/d/dwarves-dfsg/dwarves_1.20-1_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/libb/libbpf/libbpf0_0.3-2ubuntu1_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/glibc/libc6_2.33-0ubuntu5_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/glibc/libc6_2.33-0ubuntu5_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/f/fakeroot/libfakeroot_1.25.3-1.1ubuntu2_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/f/fakeroot/fakeroot_1.25.3-1.1ubuntu2_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/glibc/locales_2.33-0ubuntu5_all.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/glibc/libc-bin_2.33-0ubuntu5_amd64.deb

Edit new [12.07.2021]: The newest stable kernel 5.13.1 doesn't compile with the pahole/dwarves version 1.17 anymore.
To fix this i downloaded the source of pahole v1.21, compiled and installed it:

git clone https://github.com/acmel/dwarves.git
cd dwarves
mkdir build
cd build
sudo cmake -D__LIB=lib -DBUILD_SHARED_LIBS=OFF ..
sudo make install

I downloaded official kernel source from here:
https://www.kernel.org
https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.11.4/ with following command:

Create a folder where we download the source code, create the compile-configuration parameter file and finally compile the kernel with it:

mkdir kernel
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.18.tar.xz
tar xvf linux-* -C kernel/ --strip-components=1
cd kernel
git clone git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack cod/mainline/v5.11.4 cd cod/mainline/v5.11.4

Information:::
You need to have the latest kernel running to copy the correct config file of your current running kernel!

I copied the original .config file for building the kernel from my installed one:
cp /boot/config-$(uname -r) ./.config


KERNEL 5.18.X and above
ASHMEM has been dropped completely as to this kernel source patch from torvalds:
torvalds/linux@721412e

Aslong as anbox is using ASHMEM instead of MEMFD we need to revert the deletion of the
ASHMEM module patch to be able to use anbox for now.
Download the patch in the same directory you downloaded and extracted the kernel sources:
wget -O remove_ashmem.patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=721412ed3d819e767cac2b06646bf03aa158aaec

Revert the patch with:
interdiff -q remove_ashmem.patch /dev/null > enable_ashmem.patch

Patch the source code with the reverted patch code:
patch -p1 -i enable_ashmem.patch

Proceed with the next steps described here - the ASHMEM is now back in the make xconfig


afterwards executing:

make xconfig or make gconfig

or if you build from an already enabled android options enabled kernel make an oldconfig with

make olddefconfig

scroll through the menu and look for ashmem and binder. (One is inside stageing driver if i remember correct.)
grafik

Scroll further down to the next Android section:
grafik

Double click to activate the marked points and save as you are ready.

If you start compiling now, there seems to be a bug at least at my side and it stops building with a 'debian/canonical-certs.pem' error.

To fix this you can create this file. Use the certificate data here in this patch:
https://lists.ubuntu.com/archives/kernel-team/2020-October/113929.html

Copy from
--BEGIN CERTIFICATE--
to
--END CERTIFICATE--

and remove the '+' on each line.

Save it to debian/canonical-certs.pem

To fix the certificate error while compiling you need to remove path data in " " the line:

CONFIG_SYSTEM_TRUSTED_KEYS=""
and
CONFIG_SYSTEM_REVOCATION_KEYS=""

Start compile with a simple:
time nice make bindeb-pkg LOCALVERSION=-android

If you want to compile with more cores run the command nproc and then you see your availabe cores. Run with number of cores you want to use -jX:
time nice make -j4 bindeb-pkg LOCALVERSION=-android

Note: The time command counts how long the build process have taken after it finished.

Then install the deb packages which should be in your parent directory

cd ..
sudo dpkg -i linux-*.deb

Restart and enter:

uname -a

it should print something like *android-1 then you know it booted the newly generated kernel.

Warning:
Doing so needs some space and much time to build. I am still building... ...i will get back and report if it worked for me.

Edit 13.03.21: Successfully compiled the kernel with older 4 core-laptop in about 3 hours.
After compiling try to follow the instructions to activate binderfs and activate /dev/binder permanent on boot.
uname -a says:

Linux 5.11.6android1 #1 SMP Fri Mar 12 11:32:19 CET 2021 x86_64 x86_64 x86_64 GNU/Linux

Edit: Link to GDrive where i layed down my compiled deb-files for own history. (Using it in your own environment at your own risk!)

Pre-compiled *.debs:

5.11.x Branch

  • Added updated kernel version 5.11.16 stable branch from kernel.org (26.04.21)

5.12.x Branch

  • Added updated kernel version 5.12.0 stable branch from kernel.org (27.04.21)
  • Added updated kernel version 5.12.1 stable branch from kernel.org (05.05.21)
  • Added updated kernel version 5.12.7 stable branch from kernel.org (27.05.21)
  • Added updated kernel version 5.12.9 stable branch from kernel.org (06.06.21)
  • Added updated kernel version 5.12.13 stable branch from kernel.org (30.06.21)
  • Added updated kernel version 5.12.14 stable branch from kernel.org (03.07.21)

5.13.x Branch

  • Added updated kernel version 5.13.1 stable branch from kernel.org (09.07.21) (deprecated build)
  • Added updated kernel version 5.13.8 stable branch from kernel.org (07.08.21) (deprecated build)
  • Added updated kernel version 5.13.9 stable branch from kernel.org (08.08.21) - (build succeeds but its not booting for me. Need to optimize dependencys for building with newer GCC and glibc first. I'll think of a build environment with newer ubuntu core as this has higher package versions already included. Next compile will take longer for me to figure out as i am busy also with real life.)
  • Added updated kernel version 5.13.19 stable branch from kernel.org (compiled - uploaded on 12.01.22)

5.14.x Branch

  • Added updated kernel version 5.14.1 stable/upstream branch from kernel.org (08.09.21)
  • Added updated kernel version 5.14.2 stable/upstream branch from kernel.org (09.09.21)
  • Added updated kernel version 5.14.13 stable/upstream branch from kernel.org (17.10.21)
  • Added updated kernel version 5.14.14 stable/upstream branch from kernel.org (22.10.21)
    If your linux mint cinnamon-settings manager or similiar included system tools are not opening, then you need to install the imtools with:
    pip3 install imtools . Some updates changed the system behaviour. If you get a warning about an old pip version just execute:
    /usr/bin/python3 -m pip install --upgrade pip. Hope this helps.
  • Added updated kernel version 5.14.18 stable/upstream branch from kernel.org (14.11.21)
  • Added updated kernel version 5.14.21 stable/upstream branch from kernel.org (24.11.21) [EOL]

5.15.x Branch

  • Added updated kernel version 5.15.5 stable/upstream branch from kernel.org (29.11.21)
  • Added updated kernel version 5.15.6 stable/upstream branch from kernel.org (compiled on 07.12.21)
  • Added updated kernel version 5.15.10 stable/upstream branch from kernel.org (compiled on 20.12.21)
  • Added updated kernel version 5.15.11 stable/upstream branch from kernel.org (compiled on 25.12.21)

5.16.x Branch[EOL]

  • Added updated kernel version 5.16.20 stable/upstream branch from kernel.org (16.04.22)

5.17.x Branch

  • Added updated kernel version 5.17.1 stable/upstream branch from kernel.org (05.04.22)
  • Added updated kernel version 5.17.2 stable/upstream branch from kernel.org (11.04.22)
  • Added updated kernel version 5.17.3 stable/upstream branch from kernel.org (16.04.22)
  • Added updated kernel version 5.17.5 stable/upstream branch from kernel.org (01.05.22)
  • Added updated kernel version 5.17.6 stable/upstream branch from kernel.org (11.05.22)
  • Added updated kernel version 5.17.9 stable/upstream branch from kernel.org (19.05.22)
  • Added updated kernel version 5.17.11 stable/upstream branch from kernel.org (28.05.22)
  • Added updated kernel version 5.17.15 EOL stable/upstream branch from kernel.org (18.06.22)

5.18.x Branch - EOL

  • Added updated kernel version 5.18 stable/main branch from kernel.org (29.05.22)
  • Added updated kernel version 5.18.5 stable/main branch from kernel.org (18.06.22)
  • Added updated kernel version 5.18.7 stable/main branch from kernel.org (25.06.22)
  • Added updated kernel version 5.18.9 stable/main branch from kernel.org (03.07.22)
  • Added updated kernel version 5.18.10 stable/main branch from kernel.org (10.07.22)
  • Added updated kernel version 5.18.12 stable/main branch from kernel.org (21.07.22)
  • Added updated kernel version 5.18.19 - EOL stable/main branch from kernel.org (10.09.22)

5.19.x Branch

  • Added updated kernel version 5.19.8 stable/main branch from kernel.org (11.09.22)
  • Added updated kernel version 5.19.10 stable/main branch from kernel.org (21.09.22)

6.x Branch

  • Added updated kernel version builded within Linux Mint 21 Vanessa (based on Ubuntu 22.04) 6.0 stable/main branch from kernel.org (08.10.22)
  • Added updated kernel version builded within Linux Mint 21.1 (based on Ubuntu 22.04) 6.1.12 stable/main branch from kernel.org (15.02.23)
  • Added updated kernel version builded within Linux Mint 21.1 (based on Ubuntu 22.04) 6.2.8 stable/main branch from kernel.org (26.03.23)

NOTE: DUE TO LIMITED TIME FOR THESE THINGS I AM NOT GOING TO UPDATE THE LIST FREQUENTLY. I WILL UPDATE THE GDRIVE FOLDER FROM TIME TO TIME WITHOUT NOTICE HERE

´
´

WARNING! In 5.18.x ASHMEM has been completely removed from the kernel according to this commit from torvalds:
torvalds/linux@721412e

I am investigating how i can work around that problem actually.. ..for now use 5.17.x
we need to revert that patch until anbox uses MEMFD instead of ASHMEM to be able to use anbox again.

- Future plan is to compile some kernel branches with the latest / last EOL kernel for other use cases and clean/remove old/deprecated ones.


Note as of now: (09.07.21)

To be able to successfully build and run the latest kernel versions with linux mint 20.x you need newer glibc and gcc versions which are included in ubuntu 21.10 already. Unfortunately i didn't figure out yet how i could update them without "heart touching" the whole linux mint 20.x system. It is until now very complicated as you need to compile gcc and glibc from source and maybe many other dependencys that relay on other updated dependencys and updated gcc and glibc.
So for me until now i workaround this with a virtual machine (i use a synology virtual machine which works independend of my laptop. You may could use QEMU for example if you really want to build from scratch) and the latest ubuntu 21.04 installation where i use this handbook i wrote together to build the newer kernels there until linux mint switches to the new ubuntu base image where many apps and dependencys will get updates and higher versions included. I know this is very uncomfortable actually but in my opinion more stressless. Maybe i'll try docker anytime in the future to build it in the future where we could create a preconfigured ubuntu image with dependencys already installed but thats on another star yet.
If you need any option enabled in the kernel i can do that for my own pre-compiled kernels also, just leave a note here what you need. I dont care about some more drivers or options included even if i don't use them.

So if you want to compile newer kernels i'll suggest to stick to older ones actually or maybe to the 5.12.x branch where compiling could be done with the included files and apps from linux mint 20.x system.


Secure Boot / UEFI: (05.04.22)
Using newer hardware with UEFI / Secure Boot active will need an extra step to make the changed android kernel builds boot.
I recommend to take a look at this Information: (Thanks to jakeday to write down the steps for the average user like me)
https://github.com/jakeday/linux-surface/blob/3267e4ea1f318bb9716d6742d79162de8277dea2/SIGNING.md

.

28.03.23:
You can also have a look at this script / tool which automates the secure boot / uefi signing process ( a standard mok file is generated with dummy informations used in the certificate and signed with your newly generated kernel)

/v6.x/signkernel/cfs_signkernel.sh

.

### And for the lazy ones that want to copy and paste into a terminal:

rm cfs_signkernel.sh*; wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/signkernel/cfs_signkernel.sh && chmod +x cfs_signkernel.sh && ./cfs_signkernel.sh

.

@SoulInfernoDE
Copy link
Author

Hello all,
i tried to compile the kernel like mentioned before but its more trial and error and guessing. I try to learn and understood linux and all the compiling things but im quietly new to this.

It did compile and install but it did not install the modules and therefore i couldn't boot into the system. Also it said it compiled 5.10 instead 5.11. Anyone wants to provide help to this topic as the best way seems to be to enable the in built modules as for now.

And the new ubuntu kernels seems to not have them enabled by default (v.5.11;v5.10 etc.)

@choff
Copy link

choff commented Mar 10, 2021

Hello @SoulInfernoDE ,

first of all, as soon as you build something into the kernel, it's not a module anymore. Modules are just dynamically loadable "plugins" for the kernel. So, if you have compiled ashmem and binder support into your kernel, ashmem and binder are not modules. They are just part of the main kernel.

What is the error message you see from Anbox? Is it complaining that either ashmem or binder kernel module is not loaded? Maybe in that case, it will help to upgrade Anbox... Maybe Anbox some time ago only supported the external kernel modules and not yet the built-in ashmem and binder functionality that is now available with recent kernels.

You should try to check the kernel config of your hand-compiled kernel with one of the methods described here: https://superuser.com/questions/287371/obtain-kernel-config-from-currently-running-linux-system and verify that ashmem and binder are indeed enabled.

Do at least my "hacked" kernel modules for ashmem and binder work for you?
Best regards,

Christian

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Mar 10, 2021

Hello Christian,
thanks for assisting. I am actually not at home to test your method.
What I can say is that if I try to mount binder it says unknown file system. So I am sure my kernel don't know binder yet and if I look at the configuration file .config it is not active yet.
Therefore the inbuilt ashmem and binder hasn't been compiled into the kernel yet.

Also the copied config from actual kernel says: ANDROID
not configured

Which make menuconfig confirms this

@choff
Copy link

choff commented Mar 10, 2021

Hello @SoulInfernoDE ,

all right, then you know the root cause at the very least :-)

I think you are using some Ubuntu-based distributon. Ubuntu applies its own patches to the kernel and building a kernel for Ubuntu is described here: https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel . This description also tells you how you can modify the kernel configuration.

If you use a standard kernel without Ubuntu modifications, a simple "make menuconfig" will do the trick. But Ubuntu kernels are built in a different way and different commands need to be used there, so a "make menuconfig" will likely not work and you need to follow the instructions from the Ubuntu page that I have linked above.

Best regards,

Christian

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Mar 10, 2021

Hello Christian,
thanks for trying to support. It's the same article I mentioned under installing dependencies :-)

I have found this guide and will check that when I'm back home:

https://tutorialforlinux.com/2021/01/15/how-to-install-kernel-5-11-from-source-on-linux-mint-20/

WARNING:
unfortunately this guide site has many ads. Still noted because it could help us.

Edit:

Also found this video guide:
https://youtu.be/E4yRcmQqvWM

13.03.21 - I collected informations and successfully tested and compiled the kernel with the android options enabled.

You can read the solution here if you want to try it yourself and dont know how yet:
#75 (comment)

Edit: 18.03.21

Successfully build 5.11.7

real	163m8,412s
user	553m7,071s
sys	54m21,928s

@lsahn-gh
Copy link

lsahn-gh commented May 24, 2021

@SoulInfernoDE aren't the configs, ASHMEM/BINDER depended on ANDROID as platform dependency? so that you enable the dependency in force?

here is menuconfig help for ashmem

Depends on: STAGING [=n] && ANDROID [=n] && SHMEM [=n]

Edited
Just figured out that I can manually pick the dependency :)

@adil192
Copy link

adil192 commented Aug 22, 2021

Small update for anyone who comes across this thread...

sudo apt install git dwarves build-essential fakeroot bc kmod kernel-package cpio libncurses5-dev libgtk2.0-dev libglib2.0-dev libglade2-dev libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev dpkg-dev autoconf libdw-dev cmake

For me there was no kernel-package, and I was missing zstd. So the updated command can be
sudo apt install git dwarves build-essential fakeroot bc kmod cpio libncurses5-dev libgtk2.0-dev libglib2.0-dev libglade2-dev libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev dpkg-dev autoconf libdw-dev cmake zstd

To fix the certificate error while compiling you need to remove path data in " " the line:

CONFIG_SYSTEM_TRUSTED_KEYS=""

I needed to remove the path from both trusted keys and revocation keys in my .config file:

CONFIG_SYSTEM_TRUSTED_KEYS=""
...
CONFIG_SYSTEM_REVOCATION_KEYS=""

@SoulInfernoDE
Copy link
Author

I added that info and updated my notes.
Thanks @adil192 💟

@SeremTitus
Copy link

SeremTitus commented May 4, 2022

I been having hard time trying to build and install this kernel modules, this issues' comment seem to have a solution however not being an expert in the Linux kernel am lost in the technicalities. Can some one help me out by linking a script that just works...I am on Ubuntu

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented May 4, 2022

i can try to make a script for you. You can also use my precompiled .deb files if you like:

https://drive.google.com/drive/folders/1X4ojO2KYExc94yc5XFlPx7M_tKu-5gBy?usp=sharing

Kernel 5.17.5 direct link:
https://drive.google.com/drive/folders/1TakXT93Q16s_Sz7zOcmAZ7L4xvMy8WEC

Instructions for the deb files:

  • Download at least the Linux-Image, Linux Headers and Linux-libc deb-files. (To your downloads folder)
  • open terminal and enter:
    cd Downloads
    sudo dpkg -i linux-*.deb

Reboot and open terminal:
uname -a

If you see something like this:
image

Then you have the modules built in and loaded..

What you need to do now is to activate the binder to make anbox work:

#49 (comment) and #50 (comment).

For the one shot script i will try to write it now.

Edit:

Creating the scripts is ongoing - the goal is a one shot nogui version and a gui version where you can manually add/change options. As i am doing all this in my spare time i will update and improve it from time to time.

You can find the scripts here:
https://github.com/SoulInfernoDE/compile-kernel-from-source

@SeremTitus
Copy link

#75 (comment), took care of this issue for me.

Thanks to @SoulInfernoDE for help . And can you consider creating pull request

@SoulInfernoDE
Copy link
Author

#75 (comment), took care of this issue for me.

Thanks to @SoulInfernoDE for help . And can you consider creating pull request

Sure, pull request is opened to your fork. If you have any ideas or suggestions feel free to contribute and pull request them back to my main branch.

@DeafMan1983
Copy link

Wow thanks my friend :D
sudo dkms remove -m anbox-ashmem/1 --all

It works fine. Thanks It can remove ... :D

Then I will resolve again...

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Jun 25, 2022

Very cool - glad it worked 😄

Could you boot your newly installed kernel and did you check the output of uname -a && ls -1 /dev/{ashmem,binder} yet? 😁

I think checking of installed module and removing it with the script is a good update. Will add that now 😀

@DeafMan1983
Copy link

I am very disappointed why is binder not successful for me :( ?

I am broken on floor. :/ I can't fix that. I don't understand why does it happen with Ubuntu 22.04 I don't believe that if it doesn't support for me.

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Jun 25, 2022

So binder is not active?

Could you try this and show me the output?:

sudo mkdir /dev/binder
sudo mount -t binder binder /dev/binder

If you have anbox installed could you also check:
anbox system-info

I am very disappointed why is binder not successful for me :( ?

I am broken on floor. :/ I can't fix that. I don't understand why does it happen with Ubuntu 22.04 I don't believe that if it doesn't support for me.

If it is in the kernel sources it is definitly supported. I guess it is. I'll help you out as far as i can 😃

Also this output should be of a good help for me:
cat /boot/config-5.15.0-android | grep BINDER

should show something like this:
image

@SoulInfernoDE SoulInfernoDE changed the title Kernel 5.11 binder and ashmem not building with dkms Solution for building binder and ashmem modules on kernel version above 5.7 Sep 11, 2022
@SoulInfernoDE
Copy link
Author

I am very disappointed why is binder not successful for me :( ?

I am broken on floor. :/ I can't fix that. I don't understand why does it happen with Ubuntu 22.04 I don't believe that if it doesn't support for me.

Do you still need help for this? :-)

@Sudococommunity
Copy link

i need help i have binder module running but ashmem module is not there and i dont have android.img too my os 6.1.0-1parrot1-amd64
based on debian

@Sudococommunity
Copy link

anbox

@Sudococommunity
Copy link

anbox1

@Sudococommunity
Copy link

anbox2

@SoulInfernoDE
Copy link
Author

For Ashmem you could try the fix from @choff

First remove the ashmem dkms module you already have installed and delete the copied files from the original source.

Then download the ashmem folder with the ashmem.c fix from here:
https://github.com/choff/anbox-modules/tree/master

Finally follow the readme for the part with Ashmem.

@Froggio5543
Copy link

Im a little confused as to what I should do to fix this error. Which .deb file should I install or which of your guides should I follow to fix this? I am currently using debian 11 if that helps. Thank you!
Screenshot 2023-06-26 12 37 14 PM

@SoulInfernoDE
Copy link
Author

You have linux system with kernel 5.15 it seems that binder is not present in some way.

Could you please show us the output of this command:
cat /boot/config-5.15.108-18910-gab0e1cb584e1| grep BINDER

This will show us if you have BINDER inside your kernel or not.

@Froggio5543
Copy link

Ok
image

@SoulInfernoDE
Copy link
Author

Oh seems the file is named else maybe this works?:
cat /boot/config-$(uname -r) | grep BINDER

@Froggio5543
Copy link

nope, it gives me the same output
image

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Jun 26, 2023

oof that is very strange but then lets try to find out if binder is there anyhow with this:

sudo mkdir /dev/binder && sudo mount -t binder binder /dev/binder

@Froggio5543
Copy link

ok so it is there the question now becomes where.
image

@Froggio5543
Copy link

Froggio5543 commented Jun 26, 2023

If it helps earlier I managed to run these two commands successfully and downloaded the latest version from the pre-built ones you had in the google drive folder.

[28.03.23] ### For the lazy ones a modern one liner for copy and paste to your terminal for the first use:

rm cfs_noguimerge.sh*; wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/nogui/cfs_noguimerge.sh && chmod +x cfs_noguimerge.sh && ./cfs_noguimerge.sh

.

### For the second use you need to delete all files generated by the script / tool to work correctly again:

rm cfs_noguimerge.sh*; sudo rm -f ~/Downloads/linux-*.deb ~/Downloads/linux-*.buildinfo ~/Downloads/linux-*.changes ~/Downloads/ashmemk6.tar.xz*; sudo rm -R -f ~/Downloads/kernel/ ~/Downloads/anboxashmem/; wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/nogui/cfs_noguimerge.sh && chmod +x cfs_noguimerge.sh && ./cfs_noguimerge.sh

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Jun 26, 2023

alright . It seems binder is now loaded, can you try to run waydroid again?

@Froggio5543
Copy link

still gives me the same thing. I think waydroid is looking for the wrong binder version although waydroid is upgraded to the newest version.
image

@SoulInfernoDE
Copy link
Author

it seems it only searches binder at that specific directory. But your config file for your kernel seems also be missing somehow.
I need to sleep now but could you also try this:
sudo modprobe configs && zcat /proc/config.gz > /boot/config-$(uname -r) && cat /boot/config-$(uname -r) | grep BINDER

@Froggio5543
Copy link

unfortunately it gave me this but if you need to sleep then go ahead.
image

@SoulInfernoDE
Copy link
Author

SoulInfernoDE commented Jun 30, 2023

v5.15 kernel is a bit old. Maybe a newer kernel like 5.19 or higher works?

I recommended to try a newer kernel version from kernel.org to see if that fixes the path problem.

The script from my repo can help you with this if you are new to compile a kernel from source. But if you are on an unofficial kernel can you boot to your official kernel and then start the build process so that you get a config file from your running kernel (its not necesarly needed though but it includes configurations to your kernel on the system that you are running)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants