Skip to content

Instantly share code, notes, and snippets.

@techcaotri
Forked from tinntt/aosp-101.md
Created August 16, 2020 17:59
Show Gist options
  • Save techcaotri/aa26fbb1661e04755e3c4941f6eb466d to your computer and use it in GitHub Desktop.
Save techcaotri/aa26fbb1661e04755e3c4941f6eb466d to your computer and use it in GitHub Desktop.
AOSP 101

There are 3 steps:

  • Setup & Download
  • Build
  • Flash

Before you start, please be calm in any situation :v.

Step 1, Setup & Download:

  • At least 250GB of free disk space to check out the code and an extra 150 GB to build it. If you conduct multiple builds, you need additional space.

  • You need repo tool to download the source:

    1/ make sure that you have a bin/ directory in your home directory

    mkdir ~/bin 
    PATH=~/bin:$PATH
    

    2/ dowload the Repo Launcher and ensure that it's executable

    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo
    
  • Download:

    1/ create an empty directory (aosp or something like that)

    mkdir WORKING_DIRECTORY
    cd WORKING_DIRECTORY
    

    2/ configure Git with your real name and email address

    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
    

    3/ Run repo init and sync the source

    repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r35
    repo sync
    

    4/ Dowload Pixel 4 driver https://developers.google.com/android/drivers, please select the driver follow the build name above, this case is QQ2A.200501.001.B2.

    • Unzip the downloaded file in the root directory of the code and you will get a sh file, run through the terminal xxx.sh
    tar zxvf qcom-flame-qd1a.190821.007-54118c11.tgz -C./
    tar xvf google_devices-flame-qd1a.190821.007-2a6a603e.TAR
    
    • After decompression, execute the sh file:
    ./extract-qcom-flame.sh
    ./extract-google_devices-flame.sh
    
    • Agree user agreement is required here, you only need to hold down the down key, you can swipe to the end and enter I ACCEPT.

Step 2, Build the source.

  • Install JSK 1.8
    sudo apt-get install openjdk-8-jdk
    
  • set up the environment
    source build/envsetup.sh
    
  • run lunch command with the target (up to the device), we use aosp_flame-userdebug for pixel 4.
    lunch aosp_flame-userdebug
    
  • compile the code, make -jN, N is the number of parallel tasks.
    m -j4
    

Step 3, Flashing. You need to connect to the phone this step.

  • We will use fastboot and adb tool for this step. If you already have android sdk, please access those tools in Android/Sdk/platform-tools. Otherwise, please install by using this script

    make fastboot adb
    
  • Unlock your device

    1/ Enable OEM unlocking in developer option, please ask me if you don't know where that screen is

    2/ Reboot into the bootloader and use fastboot to unlock it

    fastboot flashing unlock
    
  • Flashing your device:

    1/ Using this script to place the device in fastboot mode

    adb reboot bootloader
    

    2/ After the device is in fastboot mode, you need to set the env variable (ANDROID_PRODUCT_OUT) to the build output

    export ANDROID_PRODUCT_OUT=~/AOSP_DIRECTORY/out/target/product/flame
    

    then run

    fastboot flashall -w
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment