Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release, bukan aosp-main, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Untuk menerapkan update over the air (OTA), bootloader harus dapat mengakses disk RAM pemulihan selama booting. Jika perangkat
menggunakan image pemulihan AOSP yang tidak dimodifikasi, bootloader akan membaca 32 byte pertama
di partisi misc; jika data di sana cocok dengan boot-recovery, bootloader akan melakukan booting ke image recovery. Metode ini memungkinkan pekerjaan pemulihan
yang tertunda (misalnya, menerapkan OTA atau menghapus data) untuk dilanjutkan
hingga selesai.
Untuk mendukung update OTA di perangkat yang menggunakan update
A/B, pastikan bootloader perangkat memenuhi
kriteria berikut.
Kriteria umum
Semua partisi yang diupdate melalui OTA harus dapat diupdate saat sistem
utama di-booting (dan tidak diupdate dalam pemulihan).
Untuk mem-booting partisi system, bootloader meneruskan nilai berikut di
command line kernel: ro root=/dev/[node] rootwait init=/init.
Framework Android bertanggung jawab untuk memanggil markBootSuccessful
dari HAL. Bootloader tidak boleh menandai partisi sebagai berhasil
di-booting.
Dukungan untuk HAL kontrol booting
Bootloader harus mendukung HAL boot_control seperti yang ditentukan dalam
hardware/libhardware/include/hardware/boot_control.h. Pengupdate membuat kueri
HAL kontrol
boot,
mengupdate slot booting yang tidak digunakan, mengubah slot aktif menggunakan
HAL, dan memulai ulang ke sistem operasi yang diupdate. Untuk mengetahui detailnya, lihat
Menerapkan HAL kontrol
boot.
Dukungan untuk slot
Bootloader harus mendukung fungsi yang terkait dengan partisi dan slot,
termasuk:
Nama partisi harus menyertakan akhiran yang mengidentifikasi partisi
yang termasuk dalam slot tertentu di bootloader. Untuk setiap partisi tersebut,
ada variabel has-slot:partition base name
yang sesuai dengan nilai
yes. Slot diberi nama secara alfabetis sebagai a, b, c, dll. yang sesuai dengan
partisi dengan akhiran _a, _b, _c, dll. Bootloader harus memberi tahu
sistem operasi slot mana yang di-booting menggunakan properti command line
androidboot.slot_suffix. Properti ini ditetapkan melalui bootconfig untuk perangkat
yang diluncurkan dengan Android 12 atau yang lebih tinggi.
Nilai slot-retry-count direset ke nilai positif (biasanya 3),
baik oleh HAL kontrol booting melalui callback setActiveBootSlot atau
melalui perintah fastboot set_active. Saat mengubah partisi yang
merupakan bagian dari slot, bootloader akan menghapus "berhasil di-booting" dan mereset
jumlah percobaan ulang untuk slot.
Bootloader juga harus menentukan slot mana yang akan dimuat. Gambar menunjukkan
contoh proses pengambilan keputusan.
Gambar 1. Alur slot bootloader
Tentukan slot yang akan dicoba. Jangan mencoba memuat slot yang ditandai
slot-unbootable. Slot ini harus konsisten dengan nilai yang ditampilkan oleh
fastboot, dan disebut sebagai slot saat ini.
Jika slot saat ini tidak ditandai sebagai slot-successful dan memiliki
slot-retry-count = 0, tandai slot saat ini sebagai slot-unbootable. Kemudian,
pilih slot lain yang tidak ditandai unbootable dan ditandai sebagai
slot-successful; slot ini sekarang menjadi slot yang dipilih. Jika tidak ada slot saat ini
yang tersedia, lakukan booting ke pemulihan atau tampilkan pesan error yang bermakna kepada
pengguna.
Pilih boot.img yang sesuai dan sertakan jalur untuk memperbaiki partisi
sistem di command line kernel.
Isi parameter slot_suffix command line kernel.
Booting. Jika tidak ditandai slot-successful, kurangi slot-retry-count.
Utilitas fastboot menentukan partisi mana yang akan di-flash saat menjalankan
perintah flash. Misalnya, menjalankan perintah fastboot flash system system.img
pertama-tama membuat kueri variabel current-slot, lalu menggabungkan hasilnya
ke sistem untuk membuat nama partisi yang harus di-flash
(system_a, system_b, dll.).
Saat menetapkan slot saat ini menggunakan perintah set_active fastboot atau
perintah setActiveBootSlot HAL kontrol booting, bootloader harus mengupdate
slot saat ini, menghapus slot-unbootable dan slot-successful, serta mereset
jumlah percobaan ulang (ini adalah satu-satunya cara untuk menghapus slot-unbootable).
Perangkat tanpa update A/B
Untuk mendukung update OTA di perangkat yang tidak menggunakan update A/B (lihat Perangkat
yang dapat diupdate non-A/B), pastikan bootloader
perangkat memenuhi kriteria berikut.
Partisi recovery harus berisi image yang mampu membaca
image sistem dari beberapa partisi yang didukung (cache, userdata) dan menulisnya
ke partisi system.
Bootloader harus mendukung booting langsung ke mode pemulihan.
Jika update image radio didukung, partisi recovery juga harus
dapat mem-flash radio. Hal ini dapat dilakukan dengan salah satu dari dua cara berikut:
Bootloader mem-flash radio. Dalam hal ini, Anda seharusnya dapat
memulai ulang dari partisi pemulihan kembali ke bootloader untuk menyelesaikan
update.
Image pemulihan mem-flash radio. Fungsi ini dapat disediakan sebagai
library atau utilitas biner.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# Implement OTA updates\n\nTo implement the [over-the-air (OTA) updates](/docs/core/ota), the\nbootloader must be able to access a recovery RAM disk during boot. If the device\nuses an unmodified AOSP recovery image, the bootloader reads the first 32 bytes\non the `misc` partition; if the data there matches `boot-recovery`, the\nbootloader boots into the `recovery` image. This method enables any pending\nrecovery work (for example, applying an OTA or removing data) to continue to\ncompletion.\n\nFor details on the content of a block in flash used for communications by\nrecovery and the bootloader, refer to\n[bootable/recovery/bootloader_message/bootloader_message.h](https://android.googlesource.com/platform/bootable/recovery/+/android16-release/bootloader_message/include/bootloader_message/bootloader_message.h#64).\n\nDevices with A/B updates\n------------------------\n\nTo support OTA updates on devices that use [A/B\nupdates](/docs/core/ota/ab), ensure that the device bootloader meets\nthe following criteria.\n\n### General criteria\n\n- All partitions updated through an OTA should be updatable while the main\n system is booted (and not updated in recovery).\n\n- To boot the `system` partition, the bootloader passes the following value on\n kernel command line: `ro root=/dev/[node] rootwait init=/init`.\n\n- It's the responsibility of the Android framework to call `markBootSuccessful`\n from the HAL. The bootloader should never mark a partition as successfully\n booted.\n\n### Support for boot control HAL\n\nThe bootloader must support the `boot_control` HAL as defined in\n`hardware/libhardware/include/hardware/boot_control.h`. The updater queries the\n[boot control\nHAL](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/boot/1.0/IBootControl.hal),\nupdates the boot slot not in use, changes the active slot using the\nHAL, and reboots into the updated operating system. For details, see\n[Implementing the boot control\nHAL](/docs/core/ota/ab/ab_implement#bootcontrol).\n\n### Support for slots\n\nThe bootloader must support functionality related to partitions and slots,\nincluding:\n\n- Partition names must include a suffix that identifies which partitions\n belong to a particular slot in the bootloader. For each such partition,\n there's a corresponding variable\n `has-slot:`\u003cvar translate=\"no\"\u003epartition base name\u003c/var\u003e with a value of\n `yes`. Slots are named alphabetically as a, b, c, etc. corresponding to\n partitions with the suffix `_a`, `_b`, `_c`, etc. The bootloader should inform\n the operating system which slot was booted using the command line property\n `androidboot.slot_suffix`. This property is set through bootconfig for devices\n launching with Android 12 or higher.\n\n- The `slot-retry-count` value is reset to a positive value (usually `3`),\n either by the boot control HAL through the `setActiveBootSlot` callback or\n through the `fastboot set_active` command. When modifying a partition that's\n part of a slot, the bootloader clears \"successfully booted\" and resets the\n retry count for the slot.\n\nThe bootloader should also determine which slot to load. The figure shows an\nexample decision process.\n**Figure 1.** Bootloader slotting flow\n\n1. Determine which slot to attempt. Don't attempt to load a slot marked\n `slot-unbootable`. This slot should be consistent with the values returned by\n fastboot, and is referred to as the current slot.\n\n2. If the current slot isn't marked as `slot-successful` and has a\n `slot-retry-count = 0`, mark the current slot as `slot-unbootable`. Then\n select a different slot that is not marked `unbootable` and is marked as\n `slot-successful`; this slot is now the selected slot. If no current slot is\n available, boot to recovery or display a meaningful error message to the\n user.\n\n3. Select the appropriate `boot.img` and include the path to correct system\n partition on the kernel command line.\n\n4. Populate the kernel command line `slot_suffix` parameter.\n\n5. Boot. If not marked `slot-successful`, decrement `slot-retry-count`.\n\nThe `fastboot` utility determines which partition to flash when running any\nflash commands. For example, running the `fastboot flash system system.img`\ncommand first queries the `current-slot` variable then concatenates the result\nto system to generate the name of the partition that should be flashed\n(`system_a`, `system_b`, etc.).\n\nWhen setting the current slot using the fastboot `set_active` command or the\nboot control HAL `setActiveBootSlot` command, the bootloader should update\nthe current slot, clear `slot-unbootable` and `slot-successful`, and reset the\nretry count (this is the only way to clear `slot-unbootable`).\n\nDevices without A/B updates\n---------------------------\n\nTo support OTA updates on devices that don't use A/B updates (see [Non-A/B\nupdatable devices](/docs/core/ota/nonab)), ensure that the device\nbootloader meets the following criteria.\n\n- The `recovery` partition should contain an image that is capable of reading a\n system image from some supported partition (`cache`, `userdata`) and writing\n it to the `system` partition.\n\n- The bootloader should support booting directly into recovery mode.\n\n- If radio image updates are supported, the `recovery` partition should also be\n able to flash the radio. This can be accomplished in one of two ways:\n\n - The bootloader flashes the radio. In this case, it should be possible to\n reboot from the recovery partition back into the bootloader to complete the\n update.\n\n - The recovery image flashes the radio. This functionality can be provided as\n a binary library or utility."]]