À partir du 27 mars 2025, nous vous recommandons d'utiliser android-latest-release
au lieu de aosp-main
pour créer et contribuer à AOSP. Pour en savoir plus, consultez la section Modifications apportées à AOSP.
Présentation du bootloader
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Un chargeur de démarrage est une image propriétaire du fournisseur chargée de démarrer le noyau sur un appareil. Le bootloader protège l'état de l'appareil et est chargé d'initialiser l'environnement d'exécution sécurisé (TEE) et de lier sa racine de confiance. Le bootloader vérifie également l'intégrité des partitions boot
et recovery
avant de transférer l'exécution au noyau.
Exemple de flux de bootloader
Voici un exemple de flux de bootloader:
Chargez et initialisez la mémoire.
Validez l'appareil conformément au flux de démarrage validé.
Vérifiez les partitions de démarrage, y compris boot
, dtbo
, init_boot
et recovery
, conformément au flux de démarrage validé. Lors de cette étape, vérifiez la version de l'en-tête de l'image de démarrage et analysez l'en-tête en conséquence.
Si des mises à jour A/B sont utilisées, déterminez l'emplacement actuel à démarrer.
Déterminez si le mode de récupération doit être démarré. Pour en savoir plus, consultez la section Prise en charge des mises à jour OTA.
Chargez les images de démarrage, telles que boot.img
, vendor_boot.img
, init_boot.img
et d'autres images de démarrage propriétaires du fournisseur. Ces images de démarrage contiennent les images du noyau et du ramdisk.
Chargez le noyau dans la mémoire en tant que binaire compressé auto-exécutable. Le noyau se décompresse et commence à s'exécuter dans la mémoire.
Chargez les ramdisks et la section bootconfig dans la mémoire pour créer initramfs
.
Fonctionnalités supplémentaires liées au bootloader
Vous trouverez ci-dessous une liste de fonctionnalités supplémentaires liées au bootloader que vous pouvez implémenter:
Superposition de l'arborescence de périphériques (DTO, Device Tree Overlay).
Une superposition d'arborescence d'appareils permet au bootloader de prendre en charge différentes configurations matérielles. Un DTO est compilé dans un blob d'arborescence de périphérique (DTB), qui est utilisé par le bootloader.
Organisation aléatoire des adresses virtuelles de l'image du noyau. Le bootloader permet de randomiser l'adresse virtuelle à laquelle l'image du noyau est chargée. Pour randomiser l'adresse, définissez RANDOMIZE_BASE
sur true
dans la configuration du kernel.
Le bootloader doit fournir de l'entropie en transmettant une valeur u64 aléatoire dans le nœud de l'arborescence des appareils /chosen/kaslr-seed
.
Démarrage validé Le démarrage validé permet au bootloader de s'assurer que tout code exécuté provient d'une source fiable.
Configuration de démarrage
La configuration de démarrage est disponible dans Android 12 et versions ultérieures. Il s'agit d'un mécanisme permettant de transmettre les détails de configuration de la compilation et du bootloader au système d'exploitation.
Avant Android 12, les paramètres de ligne de commande du noyau avec le préfixe androidboot
sont utilisés.
Mises à jour OTA (Over The Air) Les appareils Android sur le terrain peuvent recevoir et installer des mises à jour OTA du système, du logiciel d'application et des règles de fuseau horaire. Cette fonctionnalité a des conséquences sur l'implémentation de votre bootloader. Pour obtenir des informations générales sur les mises à jour OTA, consultez la section Mises à jour OTA. Pour en savoir plus sur l'implémentation OTA spécifique au bootloader, consultez la section Prise en charge des mises à jour OTA.
Liaison de version
La liaison de version lie les clés de sécurité au système d'exploitation et au niveau du correctif. Le forçage de version garantit qu'un pirate informatique qui découvre une faille dans une ancienne version du système ou du logiciel TEE ne peut pas faire revenir un appareil à la version vulnérable et utiliser les clés créées avec la version plus récente. Le bootloader doit fournir certaines informations pour prendre en charge la liaison de version. Pour en savoir plus, consultez la section Informations sur la version dans les propriétés AVB.
Ligne de commande du kernel
Concatenate la ligne de commande du kernel à partir des emplacements suivants:
Ligne de commande du bootloader: ensemble de paramètres statiques et dynamiques déterminés par le bootloader
Arborescence des périphériques: à partir du nœud chosen/bootargs
defconfig
: à partir de CONFIG_CMDLINE
boot.img
: à partir de la ligne de commande (pour les décalages et les tailles, consultez system/core/mkbootimg/bootimg.h
À partir d'Android 12, pour les paramètres androidboot.*
que nous devons transmettre à l'espace utilisateur Android, nous pouvons utiliser bootconfig au lieu de la ligne de commande du kernel.
Le contenu et les exemples de code de cette page sont soumis aux licences décrites dans la Licence de contenu. Java et OpenJDK sont des marques ou des marques déposées d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/27 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/27 (UTC)."],[],[],null,["# Bootloader overview\n\nA *bootloader* is a vendor-proprietary image responsible for bringing up the\nkernel on a device. The bootloader guards the device state and is responsible\nfor initializing the [Trusted Execution Environment (TEE)](/docs/security/features/trusty)\nand binding its root of trust. The bootloader also verifies the integrity of the\n`boot` and `recovery` partitions before moving execution to the kernel.\n\nExample bootloader flow\n-----------------------\n\nHere's an example bootloader flow:\n\n1. Load and initialize memory.\n\n2. Verify the device according to [Verified Boot flow](/docs/security/features/verifiedboot).\n\n3. Verify the boot partitions, including `boot`, `dtbo`, `init_boot`, and\n `recovery`, according to the Verified Boot flow. As part of this step, check the\n [boot image header](/docs/core/architecture/bootloader/boot-image-header)\n version and parse the header accordingly.\n\n4. If [A/B updates](/docs/core/ota/ab) are used, determine the current slot to\n boot.\n\n5. Determine if recovery mode should be booted. For more\n information, see\n [Supporting OTA Updates](/docs/core/architecture/bootloader/updating).\n\n6. Load the boot images, such as `boot.img`, `vendor_boot.img`,\n `init_boot.img`, and other proprietary vendor boot images. These boot images\n contain the kernel and ramdisk images.\n\n 1. Load the kernel into memory as a self-executable compressed\n binary. The kernel decompresses itself and starts executing into memory.\n\n 2. Load ramdisks and the bootconfig section into memory\n to create `initramfs`.\n\nAdditional bootloader-related features\n--------------------------------------\n\nFollowing is a list of additional bootloader-related features that you can\nimplement:\n\n- *Device tree overlay (DTO).*\n A [device tree overlay](/docs/core/architecture/dto) lets the bootloader to\n support different hardware configurations. A DTO is compiled into a *device\n tree blob (DTB)* which is used by the bootloader.\n\n- *Kernel image virtual address randomization.* The bootloader supports\n randomizing the virtual address at which the kernel image is loaded. To\n randomize the address, set `RANDOMIZE_BASE` to `true` in the kernel config.\n The bootloader must provide entropy by passing a random u64 value in the\n `/chosen/kaslr-seed` device tree node.\n\n- *Verified Boot.* [Verified Boot](/docs/security/features/verifiedboot) lets\n the bootloader to ensure all executed code comes from a trusted source.\n\n- *Boot config.*\n [Boot config](/docs/core/architecture/bootloader/implementing-bootconfig)\n is available in Android 12 and higher and is a mechanism for passing\n configuration details from the build and bootloader to the operating system.\n Prior to Android 12, kernel command-line parameters with the prefix of\n `androidboot` are used.\n\n- *Over-the-air (OTA) updates.* Android devices in the field can receive and\n install OTA updates to the system, app software, and\n time zone rules. This feature has implications on your bootloader\n implementation. For general information on OTA, see\n [OTA updates](/docs/core/ota). For bootloader-specific OTA implementation\n details, see\n [Supporting OTA updates](/docs/core/architecture/bootloader/updating).\n\n- *Version binding* .\n [Version binding](/docs/security/features/keystore/version-binding) binds\n security keys to the operating system and patch level version. Version binding\n ensures that an attacker who discovers a weakness in an old version of the\n system or the TEE software can't roll a device back to the vulnerable version\n and use keys created with the newer version. The bootloader must provide certain\n information to support version binding. For further information, see\n [Version information in AVB properties](/docs/core/architecture/bootloader/version-info-avb).\n\nKernel command line\n-------------------\n\nConcatenate the kernel command line from the following locations:\n\n- Bootloader command line: set of static and dynamic parameters determined by\n the bootloader\n\n- Device tree: from the `chosen/bootargs` node\n\n- `defconfig`: from `CONFIG_CMDLINE`\n\n- `boot.img`: from the command line (for offsets and sized, refer to\n [`system/core/mkbootimg/bootimg.h`](https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/android16-release/include/bootimg/bootimg.h)\n\nAs of Android 12, for `androidboot.*` parameters that\nwe need to pass to Android userspace, we can use\n[bootconfig](/docs/core/architecture/bootloader/implementing-bootconfig) instead\nof the kernel command line."]]