From 2665fd009898b59f0c367715609936d43a262b30 Mon Sep 17 00:00:00 2001 From: cfig Date: Wed, 30 Sep 2020 12:01:42 +0800 Subject: [PATCH] doc: misc and BootControl --- doc/hidl_boot_control.puml | 63 ++++++++++++++++++++++ doc/misc_image_layout.md | 108 +++++++++++++++++++++++++++++++------ 2 files changed, 154 insertions(+), 17 deletions(-) create mode 100644 doc/hidl_boot_control.puml diff --git a/doc/hidl_boot_control.puml b/doc/hidl_boot_control.puml new file mode 100644 index 0000000..d32e511 --- /dev/null +++ b/doc/hidl_boot_control.puml @@ -0,0 +1,63 @@ +@startuml + +package services { + class android_hardware_boot_1_1_service { + *cc_binary + } + class android_hardware_boot_1_0_service { + *cc_binary + } +} + + +package impls { + class android_hardware_boot_1_0_impl { + *cc_library + } + + class android_hardware_boot_1_1_impl { + *cc_library + } +} + + +package hidl_interface { + class android_hardware_boot_1_0 { + *hidl_interface + } + + class android_hardware_boot_1_1 { + *hidl_interface + } +} + + +android_hardware_boot_1_0_impl --> android_hardware_boot_1_0 + +android_hardware_boot_1_0_service --> android_hardware_boot_1_0 + + + +android_hardware_boot_1_1_impl --> android_hardware_boot_1_0 +android_hardware_boot_1_1_impl --> android_hardware_boot_1_1 +android_hardware_boot_1_1_impl --> libboot_control +android_hardware_boot_1_1_impl ..> libboot_control_defaults + + +android_hardware_boot_1_1_service --> android_hardware_boot_1_0 +android_hardware_boot_1_1_service --> android_hardware_boot_1_1 +class libboot_control_defaults { + *cc_defaults +} +libboot_control_defaults --> android_hardware_boot_1_1 +libboot_control_defaults --> libbootloader_message_vendor +class libboot_control { + *cc_library_static +} +libboot_control ..> libboot_control_defaults +class bootctrl_default { + *cc_library +} +bootctrl_default --> libboot_control +bootctrl_default ..> libboot_control_defaults +@enduml diff --git a/doc/misc_image_layout.md b/doc/misc_image_layout.md index 7567bc1..13197f8 100644 --- a/doc/misc_image_layout.md +++ b/doc/misc_image_layout.md @@ -1,20 +1,94 @@ # /misc partition layout -| - | - | - | size | description | -| :---- | :------ | :---- | :---- | :---- | -| bootloader_message_ab | | | 4096 | | -| | bootloader_message | | 2048 | | -| | |command | 32 |updated by linux/bootloader | -| | |status | 32 |deprecated | -| | |recovery |768 |talking channel between normal/recovery modes | -| | |stage | 32 |format "#/#", eg, "1/3" | -| | |reserved | 1184| | -| |slot_suffix | | 32| | -| |update_channel | |128 | | -| |reserved | | 1888| | -| | | | | | -| vendor bootloader msg | | | 12 KB | offset 4kB | -| wipe_package info | | | 48K | offset 16KB, Used by uncrypt and recovery to store wipe_package for A/B devices | -|- |- |- |- |- | -| | | | | | +| - | - | - | Offset | Size | description | +| :---- | :------ | :---- | :---- | :---- | ----- | +| Legacy | bootloader_message | | 0 | (2K) | | +| | |command | | 32 |updated by linux/bootloader | +| | |status | | 32 |deprecated | +| | |recovery | |768 |talking channel between normal/recovery modes | +| | |stage | | 32 |format "#/#", eg, "1/3" | +| | |reserved | | 1184| | +| - | - |- | - | - | - | +| Vendor Area | vendor bootloader msg | N/A | 2K | 2K | Vendor Area | +| | vendor bootloader msg | N/A | 4K | 12K | pure Vendor area | +| - | - | - | - | - | - | +| Wipe | wipe_package info | | 16K | 16K | offset 16KB, Used by uncrypt and recovery to store wipe_package for A/B devices | +| - | - | - | - | - | - | +| System | system_space -> 1
misc_virtual_ab_message | | | (64) | | +| | | version | | 1 | | +| | | magic | | 4 | | +| | | merge_status | | 1 | | +| | | source_slot | | 1 | | +| | | reserved | | 57 | | +| | | | | | | +| | | | | | | + + + +### vendor area implementation example from Google: + + +#### bootctrl.default.so (link libboot_control.a)貌似没人用 + + +使用legacy_boot_control.cpp, 把libboot_control.a的实现的类android::bootable::BootControl包装进去 + + + +### android.hardware.boot@1.1-impl + +使用BootControl.cpp + +``` +android::hardware::boot::V1_1::implementation::BootControl +``` +直接使用"android::bootable::BootControl"的实现 + + + + + + + + +#### libboot_control.a + +code location: + +```hardware/interfaces/boot/1.1/default/boot_control``` + +https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/master/boot/1.1/default/boot_control/ + +| - | - | - | Offset | Size | description | +| :---- | :------ | :---- | :---- | :---- | ----- | +| Vendor Area | bootloader_message_ab | | 2K | (2K) | Vendor Area | +| | | slot_suffix | | 32| | +| | | update_channel | |128 | | +| | | reserved | | 1888| | + + + +### 32 BYTES "slot_suffix" part details: + +| - | - | - | Offset | Size | description | +| :---- | :------ | :---- | :---- | :---- | ----- | +| | bootloader_control | | | (32) | | +| | | slot_suffix | | 4 | | +| | | magic | | 4 | | +| | | version | | 1 | | +| | | nb_slot | | 3bits | number slots | +| | | recovery_tries_remaining | | 3bits | | +| | | merge_status | | 3bits | | +| | | reserved0 | | 1 | | +| | | slot_info | | 8 | slot_metadata * 4 | +| | | reverved1 | | 8 | | +| | | crc32_le | | 4 | | +| | | | | | | +| | slot_metadata | | | (2) | | +| | | priority | | 4bits | | +| | | tries_remaining | | 3bits | | +| | | successful_boot | | 1bit | | +| | | verity_corrupted | | 1bit | | +| | | reserved | | 7bits | | +| | | | | | |