Skip to content

Instantly share code, notes, and snippets.

@Luiz-Monad
Created January 27, 2024 00:20
Show Gist options
  • Save Luiz-Monad/9feeac3bf833c96b77b3c3afe4ca7858 to your computer and use it in GitHub Desktop.
Save Luiz-Monad/9feeac3bf833c96b77b3c3afe4ca7858 to your computer and use it in GitHub Desktop.
android_binder.ko
apt-get install --no-install-recommends -yq dpkg-dev dkms git
apt-get install --no-install-recommends -yq fakeroot build-essential libncurses-dev xz-utils libssl-dev flex libelf-dev bison bc
cp v$VER/include/uapi/linux/android/binder.h `find /usr/src/ | grep include/uapi/linux/android/binder.h`
cp v$VER/include/uapi/linux/android/binderfs.h `find /usr/src/ | grep include/uapi/linux/android/binderfs.h`
# upstream sources
VER=$(uname -r | cut -d- -f1)
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git --depth 1 --tag v$VER
cp -R v$VER/drivers/android /usr/src/
# create module
pushd /usr/src
mv android android-1
cd android-1
cat > ./dkms.conf <<EOF
PACKAGE_NAME=android
PACKAGE_VERSION=1
BUILT_MODULE_NAME[0]=android
DEST_MODULE_LOCATION[0]=/updates
MAKE[0]="make all KERNEL_SRC=\${kernel_source_dir} -C \${kernel_source_dir}
CLEAN="make clean"
AUTOINSTALL=yes
EOF
cat > ./Makefile <<EOF
ccflags-y += -I\$(src) -DCONFIG_ANDROID_BINDERFS=y -DCONFIG_ANDROID_BINDER_IPC=y -DCONFIG_ANDROID_BINDER_DEVICES="\"binder,hwbinder,vndbinder\""
obj-m := android.o
android-y := $(find *.c | grep -v test | sed "s/.c$/.o/g" | tr '\n' ' ')
all:
\$(MAKE) -C \$(KERNEL_SRC) M=\$\$PWD
install:
cp android.ko \$(DESTDIR)/
clean:
rm -rf deps.h *.o *.ko *.mod.c *.symvers *.order .*.cmd .tmp_versions
EOF
popd
dkms add -m android -v 1
# build module
dkms build -m android -v 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment