背景
在Ubuntu18.04中编译小米官方内核K30U的内核,环境配置等。
Redmi K30S Ultra Android Q LA.UM.8.12.r1-10600-sm8250.0 apollo-q-oss
代码下载
aosp@ubuntu:~$ git clone https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b apollo-q-oss --depth=1 Cloning into 'Xiaomi_Kernel_OpenSource'... remote: Enumerating objects: 68787, done. remote: Counting objects: 100% (68787/68787), done. remote: Compressing objects: 100% (63208/63208), done. remote: Total 68787 (delta 5893), reused 43525 (delta 4616), pack-reused 0 Receiving objects: 100% (68787/68787), 186.20 MiB | 10.48 MiB/s, done. Resolving deltas: 100% (5893/5893), done. Checking out files: 100% (64788/64788), done. aosp@ubuntu:~$
查看内核配置文件
aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$ cd arch/arm64/configs/ aosp@ubuntu:~/Xiaomi_Kernel_OpenSource/arch/arm64/configs$ ll total 52 drwxrwxr-x 3 aosp aosp 4096 Sep 2 08:31 ./ drwxrwxr-x 12 aosp aosp 4096 Sep 2 08:31 ../ lrwxrwxrwx 1 aosp aosp 28 Sep 2 08:31 apollo_user_defconfig -> vendor/apollo_user_defconfig -rw-rw-r-- 1 aosp aosp 11759 Sep 2 08:31 cuttlefish_defconfig -rw-rw-r-- 1 aosp aosp 16696 Sep 2 08:31 defconfig -rw-rw-r-- 1 aosp aosp 7579 Sep 2 08:31 ranchu64_defconfig drwxrwxr-x 2 aosp aosp 4096 Sep 2 08:31 vendor/ aosp@ubuntu:~/Xiaomi_Kernel_OpenSource/arch/arm64/configs$ cd vendor/ aosp@ubuntu:~/Xiaomi_Kernel_OpenSource/arch/arm64/configs/vendor$ ll total 108 drwxrwxr-x 2 aosp aosp 4096 Sep 2 08:31 ./ drwxrwxr-x 3 aosp aosp 4096 Sep 2 08:31 ../ -rw-rw-r-- 1 aosp aosp 18629 Sep 2 08:31 apollo_user_defconfig -rw-rw-r-- 1 aosp aosp 19847 Sep 2 08:31 kona_defconfig -rw-rw-r-- 1 aosp aosp 17450 Sep 2 08:31 kona-perf_defconfig -rw-rw-r-- 1 aosp aosp 19215 Sep 2 08:31 lito_defconfig -rw-rw-r-- 1 aosp aosp 17376 Sep 2 08:31 lito-perf_defconfig aosp@ubuntu:~/Xiaomi_Kernel_OpenSource/arch/arm64/configs/vendor$
这里找到我们编译的内核配置文件是apollo_user_defconfig
环境
clang环境
aosp@ubuntu:~$ clang --version Android (6443078 based on r383902) clang version 11.0.1 (https://android.googlesource.com/toolchain/llvm-project b397f81060ce6d701042b782172ed13bee898b79) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/aosp/clang/bin aosp@ubuntu:~$
sudo apt-get install libncurses5-dev libncurses-dev libssl-dev device-tree-compiler bc cpio lib32ncurses5-dev lib32z1 build-essential binutils bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev git
上面是基础环境。直接安装,遇到选择y的就输入y,回车。
cd ~ git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9 aarch64-linux-android-4.9 --depth=1 git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9 arm-linux-androideabi-4.9 --depth=1
下载好编译工具。clang工具也下载好,放同目录。
sudo chmod -R 777 clang cd clang/bin export PATH=$(pwd):$PATH
开始编译
在k30u的内核目录中执行以下命令开始生成配置文件。
aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$ make -j$(nproc) -C $(pwd) O=$(pwd)/out CROSS_COMPILE=$HOME/aarch64-linux-android-4.9/bin/aarch64-linux-android- CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=$HOME/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- ARCH=arm64 SUBARCH=arm64 LLVM=1 CC=clang apollo_user_defconfig make: Entering directory '/home/aosp/Xiaomi_Kernel_OpenSource' make[1]: Entering directory '/home/aosp/Xiaomi_Kernel_OpenSource/out' HOSTCC scripts/basic/fixdep GEN ./Makefile HOSTCC scripts/kconfig/conf.o YACC scripts/kconfig/zconf.tab.c LEX scripts/kconfig/zconf.lex.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf drivers/misc/Kconfig:578:warning: config symbol defined without type drivers/misc/Kconfig:583:warning: config symbol defined without type drivers/misc/Kconfig:616:warning: config symbol defined without type # # configuration written to .config # make[1]: Leaving directory '/home/aosp/Xiaomi_Kernel_OpenSource/out' make: Leaving directory '/home/aosp/Xiaomi_Kernel_OpenSource' aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$
成功之后开始编译内核:
aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$ make -j$(nproc) -C $(pwd) O=$(pwd)/out CROSS_COMPILE=$HOME/aarch64-linux-android-4.9/bin/aarch64-linux-android- CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=$HOME/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- ARCH=arm64 SUBARCH=arm64 CC=clang LLVM=1 make: Entering directory '/home/aosp/Xiaomi_Kernel_OpenSource' make[1]: Entering directory '/home/aosp/Xiaomi_Kernel_OpenSource/out' GEN ./Makefile WRAP arch/arm64/include/generated/uapi/asm/errno.h WRAP arch/arm64/include/generated/uapi/asm/ioctl.h WRAP arch/arm64/include/generated/uapi/asm/ipcbuf.h WRAP arch/arm64/include/generated/uapi/asm/kvm_para.h WRAP arch/arm64/include/generated/uapi/asm/mman.h WRAP arch/arm64/include/generated/uapi/asm/msgbuf.h .... CC net/bridge/br_netfilter.mod.o LD [M] drivers/media/platform/msm/broadcast/tspp.ko LD [M] drivers/media/platform/msm/dvb/adapter/mpq-adapter.ko LD [M] drivers/video/backlight/lcd.ko LD [M] drivers/media/usb/gspca/gspca_main.ko LD [M] drivers/char/rdbg.ko LD [M] drivers/media/platform/msm/dvb/demux/mpq-dmx-hw-plugin.ko LD [M] net/bridge/br_netfilter.ko LD [M] drivers/soc/qcom/llcc_perfmon.ko make[1]: Leaving directory '/home/aosp/Xiaomi_Kernel_OpenSource/out' make: Leaving directory '/home/aosp/Xiaomi_Kernel_OpenSource' aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$
大概十分钟这样编译完成。
aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$ ls out/ arch/ ipc/ security/ .tmp_vmlinux1 block/ kernel/ sound/ .tmp_vmlinux2 built-in.a lib/ source/ usr/ certs/ Makefile System.map .version .config .missing-syscalls.d techpack/ virt/ crypto/ mm/ .tmp_kallsyms1.o vmlinux drivers/ modules.builtin .tmp_kallsyms1.S .vmlinux.cmd firmware/ modules.order .tmp_kallsyms2.o vmlinux.o fs/ Module.symvers .tmp_kallsyms2.S include/ net/ .tmp_System.map init/ scripts/ .tmp_versions/ aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$ ls out/arch/arm64/boot/ dts Image aosp@ubuntu:~/Xiaomi_Kernel_OpenSource$ aosp@ubuntu:~/Xiaomi_Kernel_OpenSource/out/arch/arm64/boot$ ls -l total 34952 drwxrwxr-x 29 aosp aosp 4096 Sep 2 08:38 dts -rw-rw-r-- 1 aosp aosp 37941260 Sep 2 08:42 Image aosp@ubuntu:~/Xiaomi_Kernel_OpenSource/out/arch/arm64/boot$
在out/arch/arm64/boot/目录下有Image文件,这个文件重新使用magiskbook重新打包就可以生成boot.img了。
通过临时启动内核方式刷入,验证是否正常,如果正常就flash进去。
审核编辑:刘清
-
ARM
+关注
关注
134文章
9084浏览量
367384 -
FlaSh
+关注
关注
10文章
1633浏览量
147940 -
Ubuntu系统
+关注
关注
0文章
91浏览量
3927
原文标题:Ubuntu18.04编译小米官方K30U内核
文章出处:【微信号:哆啦安全,微信公众号:哆啦安全】欢迎添加关注!文章转载请注明出处。
发布评论请先 登录
相关推荐
评论