--- [toc] --- # Build AOSP: Pixel 5 (redfin) with Android 13 ## Environment - PC - CPU: i7-12700 (8 P-core + 4 E-core) - RAM: 32 GB - Disk: 1 TB SSD - OS: Ubuntu LTS 22.04 with required [packages](https://source.android.com/docs/setup/start/initializing#setting-up-a-linux-build-environment) - Kernel: 5.17.0 [(Note: Kernel 6.XX might induce AOSP build error)](https://stackoverflow.com/questions/60275623/android-dex2oat-builderror-dex2oat-failed-to-compile-a-boot-image) - Swap: 16 GB [(Note: Set enough swap to avoid AOSP OOM build error)](https://forum.xda-developers.com/t/android-rom-compiling-error-ninja-failed-exit-status-137.4595865/) - Software - ADB: 33.0.3 [(Note: How to update the newest ADB)](https://askubuntu.com/questions/602129/how-to-update-or-re-install-the-newest-version-of-adb) - Fastboot: 33.0.3 [(Note: Fastboot 34.0.1 might induce flash error)](https://forum.xda-developers.com/t/how-to-fix-fastboot-error-android_product_out-not-set.4568671/) - Phone - Pixel 5 ## Download AOSP source code Follow [official tutorial](https://source.android.com/docs/setup/download/downloading) and choose a [tag](https://source.android.com/docs/setup/about/build-numbers#source-code-tags-and-builds). I choose tag **android-13.0.0_r67** for my Pixel 5, and the correspoding build ID is **TQ3A.230805.001**  1. Create a folder for AOSP source code ```shell! mkdir ~/aosp && cd ~/aosp ``` 2. Init with tag **android-13.0.0_r67** ```shell! repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r67 ``` 3. Sync ```shell! repo sync -j8 ``` ## Download driver binaries 1. Download [driver binaries](https://developers.google.com/android/drivers?hl=en) 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**.  ```shell! 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 ``` 2. Unzip to your AOSP source code folder ```shell! tar xvfz google_devices-redfin-tq3a.230805.001.a2-59031497.tgz tar xvfz qcom-redfin-tq3a.230805.001.a2-94c5e420.tgz ``` 3. Run script ```shell! source extract-google_devices-redfin.sh source extract-qcom-redfin.sh ``` ## Build AOSP Follow [official tutorial](https://source.android.com/docs/setup/build/building) 1. Setup ```shell! source build/envsetup.sh ``` 2. Choose a [target](https://source.android.com/docs/setup/build/running#selecting-device-build) to lunch. I choose **aosp_redfin-userdebug** for my Pixel 5.  ```shell! lunch aosp_redfin-userdebug ``` 3. Enable [compile_commands.json](https://android.googlesource.com/platform/build/soong/+/HEAD/docs/compdb.md), which let you efficiently trace C/C++ code with VS code installed with [clangd extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) ```shell! export SOONG_GEN_COMPDB=1 export SOONG_GEN_COMPDB_DEBUG=1 ``` 4. Build all images ```shell! m -j8 2>&1 | tee build_aosp_redfin_userdebug.log ``` ## Unlock phone Follow [official tutorail](https://source.android.com/docs/setup/build/running) 1. Enable OEM unlocking and USB debugging in Developer options  2. Reboot to bootloader ```shell! adb reboot bootloader ```  3. Unlock ```shell! fastboot flashing unlock ```  4. Flash (Note: fastboot will flash img in $ANDROID_PRODUCT_OUT folder to your phone) ```shell! fastboot flashall -w ``` 5. Boot to Android homescreen  ## Troubleshooting If your Pixel phone is bricked, using [physical button](https://source.android.com/docs/setup/build/running#booting-into-fastboot-mode) to force reboot your phone to bootloader, and [flash factory img with official tool](https://source.android.com/docs/setup/build/flash). ## 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](https://source.android.com/docs/core/connect/bluetooth) ## Bluetooth Repository packages/modules/Bluetooth/ ## Tools - [Android Code Search](https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/Bluetooth/) - [Gitiles](https://android.googlesource.com/platform/packages/modules/Bluetooth) - [Gerrit](https://android-review.googlesource.com/q/project:platform%252Fpackages%252Fmodules%252FBluetooth) ## Develope flow 1. Modify code 2. Build Bluetooth package and dependency ```shell! mmma packages/modules/Bluetooth/ -j8 2>&1 | tee build_bt.log ``` 3. According to [TEST_MAPPING file](https://source.android.com/docs/core/tests/development/test-mapping), use [Atest](https://source.android.com/docs/core/tests/development/atest) to run [instrumentation test](https://source.android.com/docs/core/tests/development/instrumentation), [unit test](https://source.android.com/docs/core/connect/bluetooth/verifying_debugging#unit-tests-in-aosp) or [GTest](https://source.android.com/docs/core/tests/development/gtest) - Instrumentation test ```shell! atest BluetoothInstrumentationTests -v 2>&1 | tee BluetoothInstrumentationTests.log ``` - GTest ```shell! atest bluetooth_le_audio_client_test -v 2>&1 | tee bluetooth_le_audio_client_test.log ``` 4. Manual test: replace Bluetooth apex and manually verify your change ```shell! adb root adb remount adb install out/target/product/redfin/system/apex/com.android.btservices.apex adb reboot ``` 5. [Submit patches](https://source.android.com/docs/setup/contribute/submit-patches) ## Develop & Debug skill - Enable [compile_commands.json](https://android.googlesource.com/platform/build/soong/+/HEAD/docs/compdb.md), which let you efficiently trace C/C++ code with VS code installed with [clangd extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) ```shell! export SOONG_GEN_COMPDB=1 export SOONG_GEN_COMPDB_DEBUG=1 ``` - Get read/write permission ```shell! adb root adb remount ``` - Get/Set [Bluetooth properties](https://cs.android.com/android/platform/superproject/main/+/refs/heads/main:out/soong/.intermediates/system/libsysprop/srcs/PlatformProperties_public/android_common/xref/srcjars.xref/android/sysprop/BluetoothProperties.java) ```shell! adb shell getprop bluetooth.profile.bap.unicast.client.enabled adb shell setprop bluetooth.profile.bap.unicast.client.enabled true ``` - logcat ```shell! adb logcat -c adb logcat > "Phone_log_$(date +"%F_%T").log" ``` - [Bluetooth HCI log](https://source.android.com/docs/core/connect/bluetooth/verifying_debugging#debugging-with-logs)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up