Android 驱动开发---Android Linux 内核编译 Nexus 5x
本文以Nexus 5X为例,讲解Android Linux 驱动开发的准备
驱动开发了解:
Android对硬件的支持分成了两层,
一层放在用户空间(User Space),
一层放在内核空间(Kernel Space),
其中,硬件抽象层运行在用户空间,而Linux 内核驱动程序运行在内核空间。
所以Android的开放代码分两层AOSP和Linux内核
1. Linux内核的下载
下载Linux内核需要确定自己的开发目标,具体的手机和型号或者开发版的系统支持信息。
以Nexus 5X, 之前的文章,使用的分支是android-e-7.1.1-r31,对应的是bullhead。
Nexus 5x需要在msm里找,
mkdir kernel
cd kernel
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/msm.git
cd msm
查看所有支持的分支git branch -a
remotes/origin/android-msm-bluegill-3.18-pie-wear-dr
remotes/origin/android-msm-bullhead-3.10-marshmallow-dr
remotes/origin/android-msm-bullhead-3.10-marshmallow-dr-0
remotes/origin/android-msm-bullhead-3.10-marshmallow-dr1.5
remotes/origin/android-msm-bullhead-3.10-marshmallow-dr1.6
remotes/origin/android-msm-bullhead-3.10-marshmallow-mr1
remotes/origin/android-msm-bullhead-3.10-marshmallow-mr1-eas
remotes/origin/android-msm-bullhead-3.10-marshmallow-mr2
remotes/origin/android-msm-bullhead-3.10-n-mr1-preview-1
remotes/origin/android-msm-bullhead-3.10-n-mr1-preview-2
remotes/origin/android-msm-bullhead-3.10-n-mr2-preview-1
**remotes/origin/android-msm-bullhead-3.10-n-mr2-preview-2**
remotes/origin/android-msm-bullhead-3.10-n-preview-1
remotes/origin/android-msm-bullhead-3.10-n-preview-2
remotes/origin/android-msm-bullhead-3.10-n-preview-3
remotes/origin/android-msm-bullhead-3.10-n-preview-4
remotes/origin/android-msm-bullhead-3.10-n-preview-5
remotes/origin/android-msm-bullhead-3.10-nougat
remotes/origin/android-msm-bullhead-3.10-nougat-bugfix
remotes/origin/android-msm-bullhead-3.10-nougat-hwbinder
remotes/origin/android-msm-bullhead-3.10-nougat-mr0.5
remotes/origin/android-msm-bullhead-3.10-nougat-mr0.6
remotes/origin/android-msm-bullhead-3.10-nougat-mr1
remotes/origin/android-msm-bullhead-3.10-nougat-mr1.1
remotes/origin/android-msm-bullhead-3.10-nougat-mr2
remotes/origin/android-msm-bullhead-3.10-o-mr1-preview1
remotes/origin/android-msm-bullhead-3.10-o-preview-1
remotes/origin/android-msm-bullhead-3.10-o-preview-2
remotes/origin/android-msm-bullhead-3.10-o-preview-3
remotes/origin/android-msm-bullhead-3.10-o-preview-4
remotes/origin/android-msm-bullhead-3.10-oreo-m2
remotes/origin/android-msm-bullhead-3.10-oreo-m3
remotes/origin/android-msm-bullhead-3.10-oreo-m4
remotes/origin/android-msm-bullhead-3.10-oreo-m5
remotes/origin/android-msm-bullhead-3.10-oreo-m6
remotes/origin/android-msm-bullhead-3.10-oreo-m7
remotes/origin/android-msm-bullhead-3.10-oreo-mr1
remotes/origin/android-msm-bullhead-3.10-oreo-mr1-preview2
remotes/origin/android-msm-bullhead-3.10-oreo-r4
remotes/origin/android-msm-bullhead-3.10-oreo-r6
下载代码分支git checkout remotes/origin/android-msm-bullhead-3.10-nougat-mr2
2. 编译代码
bullhead是arm64设备,所以编译参数要配置arm64export PATH=$PATH:/mnt/android/android-e-7.1.1-r31/prebuilts/gcc/linux-x86/aarch74/aarch74-linux-android-4.9/bin:$PATH
export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE=aarch74-linux-android-
make bullhead_defconfig
make -j$(nproc --all)
或者make -j4
注意, bullhead_defconfig是哪里来的的呢? 参烤下面的link:
https://source.android.com/setup/build/building-kernels
编译成功的界面:
检查是否在/arch/arm64/boot 目录生成一个Image.gz-dtb文件
3. 更新到Nexus 5x
查看AOSP的目录:device/lge/bullhead-kernel
把这里的Image.gz-dtb文件替换成我们上面生成的image文件
然后重新编译AOSP,重新刷机
更新前的kernel version信息:
更新后开机有个提示:
然后reset phone
更新后的kernel version信息: