[U-Boot] [PATCH v5 0/6] android: implement A/B boot process

Igor Opaniuk igor.opaniuk at gmail.com
Fri Jul 12 09:48:19 UTC 2019


On Fri, Jul 5, 2019 at 3:37 PM Igor Opaniuk <igor.opaniuk at gmail.com> wrote:
>
> *** This patch series depends on [4], [5], [6]  and should be
> applied after these paticular patches.
>
> This patch series adds support for Android A/B boot process [1].
> Main steps of A/B boot process are:
>   - A/B metadata integrity check
>   - looking for the current slot (where the system should be
>     booting from)
>   - getting the name of the current boot partition (boot_a or boot_b)
>     and loading the corresponding Android boot image
>   - getting the name of the current system partition (system_a or
>     system_b) and passing of its full name via kernel command line
>     (like 'root=/dev/mmcblk1p11')
>   - passing current slot via kernel command line (like
>     'androidboot.slot_suffix=_a') and via A/B metadata (e.g. via
>     misc partition)
>   - A/B metadata processing: setting the boot success flag for
>     current slot, handling the retry counter, etc
>
> A/B metadata is organized according to Android reference [2] and stored
> on 'misc' partition. On the first A/B boot process, when 'misc'
> partition doesn't contain required data, default A/B metadata will be
> created and stored in 'misc' partition. In the end of the Android boot,
> 'update_verifier' and 'update_engine' services are processing the
> A/B metadata through the Boot Control HAL. To confirm the boot was
> successful using current slot, "boot success" flag must be set on
> Android side.
>
> To enable Android A/B support in U-Boot:
>   1. Set the following config options:
>
>          CONFIG_ANDROID_AB=y
>          CONFIG_CMD_AB_SELECT=y
>
>   2. Change the disk layout so that it has sloted boot partitions.
>      E.g. instead of 'boot' and 'system' partitions there should be
>      'boot_a', 'boot_b', 'system_a' and 'system_b' partitions.
>
> To be able to actually test this patch series, the A/B features must
> be implemented and enabled in Android as well (see [1] for details).
>
> Documentation and corresponding test for A/B boot is present here. The
> last patch in this series integrates A/B boot support on AM57xx based
> boards (though it's not enabled by default). Future users of A/B boot
> feature can use it as a reference.
>
> This series is a part of previous submission [3] by Alex Deymo. It
> contains only A/B feature that was stripped out from there with some
> modifications for using with "bootm" command preferred in upstream.
>
> Changes in v5:
>   * Move tests to android subdir
>   * In new version of sgdisk (0.8.10.2) short options don't work. That can
>     be a regression in sgdisk, but anyway let's use long options, because
>     otherwise the test fails.
>   * Fix boot part size (preserve the new value).
>   * Move doc to proper place
>   * Handle ret values properly for blk_dread()/blk_dwrite properly using
>     IS_ERR_VALUE() macro
>
> Changes in v4:
>   * Removed android_bl_msg.h and re-used the one, which was
>     introduced by Eugeniu Rosca in [4] and [5].
>   * Initially we had intention to use "bcb" command and scripting for
>     providing proper boot sequence logic (slot selection, decrementing the
>     counter for each slot), but found out that it's better to keep using
>     a dedicated command ab_select to avoid huge amount of scripting in
>     the headers in includes/config for each platform.
>   * Removed ANDROID_ prefix in multiple macros.
>   * Addressed comments from Simon
>
> Changes in v3:
>   * Minor fixes in the ab metadata handling (added additional sanity checks).
>   * As Ruslan Trofymenko left Linaro and won't address comments anymore,
>     continue (added my S-b tag) upstreaming patches on my own.
>
> Changes in v2:
>   * 'android_ab_select' command is renamed to 'ab_select' command and
>      moved to separate 'Android support commands' menu
>   * For am57xx boards slotted sections (e.g. system_a and system_b) are
>     added to the default sections if CONFIG_CMD_AB_SELECT flag is
>     defined
>   * Returned function error codes are clarified (errno using)
>   * Some types constants and files are renamed
>   * Assertion condition is clarified in test case
>   * 'debug' calls are changed to 'log_debug'
>   * The Guide is clarified by the results of changes
>
> [1] https://source.android.com/devices/tech/ota/ab/ab_implement
> [2] bootable/recovery/bootloader_message/include/bootloader_message/bootloader_message.h
> [3] https://lists.denx.de/pipermail/u-boot/2017-April/285841.html
> [4] https://patchwork.ozlabs.org/patch/1080394/
> [5] https://patchwork.ozlabs.org/patch/1104243/
> [6] https://patchwork.ozlabs.org/patch/1116012/
>
>
> Ruslan Trofymenko (6):
>   disk: part: Extend API to get partition info
>   common: Implement A/B metadata
>   cmd: Add 'ab_select' command
>   test/py: Add base test case for A/B updates
>   doc: android: Add simple guide for A/B updates
>   env: am57xx: Implement A/B boot process
>
>  cmd/Kconfig                           |  15 ++
>  cmd/Makefile                          |   1 +
>  cmd/ab_select.c                       |  52 +++++
>  common/Kconfig                        |  10 +
>  common/Makefile                       |   1 +
>  common/android_ab.c                   | 300 ++++++++++++++++++++++++++
>  configs/sandbox_defconfig             |   2 +
>  disk/part.c                           |  68 ++++++
>  doc/android/ab.txt                    |  67 ++++++
>  include/android_ab.h                  |  34 +++
>  include/environment/ti/boot.h         |  58 ++++-
>  include/part.h                        |  21 ++
>  test/py/tests/test_android/test_ab.py |  75 +++++++
>  13 files changed, 698 insertions(+), 6 deletions(-)
>  create mode 100644 cmd/ab_select.c
>  create mode 100644 common/android_ab.c
>  create mode 100644 doc/android/ab.txt
>  create mode 100644 include/android_ab.h
>  create mode 100644 test/py/tests/test_android/test_ab.py
>
> --
> 2.17.1
>

FYI:
I've checked the latest master today, almost all needed dependent patches
are merged, except [1] and [2]. I've just left my R-b tag for Sam's
patch, so now
we will be ready to go with A/B patch series after these two are merged.

[1] https://patchwork.ozlabs.org/patch/1126434/
[2] https://patchwork.ozlabs.org/patch/1116012/

-- 
Best regards - Freundliche GrĂ¼sse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk


More information about the U-Boot mailing list