androidS 發布已經有一段時間了,作為一名搞機人,咱也不能落后,今天就來開盤 12 代碼,
下載這個 S 代碼前前后后搞了快一個月,哈哈我不愧是樹懶本懶,唉,其實是中間遇到了不少問題,
環境都搞廢了,還得重裝系統,今天就來總結一下吧,
編譯環境
1、Ubuntu16.04.5 系統
2、三星500G SSD EVO系列
3、記憶體8G,cpu 4核,I5(8年老本了湊合著用用)
4、二手 Pixel 3 XL一臺
坑位集錦
1、磁盤大小
如果你是在虛擬機來盤這套代碼的話,磁盤大小至少200G以上(血淚教訓),中間擴容了三次最侄訓是不夠大
僅僅 repo 檔案夾就有 70G 左右
磁盤空間一定要大,一定要大,一定要大
不是虛擬機的請忽略這步
2、Python 版本要求
這次下載 aosp 的 S 代碼時,repo init 就出現了問題,提示要求 Python 版本 3.6 以上
在這也是費了好長時間才解決這個問題,具體可參考 Linux python升級
從官網下載最新版本 Python-3.9.8 解壓,解壓完成后先不要著急 make install
還有個小坑,會報
ModuleNotFoundError: No module named ‘_ctypes’ 這個錯誤
以及 ModuleNotFoundError: No module named ‘_ssl’ 這個錯誤
解決辦法,執行如下兩條指令
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev
成功后,再參考 python3虛擬環境中解決 ModuleNotFoundError: No module named ‘_ssl’
修改原始碼 vim Modules/Setup
取消 _socket socketmodule.c 和下面的 SLL 注釋
然后執行 make install 安裝重新配置環境變數,
3、HTTP SSL 證書問題
執行 git config --global http.sslverify false 關閉
cczheng@ubantu:~/google$ cd Android12/
cczheng@ubantu:~/google/Android12$ export REPO_URL='https://gerrit-googlesource.proxy.ustclug.org/git-repo'
cczheng@ubantu:~/google/Android12$ repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-12.0.0_r3
Downloading Repo source from https://gerrit-googlesource.proxy.ustclug.org/git-repo
fatal: unable to access 'https://gerrit-googlesource.proxy.ustclug.org/git-repo/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
repo: error: "git" failed with exit status 128
cwd: /home/cczheng/google/Android12/.repo/repo
cmd: ['git', 'fetch', '--quiet', '--progress', 'origin', '+refs/heads/*:refs/remotes/origin/*', '+refs/tags/*:refs/tags/*']
fatal: cloning the git-repo repository failed, will remove '.repo/repo'
cczheng@ubantu:~/google/Android12$ git config --global http.sslverify false
cczheng@ubantu:~/google/Android12$ repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-12.0.0_r3
Downloading Repo source from https://gerrit-googlesource.proxy.ustclug.org/git-repo
... A new version of repo (2.17) is available.
... You should upgrade soon:
cp /home/cczheng/google/Android12/.repo/repo/repo /home/cczheng/bin/repo
Downloading manifest from git://mirrors.ustc.edu.cn/aosp/platform/manifest
remote: Enumerating objects: 92903, done.
remote: Counting objects: 100% (92903/92903), done.
remote: Compressing objects: 100% (41747/41747), done.
remote: Total 92903 (delta 31091), reused 92896 (delta 31088)
Your identity is: yangtao <yangtao@innovatech.net.cn>
If you want to change this, please re-run 'repo init' with --config-name
repo has been initialized in /home/cczheng/google/Android12
做完這些步驟后,repo init 終于可以成功了,
準備作業
1、設定 git 賬戶
git config --global user.email "xxxxxxx@gmail.com"
git config --global user.name "xxxxx"
2、配置PATH環境變數
mkdir ~/bin
echo "PATH=~/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc
3、安裝 curl 庫,并設定權限
sudo apt-get install curl
curl -sSL 'https://gerrit-googlesource.proxy.ustclug.org/git-repo/+/master/repo?format=TEXT' |base64 -d > ~/bin/repo
chmod a+x ~/bin/repo
下載原始碼
1、建立作業目錄
mkdir Android12
cd Android12
2、添加科大鏡像源
export REPO_URL='https://gerrit-googlesource.proxy.ustclug.org/git-repo'
3、初始化倉庫,并指定要下載android版本
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-12.0.0_r3
4、同步原始碼
repo sync -j4
編譯原始碼
1、安裝 openjdk8
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
如果電腦里面存在多個java 版本,則通過如下命令選擇openjdk-8即可
sudo update-alternative --config java
sudo update-alternative --config javac
2、安裝依賴庫
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
sudo apt-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install lib32z-dev ccache
sudo apt-get install libssl-dev
3、下載對應閉源驅動檔案合入原始碼
可以到下面的地址下載 pixel 對應驅動檔案或者完整 rom 包
Google play 中文站
4、開始編譯
通過 lscpu 命令查看當前cpu的詳細資訊

執行命令
source build/envsetup.sh
lunch 25 (aosp_crosshatch-userdebug 版本)
make -j8
lunch 根據上面cpu的型別,make -j cpu核數*2
編譯完成23小時,哈哈哈哈哈哈
刷機,參考官方包自己寫個刷機腳本,將你編譯后out目錄下得到的如下檔案
copy出來,全部添加到壓縮檔案 aosp12.zip
然后依次執行
adb reboot fastboot
fastboot -w update .\aosp12.zip
fastboot reboot
PS H:\rom12\aosp12> adb reboot fastboot
PS H:\rom12\aosp12> fastboot -w update .\aosp12.zip
--------------------------------------------
Bootloader Version...: b1c1-0.4-7617406
Baseband Version.....: g845-00194-210812-B-7635520
Serial Number........: 89BY05MBQ
--------------------------------------------
extracting android-info.txt (0 MB) to RAM...
Checking 'product' OKAY [ 0.001s]
Setting current slot to 'b' OKAY [ 0.035s]
extracting boot.img (64 MB) to disk... took 0.317s
archive does not contain 'boot.sig'
Sending 'boot_b' (65536 KB) OKAY [ 2.063s]
Writing 'boot_b' OKAY [ 0.393s]
extracting dtbo.img (8 MB) to disk... took 0.048s
archive does not contain 'dtbo.sig'
Sending 'dtbo_b' (8192 KB) OKAY [ 0.257s]
Writing 'dtbo_b' OKAY [ 0.066s]
archive does not contain 'dt.img'
archive does not contain 'recovery.img'
extracting vbmeta.img (0 MB) to disk... took 0.004s
archive does not contain 'vbmeta.sig'
Sending 'vbmeta_b' (8 KB) OKAY [ 0.001s]
Writing 'vbmeta_b' OKAY [ 0.003s]
archive does not contain 'vbmeta_system.img'
archive does not contain 'vendor_boot.img'
extracting super_empty.img (0 MB) to disk... took 0.004s
Sending 'system_b' (4 KB) OKAY [ 0.001s]
Updating super partition OKAY [ 0.006s]
Resizing 'product_b' OKAY [ 0.006s]
Resizing 'system_b' OKAY [ 0.006s]
Resizing 'system_ext_b' OKAY [ 0.006s]
Resizing 'vendor_b' OKAY [ 0.006s]
archive does not contain 'boot_other.img'
archive does not contain 'odm.img'
extracting product.img (261 MB) to disk... took 2.240s
archive does not contain 'product.sig'
Resizing 'product_b' OKAY [ 0.006s]
Sending sparse 'product_b' 1/2 (262140 KB) OKAY [ 8.237s]
Writing 'product_b' OKAY [ 1.592s]
Sending sparse 'product_b' 2/2 (6092 KB) OKAY [ 0.210s]
Writing 'product_b' OKAY [ 0.086s]
extracting system.img (795 MB) to disk... took 6.101s
archive does not contain 'system.sig'
Resizing 'system_b' OKAY [ 0.006s]
Sending sparse 'system_b' 1/4 (262140 KB) OKAY [ 8.247s]
Writing 'system_b' OKAY [ 1.634s]
Sending sparse 'system_b' 2/4 (262140 KB) OKAY [ 8.788s]
Writing 'system_b' OKAY [ 1.685s]
Sending sparse 'system_b' 3/4 (262140 KB) OKAY [ 8.642s]
Writing 'system_b' OKAY [ 1.632s]
Sending sparse 'system_b' 4/4 (27832 KB) OKAY [ 0.935s]
Writing 'system_b' OKAY [ 0.199s]
extracting system_ext.img (123 MB) to disk... took 0.779s
archive does not contain 'system_ext.sig'
Resizing 'system_ext_b' OKAY [ 0.004s]
Sending 'system_ext_b' (126872 KB) OKAY [ 3.976s]
Writing 'system_ext_b' OKAY [ 0.826s]
extracting system_other.img (66 MB) to disk... took 0.402s
archive does not contain 'system.sig'
Sending 'system_a' (68120 KB) OKAY [ 2.129s]
Writing 'system_a' OKAY [ 0.410s]
extracting vendor.img (461 MB) to disk... took 3.112s
archive does not contain 'vendor.sig'
Resizing 'vendor_b' OKAY [ 0.006s]
Sending sparse 'vendor_b' 1/2 (262140 KB) OKAY [ 8.233s]
Writing 'vendor_b' OKAY [ 1.651s]
Sending sparse 'vendor_b' 2/2 (210424 KB) OKAY [ 7.042s]
Writing 'vendor_b' OKAY [ 1.296s]
archive does not contain 'vendor_dlkm.img'
archive does not contain 'vendor_other.img'
Erasing 'userdata' OKAY [ 5.861s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata' OKAY [ 0.111s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting OKAY [ 0.000s]
Finished. Total time: 89.950s
PS H:\rom12\aosp12>
刷機結束,重啟開始搞機啦,
Android 系統開發系列(1):Android 12 源代碼下載、編譯和刷機
Android系統編譯之AOSP刷機
在谷歌云上高速編譯安卓AOSP ROM、驅動、內核并完成刷機
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/396235.html
標籤:其他
