Build AOSP: Pixel 5 (redfin) with Android 13

Environment

Download AOSP source code

Follow official tutorial and choose a tag.

I choose tag android-13.0.0_r67 for my Pixel 5, and the correspoding build ID is TQ3A.230805.001

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More β†’

  1. Create a folder for AOSP source code
mkdir ~/aosp && cd ~/aosp
  1. Init with tag android-13.0.0_r67
repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r67
  1. Sync
repo sync -j8

Download driver binaries

  1. Download driver binaries according to the AOSP source code build ID and tag. I download binaries with build ID TQ3A.230805.001 for my Pixel 5 according to the tag android-13.0.0_r67.
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More β†’
wget https://dl.google.com/dl/android/aosp/google_devices-redfin-tq3a.230805.001.a2-59031497.tgz
wget https://dl.google.com/dl/android/aosp/qcom-redfin-tq3a.230805.001.a2-94c5e420.tgz
  1. Unzip to your AOSP source code folder
tar xvfz google_devices-redfin-tq3a.230805.001.a2-59031497.tgz
tar xvfz qcom-redfin-tq3a.230805.001.a2-94c5e420.tgz
  1. Run script
source extract-google_devices-redfin.sh
source extract-qcom-redfin.sh

Build AOSP

Follow official tutorial

  1. Setup
source build/envsetup.sh
  1. Choose a target to lunch. I choose aosp_redfin-userdebug for my Pixel 5.
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More β†’
lunch aosp_redfin-userdebug
  1. Enable compile_commands.json, which let you efficiently trace C/C++ code with VS code installed with clangd extension
export SOONG_GEN_COMPDB=1
export SOONG_GEN_COMPDB_DEBUG=1
  1. Build all images
m -j8 2>&1 | tee build_aosp_redfin_userdebug.log

Unlock phone

Follow official tutorail

  1. Enable OEM unlocking and USB debugging in Developer options

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More β†’

  2. Reboot to bootloader

adb reboot bootloader

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More β†’

  1. Unlock
fastboot flashing unlock

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More β†’

  1. Flash (Note: fastboot will flash img in $ANDROID_PRODUCT_OUT folder to your phone)
fastboot flashall -w
  1. Boot to Android homescreen
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More β†’

Troubleshooting

If your Pixel phone is bricked, using physical button to force reboot your phone to bootloader, and flash factory img with official tool.

Reference

  1. https://c55jeremy-tech.blogspot.com/2019/04/aosppixel-2-romrom.html
  2. https://zhuanlan.zhihu.com/p/574856795
  3. https://source.android.com/docs/automotive/start/pixelxl

Develop AOSP: Bluetooth

Bluetooth Repository

packages/modules/Bluetooth/

Tools

Develope flow

  1. Modify code
  2. Build Bluetooth package and dependency
mmma packages/modules/Bluetooth/ -j8 2>&1 | tee build_bt.log
  1. According to TEST_MAPPING file, use Atest to run instrumentation test, unit test or GTest
  • Instrumentation test
atest BluetoothInstrumentationTests -v 2>&1 | tee BluetoothInstrumentationTests.log
  • GTest
atest bluetooth_le_audio_client_test -v 2>&1 | tee bluetooth_le_audio_client_test.log
  1. Manual test: replace Bluetooth apex and manually verify your change
adb root
adb remount
adb install out/target/product/redfin/system/apex/com.android.btservices.apex
adb reboot
  1. Submit patches

Develop & Debug skill

export SOONG_GEN_COMPDB=1
export SOONG_GEN_COMPDB_DEBUG=1
  • Get read/write permission
adb root
adb remount
adb shell getprop bluetooth.profile.bap.unicast.client.enabled
adb shell setprop bluetooth.profile.bap.unicast.client.enabled true
  • logcat
adb logcat -c
adb logcat > "Phone_log_$(date +"%F_%T").log"