Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Custom device development
Stay organized with collections
Save and categorize content based on your preferences.
This page explains several tasks you might need to perform if you're
setting up a build for your own device.
Create a custom flash configuration
Fastboot instructions are defined in an artifact called fastboot-info.txt
. If
you build multiple targets, you'll have multiple fastboot-info.txt
files in
the $OUT_DIR. And, $ANDROID_PRODUCT_OUT
points to the
most current target you built. This page list the tasks for fastboot to execute
and can be regenerated using m fastboot_info
. You can introduce custom
flashing logic by modifying the fastboot-info.txt
file.
The fastboot-info.txt
file supports these commands:
flash %s
: Flashes a given partition. Optional arguments include
--slot-other,
filename_path, and
--apply-vbmeta`.
update-super
: Updates the super partition.
if-wipe
: Conditionally runs some other component if a wipe is specified.
erase %s
: Erases a given partition (can only be used in conjunction
with if-wipe
-> eg. if-wipe erase cache
).
Determine flash lock state
If you're building a custom flashboot daemon (flashbootd) for a device, you need
to be able to obtain bootloader and bootloader lock state. The
getFlashLockState()
@SystemApi
transmits the bootloader
state and the PersistentDataBlockManager.getFlashLockState()
system
API returns the bootloader's lock status on compliant devices.
Return value |
Conditions |
FLASH_LOCK_UNKNOWN |
Returned only by devices upgrading to Android 7.x or higher that didn't
previously support the bootloader changes required to get the flash lock
status if they supported flashing lock/unlock capability.
- New devices running Android 7.x or higher must be in either a
FLASH_LOCK_LOCKED or FLASH_LOCK_UNLOCKED state.
- Devices upgrading to Android 7.x or higher that don't support flashing
unlock/lock capability should return a
FLASH_LOCK_LOCKED state.
|
FLASH_LOCK_LOCKED |
Returned by any device that doesn't support flashing
lock/unlock (that is, the device is always locked), or any device that supports
flashing lock/unlock and is in the locked state. |
FLASH_LOCK_UNLOCKED |
Returned by any device that supports flashing lock/unlock and is
in the unlocked state. |
Manufacturers should test the values returned by devices with locked and
unlocked bootloaders. For example, AOSP
contains a reference implementation that returns a value based on the
ro.boot.flash.locked
boot property. Example code is located in the
following directories:
frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java
frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-29 UTC.
[null,null,["Last updated 2025-08-29 UTC."],[],[],null,["# Custom device development\n\nThis page explains several tasks you might need to perform if you're\nsetting up a build for your own device.\n\nCreate a custom flash configuration\n-----------------------------------\n\nFastboot instructions are defined in an artifact called `fastboot-info.txt`. If\nyou build multiple targets, you'll have multiple `fastboot-info.txt` files in\nthe \u003cvar translate=\"no\"\u003e$OUT_DIR\u003c/var\u003e. And, `$ANDROID_PRODUCT_OUT` points to the\nmost current target you built. This page list the tasks for fastboot to execute\nand can be regenerated using `m fastboot_info`. You can introduce custom\nflashing logic by modifying the `fastboot-info.txt` file.\n\nThe `fastboot-info.txt` file supports these commands:\n\n- `flash %s`: Flashes a given partition. Optional arguments include `--slot-other,`\u003cvar translate=\"no\"\u003efilename_path\u003c/var\u003e`, and`--apply-vbmeta\\`.\n- `update-super`: Updates the super partition.\n- `if-wipe`: Conditionally runs some other component if a wipe is specified.\n- `erase %s`: Erases a given partition (can only be used in conjunction with `if-wipe` -\\\u003e eg. `if-wipe erase cache`).\n\nDetermine flash lock state\n--------------------------\n\nIf you're building a custom flashboot daemon (flashbootd) for a device, you need\nto be able to obtain bootloader and bootloader lock state. The\n`getFlashLockState()` `@SystemApi` transmits the bootloader\nstate and the `PersistentDataBlockManager.getFlashLockState()` system\nAPI returns the bootloader's lock status on compliant devices.\n\n| Return value | Conditions |\n|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `FLASH_LOCK_UNKNOWN` | Returned only by devices upgrading to Android 7.x or higher that didn't previously support the bootloader changes required to get the flash lock status if they supported flashing lock/unlock capability. - New devices running Android 7.x or higher must be in either a `FLASH_LOCK_LOCKED` or `FLASH_LOCK_UNLOCKED` state. - Devices upgrading to Android 7.x or higher that don't support flashing unlock/lock capability should return a `FLASH_LOCK_LOCKED` state. |\n| `FLASH_LOCK_LOCKED` | Returned by any device that doesn't support flashing lock/unlock (that is, the device is always locked), or any device that supports flashing lock/unlock and is in the locked state. |\n| `FLASH_LOCK_UNLOCKED` | Returned by any device that supports flashing lock/unlock and is in the unlocked state. |\n\nManufacturers should test the values returned by devices with locked and\nunlocked bootloaders. For example, AOSP\ncontains a reference implementation that returns a value based on the\n`ro.boot.flash.locked` boot property. Example code is located in the\nfollowing directories:\n\n- `frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java`\n- `frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java`"]]