From patchwork Mon Feb 18 16:21:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1044152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MSjlrWXB"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4438KZ1crpz9s1l for ; Tue, 19 Feb 2019 03:22:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id DED5CC21FC1; Mon, 18 Feb 2019 16:22:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8A621C21F63; Mon, 18 Feb 2019 16:22:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 28DFBC21F38; Mon, 18 Feb 2019 16:22:02 +0000 (UTC) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by lists.denx.de (Postfix) with ESMTPS id E731AC21F38 for ; Mon, 18 Feb 2019 16:22:00 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id q12so12771597lfm.0 for ; Mon, 18 Feb 2019 08:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=pVgP3Qn2g+/2mUfW+TGC438N6xN/l2bCs9pkUd+15Z8=; b=MSjlrWXBmLt6I4AOLW4zuUVvt9ZomFI65bDzUrcPTf2ojS8yq9J8REkZeHXqVljFgz GIKUNnOt4+jjEDaaF491/8t/h16IpHzHwhQcWA/ij6KyWs5hDX16b4agjxp/6b77I72s 2FRJy81Osy0wmcM1L++kuFMpfJmTDPDmyq0c/1PnEQXtWYsssD42GMQ94eq9YGtYZVOd s1M1+HAUgfi+8QVvm2z5T/epTQAPO0JJFxu6unpQatsdjDMRGIpnHpRvmFijdVD7fduw TGM2/2RiiULaeGXB58fz5gQoG1HZJd0ulYheto4efBWrYvQL2ULyf0942bf3C0iPd/RI oRnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pVgP3Qn2g+/2mUfW+TGC438N6xN/l2bCs9pkUd+15Z8=; b=pieeHl3bfOIoZ91EiYInq1prYMCruAeS1HVLV1XpDJqYk5juxiifirnv/zwKSucWiG P0Kl+77QpPhoX0Iygc2h7zdOwuifCdRaqSnz0B55oqJCIIsCevswcShFRaRgPFjMj11O XYtLhvbv+Z0dqcW6evwUwhvBidI7frGPxYKkFs20xoPhAWAULH1ybdYVIipFEneMPHm8 /WMKU9j0oiD6fE155Azq3fMSicKrSAK1Q0eg39OTcmoYCCg4y4y9gcT5EWyMcbOnnwDE 3fhoNuGDjBTwdhcPR2yUsFairVijuTpdThKKgCU0+J7sphLax/rYncjy3EhclC22ahAf 2Tig== X-Gm-Message-State: AHQUAuZ3Jmq1/h6jq2HAjwg/EfuV4+qp0Fch1KiALEPQl1OXwkqCgYZx QtYjkcLLLZsXvGaorZBlB9t4h8yyZN0= X-Google-Smtp-Source: AHgI3IZn1sqZ6/RGxxmmB6MerDq1DFMqTZ8QJ9JH00WXfCnENvYhHvvI2Zg227neM/zhD++KkTS6ZQ== X-Received: by 2002:a19:95c1:: with SMTP id x184mr14030857lfd.155.1550506919765; Mon, 18 Feb 2019 08:21:59 -0800 (PST) Received: from localhost ([195.238.92.223]) by smtp.gmail.com with ESMTPSA id z14sm3856227lfj.21.2019.02.18.08.21.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 08:21:58 -0800 (PST) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Mon, 18 Feb 2019 18:21:50 +0200 Message-Id: <1550506917-25547-1-git-send-email-igor.opaniuk@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: trini@konsulko.com, deymo@google.com, praneeth@ti.com, astrachan@google.com, semen.protsenko@linaro.org Subject: [U-Boot] [PATCH v3 0/7] android: implement A/B boot process X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 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 Ruslan Trofymenko (7): cmd: part: Add 'number' sub-command 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 ++++++++ cmd/part.c | 16 ++- common/Kconfig | 10 ++ common/Makefile | 1 + common/android_ab.c | 290 ++++++++++++++++++++++++++++++++++++++++++ configs/sandbox_defconfig | 2 + disk/part.c | 68 ++++++++++ doc/README.android-ab | 67 ++++++++++ include/android_ab.h | 34 +++++ include/android_bl_msg.h | 169 ++++++++++++++++++++++++ include/environment/ti/boot.h | 58 ++++++++- include/part.h | 21 +++ test/py/tests/test_ab.py | 74 +++++++++++ 15 files changed, 871 insertions(+), 7 deletions(-) create mode 100644 cmd/ab_select.c create mode 100644 common/android_ab.c create mode 100644 doc/README.android-ab create mode 100644 include/android_ab.h create mode 100644 include/android_bl_msg.h create mode 100644 test/py/tests/test_ab.py Reviewed-by: Sam Protsenko