背景
在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文章
9056瀏覽量
366846 -
FlaSh
+關注
關注
10文章
1622瀏覽量
147767 -
Ubuntu系統
+關注
關注
0文章
85瀏覽量
3912
原文標題:Ubuntu18.04編譯小米官方K30U內核
文章出處:【微信號:哆啦安全,微信公眾號:哆啦安全】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論