From patchwork Wed Dec 12 17:12:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 153581 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2052941ljp; Wed, 12 Dec 2018 09:14:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UYIgv2jGobPzEWvvJR2SeIRoWRbp7T5hbs5fszJHY3KUZ5ZphtsKZ9BFIYv6O5WVWkRt2C X-Received: by 2002:a17:906:4e14:: with SMTP id z20-v6mr6456842eju.187.1544634856131; Wed, 12 Dec 2018 09:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544634856; cv=none; d=google.com; s=arc-20160816; b=Zlt11t8nNIi3QdCZPDPQSHObAbbXZtHKqCpB5/Mb8BwFp+3bhcsSGzty3lcQqBDUpm bYPgEIm4vvhn7Kna4uOPOoDGi0ssB5+apLi7iwqgV7xqMKAVy726SKhyv1MSz4B+BJvu 4FxufZr2a7zwehLyGEQ3v9zkXitseM+pYWHJPE9vLQA6KvcN/ioNg7BG2CD7oFhssdmj tSMJzNgAtk9qRDbEAugJyGwmfDghx8sB07/mFDWo4WUU1zNH0waq7kH62OCJceckpyMf 9ENXQv3EQKhvAIfUmhhtgVwWVRRR56HkKdxyRRcOxQiA8SHJzLfnAQ0rwmR8a9rCspeG NUEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:dkim-signature; bh=bUeVwAHRitFU2JzubpBhCW7HJoVgtn6oN9qnAIdBXsY=; b=ZcPhZKhqQukmFc9HxhqtnBMkLJkXtV04qbenZLpy9fAqAgmRUh0M2zn288ejMfL+i2 t2bAuoJQRRA2yF5UdqqPfCEzIXYDS0VgOn27UbjR53hDtJmoXZ2oVLpYiTV0YqycQCtL euI5ZD3LwUt034S1yozCZ1gB29gbS8BpuoRWlqoxsLN+4SguWtRnliCWxVIUFhPG2DHY fUDzIPBWKiLm2qxFuucmSKWwfN+vbybSNcjQgWV0OoLHjs/xqIMm9WypvLyTbC+yhe+b mjEd5eX5+BMFt2oiuYaxLoZzm7qMXe7V3YhMhRRSs2Jd3gyAcz2ydQUOPxJguFuIqbag zyIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TwJcBu6Q; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id k3si3016048edr.290.2018.12.12.09.14.15; Wed, 12 Dec 2018 09:14:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TwJcBu6Q; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 8A989C22775; Wed, 12 Dec 2018 17:13:03 +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 C5BCAC22773; Wed, 12 Dec 2018 17:12:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 769BCC21F18; Wed, 12 Dec 2018 17:12:39 +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 9D5F6C21F51 for ; Wed, 12 Dec 2018 17:12:38 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id l10so14101249lfh.9 for ; Wed, 12 Dec 2018 09:12:38 -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:mime-version :content-transfer-encoding; bh=7wTmWe014lFuESDlzYoGVT0wotEj17FXk7YXQyBZPj0=; b=TwJcBu6QiHlwZoTogf3CNnFz7jILXvOtkfJA7N6J1I6LL/psSklQXOw4m20aq3y6HL buUL8DPmC3tgRa0++doV9FGjnZ1X/qcpye03fIPsTFG3AojqWaZMw/z6J/JsWDv3INKU IAodBgxwalk6PV/tjlnQSYJ182pU2V7h5ruNE= 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:mime-version :content-transfer-encoding; bh=7wTmWe014lFuESDlzYoGVT0wotEj17FXk7YXQyBZPj0=; b=FEfBnewwSLh6OysYIo6ZtPgmiY+RzTugu7uOd36ILRj9pi1zubcQB3i5gS/y95anPi bx2SLcGQfgV/z0CF2/YhMJHpkL0bWcmP1wx8TrfDRcsKyfbStpsFmWAfyyleLpTXUsFC Auehb8teVEnLGR/yrScCJnlM0i6G3XLENSTrnYNFWcZa/gH0y/vCSUD9yGNEp2J5QV6A cmeupoE1eqZdzcHnmiQG40Mou+nhWPcPlHQZX/gRbP3+jB91hVsuZnBVc/sGGAZhFSKd bVBpIcebWzaUGC950eSMY92GOtUIONQbNZDHqHNDbwPpzpjU+SzXusPpOaEQINKuKx2Y 7X/A== X-Gm-Message-State: AA+aEWa6Ce1HB1nL899qqxJuQSTK3UAgKiKgEmB20beZCCez7CdStvhS /saJqunpcdcweMJTIYbKKQffM/gqDNA= X-Received: by 2002:a19:ee08:: with SMTP id g8mr12579602lfb.72.1544634756754; Wed, 12 Dec 2018 09:12:36 -0800 (PST) Received: from kbp1-dhp-f54913.synapse.com ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id t81sm3358020lfe.84.2018.12.12.09.12.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Dec 2018 09:12:36 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Wed, 12 Dec 2018 19:12:27 +0200 Message-Id: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH v2 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: , 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 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 | 277 ++++++++++++++++++++++++++++++++++++++++++ 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, 858 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