Skip to content

Instantly share code, notes, and snippets.

@farhanarrafi
Last active December 9, 2021 04:38
Show Gist options
  • Save farhanarrafi/d3a5d11f808e6f460e72aa60f8e38f7f to your computer and use it in GitHub Desktop.
Save farhanarrafi/d3a5d11f808e6f460e72aa60f8e38f7f to your computer and use it in GitHub Desktop.
Instructions for flashing AOSP firmware into Android device

Android device flashing instructions

This guide covers the steps for flashing Android firmware into hardware device. These steps can be used to flash AOSP build into a hardware device. Please follow the steps in order.

Unlock device for firmware flash:

Please follow the instructions on the Flashing Devices page for unlocking the device.

Boot device into bootloader:

  • Connect device to PC via USB cable. Make sure developer option and USB debugging is enabled.
  • Run the command in a terminal to boot into bootloader:
adb reboot bootloader

Preapre Enviroment:

We need to set ANDROID_PRODUCT_OUT variable to the AOSP output directory where boot.img, system.img and other files reside.

We need to execute the build commands once in the terminal. This updates the ANDROID_PRODUCT_OUT variable and sources fastboot command in the terminal. To do these we need to execute the two steps.

  • Open terminal in <AOSP_ROOT> directory.
  • Run the following commands:
. build/envsetup.sh
lunch aosp_target-name-eng
m

(Replace "target-name" with your device codename. For device target-names check Selecting a device build)

Flash the device:

Please make sure the device is not disconnected while the flash is running. The device will automatically reboot after a successful flash. To flash the device run the command:

fastboot flashall -w

Troubleshooting

  • If an error like fastboot: usage: no command is shown, that means fastboot is not sourced to your terminal or there are some other issues. If this happens, you need to use fastboot from your AOSP output directory. In that case use the fastboot from the directory - /out/soong/host/linux-x86/bin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment