A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release anziché aosp-main per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Per implementare gli aggiornamenti over-the-air (OTA), il bootloader deve essere in grado di accedere a un disco RAM di ripristino durante l'avvio. Se il dispositivo utilizza un'immagine di ripristino AOSP non modificata, il bootloader legge i primi 32 byte della partizione misc. Se i dati corrispondono a boot-recovery, il bootloader avvia l'immagine recovery. Questo metodo consente a qualsiasi attività di recupero in attesa (ad esempio l'applicazione di un aggiornamento OTA o la rimozione di dati) di continuare fino al completamento.
Per supportare gli aggiornamenti OTA sui dispositivi che utilizzano gli aggiornamenti A/B, assicurati che il bootloader del dispositivo soddisfi i seguenti criteri.
Criteri generali
Tutte le partizioni aggiornate tramite un OTA devono essere aggiornabili durante l'avvio del sistema principale (e non aggiornate in modalità di ripristino).
Per avviare la partizione system, il bootloader passa il seguente valore alla riga di comando del kernel: ro root=/dev/[node] rootwait init=/init.
È responsabilità del framework Android chiamare markBootSuccessful
dall'HAL. Il bootloader non deve mai contrassegnare una partizione come avviata correttamente.
Supporto per l'HAL di controllo dell'avvio
Il bootloader deve supportare l'HAL boot_control come definito in
hardware/libhardware/include/hardware/boot_control.h. L'aggiornamento esegue query sull'HAL di controllo dell'avvio, aggiorna lo slot di avvio non in uso, modifica lo slot attivo utilizzando l'HAL e riavvia il sistema operativo aggiornato. Per maggiori dettagli, consulta
Implementazione dell'HAL di controllo del boot.
Supporto per gli slot
Il bootloader deve supportare le funzionalità relative a partizioni e slot, tra cui:
I nomi delle partizioni devono includere un suffisso che identifichi le partizioni appartenente a un determinato slot nel bootloader. Per ogni partizione di questo tipo,
esiste una variabile corrispondente
has-slot:partition base name con un valore di
yes. Gli slot sono denominati in ordine alfabetico come a, b, c e così via, corrispondenti alle partizioni con il suffisso _a, _b, _c e così via. Il bootloader deve informare il sistema operativo dello slot da cui è stato eseguito l'avvio utilizzando la proprietà della riga di comando androidboot.slot_suffix. Questa proprietà viene impostata tramite bootconfig per i dispositivi avviati con Android 12 o versioni successive.
Il valore slot-retry-count viene reimpostato su un valore positivo (di solito 3),
dall'HAL di controllo del boot tramite il callback setActiveBootSlot o
tramite il comando fastboot set_active. Quando modifichi una partizione che fa parte di uno slot, il bootloader cancella "avvio riuscito" e reimposta il conteggio dei tentativi per lo slot.
Il bootloader deve anche determinare quale slot caricare. La figura mostra un
esempio di processo decisionale.
Figura 1. Flusso di allocazione del bootloader
Determina quale slot provare. Non tentare di caricare una scheda contrassegnata come
slot-unbootable. Questo slot deve essere coerente con i valori restituiti da
fastboot e viene definito slot corrente.
Se lo slot corrente non è contrassegnato come slot-successful e contiene un
slot-retry-count = 0, contrassegnalo come slot-unbootable. Quindi,
seleziona un altro intervallo che non è contrassegnato come unbootable, ma come
slot-successful. Questo intervallo è ora selezionato. Se non è disponibile alcuno slot corrente, avvia il recupero o mostra un messaggio di errore significativo all'utente.
Seleziona boot.img appropriato e includi il percorso della partizione di sistema corretta sulla riga di comando del kernel.
Compila il parametro slot_suffix della riga di comando del kernel.
Avvia. Se non è contrassegnato slot-successful, decrementa slot-retry-count.
L'utilità fastboot determina quale partizione eseguire il flashing quando esegui comandi di flashing. Ad esempio, l'esecuzione del comando fastboot flash system system.img
esegue prima una query sulla variabile current-slot, quindi concatena il risultato
al sistema per generare il nome della partizione da eseguire in modalità flash
(system_a, system_b e così via).
Quando imposti lo slot corrente utilizzando il comando fastboot set_active o il comando HAL di controllo del boot setActiveBootSlot, il bootloader deve aggiornare lo slot corrente, cancellare slot-unbootable e slot-successful e reimpostare il conteggio dei tentativi (questo è l'unico modo per cancellare slot-unbootable).
Dispositivi senza aggiornamenti A/B
Per supportare gli aggiornamenti OTA sui dispositivi che non utilizzano gli aggiornamenti A/B (vedi Dispositivi non A/B aggiornabili), assicurati che il bootloader del dispositivo soddisfi i seguenti criteri.
La partizione recovery deve contenere un'immagine in grado di leggere un'immagine di sistema da qualche partizione supportata (cache, userdata) e di scriverla nella partizione system.
Il bootloader deve supportare l'avvio direttamente in modalità di ripristino.
Se sono supportati gli aggiornamenti delle immagini della radio, la partizione recovery dovrebbe anche essere in grado di eseguire il flashing della radio. Questa operazione può essere eseguita in due modi:
Il bootloader esegue il flashing della radio. In questo caso, dovrebbe essere possibile riavviare dalla partizione di ripristino al bootloader per completare l'aggiornamento.
L'immagine di ripristino fa lampeggiare la radio. Questa funzionalità può essere fornita come utility o libreria binaria.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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."]]