天天看點

記錄AOSP源碼編譯刷機(pixel 4a)查找pixel 4a所對應的branch分支國内使用清華鏡像,下載下傳aosp代碼通過上面表格中的build ID,找到driver并下載下傳開始編譯編譯成功之後,打包img檔案刷機

查找pixel 4a所對應的branch分支

我選擇了第二行,其更新檔級别也是比較新的。

build ID 标記 版本 支援的裝置 安全更新檔程式級别
RQ2A.210505.003 android-11.0.0_r37 Android11 Pixel 4a (5G)、Pixel 5 2021-05-05
RQ2A.210505.002 android-11.0.0_r36 Android11 Pixel 3、Pixel 3a、Pixel 3a XL、Pixel 3 XL、Pixel 4、Pixel 4a、Pixel 4 XL 2021-05-05
RQ2A.210405.006 android-11.0.0_r35 Android11 Pixel 3、Pixel 3 XL 2021-04-05
RQ2A.210405.005 android-11.0.0_r34 Android11 Pixel 3、Pixel 3a、Pixel 3a XL、Pixel 3 XL、Pixel 4、Pixel 4a、Pixel 4a (5G)、Pixel 4 XL、Pixel 5 2021-04-05
RQ2A.210305.007 android-11.0.0_r33 Android11 Pixel 4a、Pixel 4a (5G)、Pixel 5 2021-03-05
RQ2A.210305.006 android-11.0.0_r32 Android11 Pixel 3、Pixel 3 XL、Pixel 3a、Pixel 3a XL、Pixel 4、Pixel 4 XL、Pixel 4a、Pixel 4a (5G)、Pixel 5 2021-03-05
RQ1D.210205.004 android-11.0.0_r31 Android11 Pixel 3、Pixel 3 XL、Pixel 4a (5G)、Pixel 5 2021-02-05
RQ1C.210205.006 android-11.0.0_r30 Android11 Pixel 4a (5G)、Pixel 5 2021-02-05
RQ1A.210205.004 android-11.0.0_r29 Android11 Pixel 3、Pixel 3a、Pixel 3a XL、Pixel 3 XL、Pixel 4、Pixel 4a、Pixel 4a (5G)、Pixel 4 XL、Pixel 5 2021-02-05
RQ1D.210105.003 android-11.0.0_r28 Android11 Pixel 3、Pixel 3 XL、Pixel 4a (5G)、Pixel 5 2021-01-05
RQ1A.210105.003 android-11.0.0_r27 Android11 Pixel 3、Pixel 3 XL、Pixel 4、Pixel 4a (5G)、Pixel 4 XL、Pixel 5 2021-01-05
RQ1A.210105.002 android-11.0.0_r26 Android11 Pixel 3a、Pixel 3a XL、Pixel 4a 2021-01-05
RP1A.201005.004.A1 android-11.0.0_r25 Android11 Pixel 2、Pixel 2 XL 2020-10-05
RQ1D.201205.012.A1 android-11.0.0_r24 Android11 Pixel 5、Pixel 4a (5G) 2020-12-05
RQ1A.201205.003.A1 android-11.0.0_r23 Android11 Pixel 3、Pixel 3 XL 2020-12-05
RQ1A.201205.011 android-11.0.0_r22 Android11 Pixel 5、Pixel 4a (5G) 2020-12-05
RQ1A.201205.008.A1 android-11.0.0_r21 Android11 Pixel 4、Pixel 4 XL 2020-12-05
RQ1A.201205.010 android-11.0.0_r20 Android11 Pixel 5、Pixel 4a (5G) 2020-12-05
RQ1A.201205.008 android-11.0.0_r19 Android11 Pixel 4a、Pixel 4、Pixel 4 XL 2020-12-05
RQ1A.201205.003 android-11.0.0_r18 Android11 Pixel 3a、Pixel 3a XL、Pixel 3 XL、Pixel 3 2020-12-05
RP1A.201105.002 android-11.0.0_r17 Android11 Pixel 3、Pixel 3a、Pixel 3a XL、Pixel 3 XL、Pixel 4、Pixel 4a、Pixel 4 XL 2020-11-05
RD1B.201105.010 android-11.0.0_r16 Android11 Pixel 4a (5G)、Pixel 5 2020-11-05
RD1A.201105.003.C1 android-11.0.0_r15 Android11 Pixel 4a (5G)、Pixel 5 2020-11-05
RD1A.201105.003.B1 android-11.0.0_r14 Android11 Pixel 4a (5G)、Pixel 5 2020-11-05
RD1A.201105.003.A1 android-11.0.0_r13 Android11 Pixel 4a (5G)、Pixel 5 2020-11-05
RD1A.201105.003 android-11.0.0_r12 Android11 Pixel 4a (5G)、Pixel 5 2020-11-05
RD1A.200810.022.A4 android-11.0.0_r11 Android11 Pixel 4a (5G)、Pixel 5 2020-10-05
RD1A.200810.021.B3 android-11.0.0_r10 Android11 Pixel 4a (5G)、Pixel 5 2020-10-05
RD1A.200810.020.A1 android-11.0.0_r9 Android11 Pixel 5 2020-10-05
RD1A.200810.021.A1 android-11.0.0_r8 Android11 Pixel 4a (5G)、Pixel 5 2020-10-05
RD1A.200810.020 android-11.0.0_r7 Android11 Pixel 4a (5G)、Pixel 5 2020-10-05
RP1A.201005.006 android-11.0.0_r5 Android11 Pixel 4a 2020-10-05

國内使用清華鏡像,下載下傳aosp代碼

使用清華的repo

下載下傳
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
為了友善可以将其拷貝到你的PATH裡。

更新
repo的運作過程中會嘗試通路官方的git源更新自己,如果想使用tuna的鏡像源進行更新,可以将如下内容複制到你的~/.bashrc裡

export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
并重新開機終端模拟器。
           

把新鮮的包下載下傳下來

wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下載下傳初始化包
tar xf aosp-latest.tar
cd AOSP   # 解壓得到的 AOSP 工程目錄
           

初始化分支

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r37 --no-clone-bundle --depth=1
           

開始同步代碼

repo sync --jobs=4 --current-branch --no-clone-bundle
           

通過上面表格中的build ID,找到driver并下載下傳

Pixel 4a binaries for Android 11.0.0 (RQ2A.210505.002)

Hardware Component Company Download SHA-256 Checksum
Vendor image Google Link 58017c1857198d3a6dfdcba24579fb3f1c30611815017f3de22e856b5d71e6ce
GPS, Audio, Camera, Gestures, Graphics, DRM, Video, Sensors Qualcomm Link 40ff31bce2bc2d2afa9b0b7a2f6ad0742eaca6ac28090b4b6ddbdcb9343769bc

把這兩個元件都下載下傳下來解壓,其實是兩個sh腳本,放到aosp下載下傳的源碼根目錄

[email protected]:/data00/home/admin/work/aosp_sunfish$ ls -al *.sh
-rwxr-x--x 1 admin admin 274738793 Jun  4 08:59 extract-google_devices-sunfish.sh
-rwxr-x--x 1 admin admin    743011 Jun  4 09:00 extract-qcom-sunfish.sh
           

運作這兩個dirver shell腳本,一直回車,因為太長可以直接ctrl+c,然後輸入I ACCEPT回車就行了

[email protected]:/data00/home/admin/work/aosp_sunfish$ extract-qcom-sunfish.sh
The license for this software will now be displayed.
You must agree to this license before using this software.

Press Enter to view the license

THIS DEVELOPER SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") IS A LEGALLY
BINDING AGREEMENT BETWEEN Qualcomm Technologies, Inc. ("LICENSOR") AND
YOU OR THE LEGAL ENTITY YOU REPRESENT ("You" or its possessive, "Your"). BY
TYPING "I ACCEPT" WHERE INDICATED YOU ACKNOWLEDGE THAT YOU HAVE READ THIS
AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS.
IF YOU DO NOT AGREE TO THESE TERMS YOU MUST DISCONTINUE THE INSTALLATION
PROCESS AND YOU SHALL NOT USE THE SOFTWARE OR RETAIN ANY COPIES OF THE
SOFTWARE OR DOCUMENTATION. ANY USE OR POSSESSION OF THE SOFTWARE BY YOU IS
SUBJECT TO THE TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF THE
SOFTWARE IS INSTALLED ON A COMPUTER OWNED BY A CORPORATION OR OTHER LEGAL
ENTITY, THEN YOU REPRESENT AND WARRANT THAT YOU HAVE THE AUTHORITY TO BIND
SUCH ENTITY TO THE TERMS AND CONDITIONS OF THIS AGREEMENT.

   1.  Special Definitions

      a.  The term "Android" means the open source mobile platform, software
          stack, operating system, middleware, application programming
          interfaces and mobile applications under the trade-name "Android"
          distributed at Android.com.

      b.  The term "Android Applications" means a software application or
          open-source contribution developed by You, designed to operate with
          Android that does not contain or incorporate any of the Software.

      c.  The term "Authorized Android Enabled Device" means only the device
          identified on the site from which You downloaded the Software.
          The term "Software" means the Licensor's proprietary software and
          libraries in object code form, designed for use on the Authorized
          Android Enabled Device.

      d.  The term "Authorized Android Enabled Device Software" means a
          packaged build for Authorized Android Enabled Devices, consisting
          of files suitable for installation on an Authorized Android Enabled
          Device using a mechanism such as fastboot mode or recovery mode.

   2.  License Grant

      a.  Subject to the terms of this Agreement, Licensor hereby grants to
          You, free of charge, a non-exclusive, non-sublicensable,
          non-transferable, limited copyright license, during the term of
          this Agreement, to download, install and use the Software
          internally in machine-readable (i.e., object code) form and the
          Documentation for non-commercial use on an Authorized Android
          Enabled Device and non-commercial redistribution for academic
          purposes only of a reasonable number of copies of the Authorized
          Android Enabled Device Software (the "Limited Purpose"). You may
          grant your end users the right to use the Software for
          non-commercial purposes on an Authorized Android Enabled Device.
          The license to the Software granted to You hereunder is solely for
          the Limited Purpose set forth in this section, and the Software
          shall not be used for any other purpose.

   3.  Restrictions

      a.  Retention of Rights. The entire right, title and interest in the

Type "I ACCEPT" if you agree to the terms of the license: I ACCEPT

vendor/
vendor/qcom/
vendor/qcom/sunfish/
vendor/qcom/sunfish/LICENSE
vendor/qcom/sunfish/BoardConfigPartial.mk
vendor/qcom/sunfish/proprietary/
vendor/qcom/sunfish/proprietary/libimsmedia_jni.so
vendor/qcom/sunfish/proprietary/ims.apk
vendor/qcom/sunfish/proprietary/lib64/
vendor/qcom/sunfish/proprietary/lib64/libimsmedia_jni.so
vendor/qcom/sunfish/proprietary/Android.bp
vendor/qcom/sunfish/proprietary/qti-telephony-hidl-wrapper.jar
vendor/qcom/sunfish/proprietary/QtiTelephonyService.apk
vendor/qcom/sunfish/proprietary/com.qualcomm.qcrilmsgtunnel.xml
vendor/qcom/sunfish/proprietary/qti_telephony_utils.xml
vendor/qcom/sunfish/proprietary/qti-telephony-utils.jar
vendor/qcom/sunfish/proprietary/qti_telephony_hidl_wrapper.xml
vendor/qcom/sunfish/proprietary/qcrilhook.xml
vendor/qcom/sunfish/proprietary/qcrilhook.jar
vendor/qcom/sunfish/proprietary/org_codeaurora_ims.xml
vendor/qcom/sunfish/proprietary/qcrilmsgtunnel.apk
vendor/qcom/sunfish/proprietary/Android.mk
vendor/qcom/sunfish/device-partial.mk
vendor/google_devices/
vendor/google_devices/sunfish/
vendor/google_devices/sunfish/android-info.txt
vendor/google_devices/sunfish/proprietary/
vendor/google_devices/sunfish/proprietary/BoardConfigVendor.mk
vendor/google_devices/sunfish/proprietary/device-vendor.mk

Files extracted successfully.
           

開始編譯

1. source build/envsetup.sh
2. lunch
You're building on Linux

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_blueline-userdebug
     4. aosp_blueline_car-userdebug
     5. aosp_bonito-userdebug
     6. aosp_bonito_car-userdebug
     7. aosp_bramble-userdebug
     8. aosp_car_arm-userdebug
     9. aosp_car_arm64-userdebug
     10. aosp_car_x86-userdebug
     11. aosp_car_x86_64-userdebug
     12. aosp_cf_arm64_auto-userdebug
     13. aosp_cf_arm64_phone-userdebug
     14. aosp_cf_x86_64_phone-userdebug
     15. aosp_cf_x86_auto-userdebug
     16. aosp_cf_x86_phone-userdebug
     17. aosp_cf_x86_tv-userdebug
     18. aosp_coral-userdebug
     19. aosp_coral_car-userdebug
     20. aosp_crosshatch-userdebug
     21. aosp_crosshatch_car-userdebug
     22. aosp_flame-userdebug
     23. aosp_flame_car-userdebug
     24. aosp_redfin-userdebug
     25. aosp_sargo-userdebug
     26. aosp_sunfish-userdebug
     27. aosp_trout_arm64-userdebug
     28. aosp_trout_x86-userdebug
     29. aosp_x86-eng
     30. aosp_x86_64-eng
     31. arm_krait-eng
     32. arm_v7_v8-eng
     33. armv8-eng
     34. armv8_kryo385-eng
     35. beagle_x15-userdebug
     36. beagle_x15_auto-userdebug
     37. car_x86_64-userdebug
     38. db845c-userdebug
     39. fuchsia_arm64-eng
     40. fuchsia_x86_64-eng
     41. hikey-userdebug
     42. hikey64_only-userdebug
     43. hikey960-userdebug
     44. hikey960_tv-userdebug
     45. hikey_tv-userdebug
     46. pixel3_mainline-userdebug
     47. poplar-eng
     48. poplar-user
     49. poplar-userdebug
     50. qemu_trusty_arm64-userdebug
     51. silvermont-eng
     52. uml-userdebug
     53. yukawa-userdebug
     54. yukawa_sei510-userdebug

Which would you like? [aosp_arm-eng] 26
3. make -j8
           

lunch的時候,選擇了26 sunfish(pixel 4a的代号)

編譯成功之後,打包img檔案

admin$aosp$ cd out/target/product/sunfish/
admin$sunfish$ ls *.img
boot-debug.img  bootloader.img  dtbo.img     radio.img          ramdisk.img           super_empty.img  system.img        userdata.img  vbmeta_system.img
boot.img        dtb.img         product.img  ramdisk-debug.img  ramdisk-recovery.img  system_ext.img   system_other.img  vbmeta.img    vendor.img
           
admin$sunfish$ tar -zcvf sunfish-11.tar.gz *.img
           

刷機

scp傳到本機Mac

解壓gzip檔案

tar -zxvf sunfish-11.tar.gz
           

添加ANDROID_PRODUCT_OUT環境變量

export ANDROID_PRODUCT_OUT=/Users/admin/tmp/ROM
           

使用fastboot開刷

[email protected] ROM % fastboot flashall -w
--------------------------------------------
Bootloader Version...: s5-0.3-6835615
Baseband Version.....: g7150-00023-201008-B-6891498
Serial Number........: 0A021JEC204265
--------------------------------------------
Checking 'product'                                 OKAY [  0.068s]
Setting current slot to 'b'                        OKAY [  0.155s]
Sending 'boot_b' (65536 KB)                        OKAY [  0.430s]
Writing 'boot_b'                                   OKAY [  0.295s]
Sending 'dtbo_b' (8192 KB)                         OKAY [  0.160s]
Writing 'dtbo_b'                                   OKAY [  0.094s]
Sending 'vbmeta_b' (8 KB)                          OKAY [  0.140s]
Writing 'vbmeta_b'                                 OKAY [  0.077s]
Sending 'vbmeta_system_b' (4 KB)                   OKAY [  0.140s]
Writing 'vbmeta_system_b'                          OKAY [  0.077s]
Rebooting into fastboot                            OKAY [  0.070s]
< waiting for any device >

Sending 'super' (4 KB)                             OKAY [  0.001s]
Updating super partition                           OKAY [  0.011s]
Resizing 'product_b'                               OKAY [  0.004s]
Resizing 'system_b'                                OKAY [  0.005s]
Resizing 'system_ext_b'                            OKAY [  0.004s]
Resizing 'system_a'                                OKAY [  0.005s]
Resizing 'vendor_b'                                OKAY [  0.004s]
Resizing 'vendor_a'                                OKAY [  0.004s]
Resizing 'product_b'                               OKAY [  0.004s]
Sending 'product_b' (233992 KB)                    OKAY [  1.194s]
Writing 'product_b'                                OKAY [  1.825s]
Resizing 'system_b'                                OKAY [  0.005s]
Sending sparse 'system_b' 1/4 (262140 KB)          OKAY [  1.350s]
Writing 'system_b'                                 OKAY [  1.935s]
Sending sparse 'system_b' 2/4 (262140 KB)          OKAY [  1.341s]
Writing 'system_b'                                 OKAY [  0.898s]
Sending sparse 'system_b' 3/4 (262140 KB)          OKAY [  1.341s]
Writing 'system_b'                                 OKAY [  0.899s]
Sending sparse 'system_b' 4/4 (73812 KB)           OKAY [  0.364s]
Writing 'system_b'                                 OKAY [  0.312s]
Resizing 'system_ext_b'                            OKAY [  0.005s]
Sending 'system_ext_b' (106640 KB)                 OKAY [  0.550s]
Writing 'system_ext_b'                             OKAY [  1.434s]
Resizing 'system_a'                                OKAY [  0.005s]
Sending 'system_a' (23844 KB)                      OKAY [  0.123s]
Writing 'system_a'                                 OKAY [  0.117s]
Resizing 'vendor_b'                                OKAY [  0.005s]
Sending sparse 'vendor_b' 1/3 (262140 KB)          OKAY [  1.352s]
Writing 'vendor_b'                                 OKAY [  1.928s]
Sending sparse 'vendor_b' 2/3 (262140 KB)          OKAY [  1.349s]
Writing 'vendor_b'                                 OKAY [  0.885s]
Sending sparse 'vendor_b' 3/3 (27864 KB)           OKAY [  0.145s]
Writing 'vendor_b'                                 OKAY [  0.148s]
Erasing 'userdata'                                 OKAY [  8.343s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata'                                 OKAY [  0.012s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting                                          OKAY [  0.000s]
Finished. Total time: 46.249s