编译ko模块
Android跟Linux系统通讯依赖于binder和ashmem两个模块,需要编译安装到新内核。
编译和安装ko模块需要用到两个patch文件,均存放在“patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder”路径下,具体编译过程请参考下面的步骤。
- 创建文件夹,存放ashmem源码。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/ # mkdir -p ashmem # mkdir -p ashmem/uapi # chmod -R 700 ashmem
- 将内核源码目录中“/usr/src/kernels/kernel-5.10.0-60.18.0/drivers/staging/android”文件夹下的指定文件复制到1中创建的“ashmem”文件夹下。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/ashmem # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/staging/android/ashmem.c ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/staging/android/ashmem.h ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/staging/android/Makefile ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/staging/android/uapi/ashmem.h ./uapi/
- 创建文件夹,存放binder源码。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/ # mkdir -p binder # mkdir -p binder/uapi # chmod -R 700 binder
- 将内核源码目录中“/usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/”文件夹下的指定文件复制到3中建立的“binder”文件夹下。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/binder # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/binder_alloc.c ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/binder_alloc.h ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/binder.c ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/binder_internal.h ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/binder_trace.h ./ # cp /usr/src/kernels/kernel-5.10.0-60.18.0/drivers/android/Makefile ./
- 将内核源码目录中“/usr/src/kernels/kernel-5.10.0-60.18.0/include/uapi/linux/android/”文件夹下的指定文件复制到3中建立的“binder/uapi”文件夹下。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/binder/uapi # cp /usr/src/kernels/kernel-5.10.0-60.18.0/include/uapi/linux/android/binder.h ./
- 合入ashmem.patch、binder.patch。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/ # patch -p1 < ashmem.patch # patch -p1 < binder.patch
- 编译ashmem。
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/ashmem/ # make KERNEL_SRC=/usr/src/kernels/kernel-5.10.0-60.18.0 V=0 M=~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/ashmem/ # cp ashmem_linux.ko /lib/modules/5.10.0/kernel/lib/
- 编译binder。
1 2 3
# cd ~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/binder/ # make KERNEL_SRC=/usr/src/kernels/kernel-5.10.0-60.18.0 V=0 M=~/dependency/patchForKernel/openEuler_22.03/kernel_5.10.0/ashmem_binder/binder/ # cp aosp_binder_linux.ko /lib/modules/5.10.0/kernel/lib/
父主题: 编译内核及ko模块