From patchwork Wed Dec 12 17:12:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 153584 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2056083ljp; Wed, 12 Dec 2018 09:17:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/VJOs6EjgXB42+j67b6xYA8nIn4Ks6J4yMSRyCeYYtRUd1Fc1Mv1E39hm+xVjXIsX1Ljp/u X-Received: by 2002:a17:906:b893:: with SMTP id hb19-v6mr15579353ejb.76.1544635032339; Wed, 12 Dec 2018 09:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544635032; cv=none; d=google.com; s=arc-20160816; b=Ql7B1YiMBwwxtGua2rphBJQ8V1Rk4I+6Ch8ef8oLXI0SrgcgaLX4TZNU7TdVXIgCJ4 Gu0XrU5Mc08b/mb+vpdxB77pK1SorsSmB/VqHgkuFe3dr96J69aI5TV30+upXr6q4w0R +3wQHfrQEzuZ3gyk4Lqd9n208s7/o250lB9K+AHcPVNZJbH/maIMCKjgg6pxGJ+usWIe xWLPUWW7wi7qKipeED9xmikZCwkUkNMD/8L1K1MotjE7f2Pa0s0yni4zk7rlUThhSDye d9e0uiy3KjXUydkneumAMABXdO6vEbVw5bK1TbR9Q3AG5mSWZugK/vdWEurexEnFbUvM Lj0w== 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:references:in-reply-to:message-id:date:to:from :dkim-signature; bh=jKiKpOOGdcOisUJhDM6ccR6e9hFUT2fq2GVDFqy9eW4=; b=SEpvEWrTjK5QGXHTmIRAetrR2kQ8IeMYpK2BwCxNPqNuXSUCP3h+ZUEEasLDdVazMx vIPg5RT91PTx66aVexjVdug2iyMQb0N62K1BHv3yxVxxhlay7HWrka25acSxT5GQxTIm 62w0787RdP9QjjASxeUoPWf7iTgnxJ26gOoIP5j71nfa9qhR8h61C30KNGnzLoh3lkMS PJDdzwappaiANFYRRwC3DQbfC4eVPTRhA4lVD31MBfxAbqsaDZeq8+aaXfmzW472xxuL i59bSXf+3HXTKDiuQAK9zNcAjWbMtUtY2OrkvjWMjOOYUgYBIKviEA6AOywvCI7G2c1o E+Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TggbaAZ+; 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 o1-v6si2915087eji.22.2018.12.12.09.17.12; Wed, 12 Dec 2018 09:17:12 -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=TggbaAZ+; 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 D65DCC2278B; Wed, 12 Dec 2018 17:14:42 +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 6CDCBC22788; Wed, 12 Dec 2018 17:12:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7F0C9C22784; Wed, 12 Dec 2018 17:12:50 +0000 (UTC) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by lists.denx.de (Postfix) with ESMTPS id 5CDE2C22779 for ; Wed, 12 Dec 2018 17:12:46 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id y11so2822972lfj.4 for ; Wed, 12 Dec 2018 09:12:46 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZHaDFBTgtxPyauUYIbe2xZhoBPmdz9uZMKjIbwpkzlE=; b=TggbaAZ+swcqlDZGwvX6TJp9NUYe1KKFDc9gArETCSKZf7wBo0CuiisMe2ooQ933aa PLPwNkncd7pJ2jwphdw27rJ5s58xbcvQL4V4MWnxhCth0hLkb97zV3rxJ6ojk/c4glqq aVoDtxRiEQyVEwJ7sbQHkGsxL1EeJT48+A9/E= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZHaDFBTgtxPyauUYIbe2xZhoBPmdz9uZMKjIbwpkzlE=; b=NcYRDhSWEaqwKYP5gpsevbH0s0pEHhnYOs8eUrWH4GagnV3r1q/BVRuCE3FnLh7e6Q qoN3td1TuqtSnFdald8B7gbBsAE4fIpy5eViVeuRQIXNQRDcWGVAUNH1bpkGQY5eEv+a aKvCSTUtzEA0rucVoYtJp6di+xJ05hYdOwEOFEKpHc2BOsegzQsJ9Rn8W6Y4DjhInUS7 T+VZN9ipwsvlsrfV0kAg9L9FYGtwF40ICh7EilbYCzcwdNT61VvCyi9jyfT2TYmU8W8y UxrX9EosnD9+F9jEarHMYeHRCX6+UfU2iRVqvoPKHLOkwLrsoQ/R3rqwJYpeoBoP0pai Dppg== X-Gm-Message-State: AA+aEWaN6nxAR2/aU0RsExYRTGQVWpUExWR7fvFy+oTnqDK/k/l5d6xP uU4HHeTkJ38Lc8b6U2j8Q3uvJP/Z0VY= X-Received: by 2002:a19:d90c:: with SMTP id q12mr11733088lfg.24.1544634765524; Wed, 12 Dec 2018 09:12:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Dec 2018 09:12:44 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Wed, 12 Dec 2018 19:12:34 +0200 Message-Id: <1544634754-3435-8-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> References: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> MIME-Version: 1.0 Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH v2 7/7] env: am57xx: 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" Add support for A/B boot process on AM57xx based boards: 1. Define 'slot_suffix' variable (using 'ab_select' command) 2. Extend 'emmc_android_boot' boot command (add commands for A/B boot process) 'ab_select' command is used to decide which slot should be used for booting up. A/B metadata resides in 'misc' partition. To activate the A/B boot process, the following config options must be set: CONFIG_ANDROID_AB=y CONFIG_CMD_AB_SELECT=y For successful A/B boot, the corresponding A/B infrastructure must be involved on Android side [1] (including mounting system as root), and disk must be partitioned accordingly. When A/B boot is enabled, there are some known limitations currently exist (not related to A/B patches, need to be implemented later): 1. The 'Verified Boot' sequence is not supported 2. dev path to system partition (system_a or system_b) is passed via 'bootargs' as 'root=' argument like 'root=/dev/mmcblk1p12', but further we'll need to rework it with respect to dm-verity requirements [2] In case when A/B partitions are not present in system (and A/B boot is enabled), boot up process will be terminated and next message will be shown: "boot_a(b) partition not found" [1] https://source.android.com/devices/tech/ota/ab [2] https://source.android.com/devices/tech/ota/ab/ab_implement#kernel Signed-off-by: Ruslan Trofymenko Reviewed-by: Alistair Strachan Reviewed-by: Sam Protsenko Reviewed-by: Simon Glass Reviewed-by: Igor Opaniuk --- Changes in v2: * Сhanges related to command renaming (android_ab_select -> ab_select) * Slotted sections (e.g. system_a and system_b) are added to the default sections if CONFIG_CMD_AB_SELECT flag is defined * Rebased on top of master * system partitions sizes increased to 1024 MiB (to be consistent with recent changes to boot.h file) include/environment/ti/boot.h | 58 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index 5891009..e3ba689 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -23,6 +23,18 @@ #define VBMETA_PART "" #endif +#if defined(CONFIG_CMD_AB_SELECT) +#define COMMON_PARTS \ + "name=boot_a,size=10M,uuid=${uuid_gpt_boot_a};" \ + "name=boot_b,size=10M,uuid=${uuid_gpt_boot_b};" \ + "name=system_a,size=1024M,uuid=${uuid_gpt_system_a};" \ + "name=system_b,size=1024M,uuid=${uuid_gpt_system_b};" +#else +#define COMMON_PARTS \ + "name=boot,size=10M,uuid=${uuid_gpt_boot};" \ + "name=system,size=1024M,uuid=${uuid_gpt_system};" +#endif + #ifndef PARTS_DEFAULT /* Define the default GPT table for eMMC */ #define PARTS_DEFAULT \ @@ -40,8 +52,7 @@ "name=efs,size=16M,uuid=${uuid_gpt_efs};" \ "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \ "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \ - "name=boot,size=10M,uuid=${uuid_gpt_boot};" \ - "name=system,size=768M,uuid=${uuid_gpt_system};" \ + COMMON_PARTS \ "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \ "name=cache,size=256M,uuid=${uuid_gpt_cache};" \ "name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \ @@ -63,6 +74,35 @@ #define AVB_VERIFY_CMD "" #endif +#define CONTROL_PARTITION "misc" + +#if defined(CONFIG_CMD_AB_SELECT) +#define AB_SELECT \ + "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ + "then " \ + "echo " CONTROL_PARTITION \ + " partition number:${control_part_number};" \ + "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ + "else " \ + "echo " CONTROL_PARTITION " partition not found;" \ + "exit;" \ + "fi;" \ + "setenv slot_suffix _${slot_name};" \ + "if part number mmc ${mmcdev} system${slot_suffix} " \ + "system_part_number; then " \ + "setenv bootargs_ab " \ + "ro root=/dev/mmcblk${mmcdev}p${system_part_number} " \ + "rootwait init=/init skip_initramfs " \ + "androidboot.slot_suffix=${slot_suffix};" \ + "echo A/B cmdline addition: ${bootargs_ab};" \ + "setenv bootargs ${bootargs} ${bootargs_ab};" \ + "else " \ + "echo system${slot_suffix} partition not found;" \ + "fi;" +#else +#define AB_SELECT "" +#endif + #define DEFAULT_COMMON_BOOT_TI_ARGS \ "console=" CONSOLEDEV ",115200n8\0" \ "fdtfile=undefined\0" \ @@ -91,10 +131,16 @@ "mmc dev $mmcdev; " \ "mmc rescan; " \ AVB_VERIFY_CHECK \ - "part start mmc ${mmcdev} boot boot_start; " \ - "part size mmc ${mmcdev} boot boot_size; " \ - "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \ - "bootm ${loadaddr}#${fdtfile};\0 " + AB_SELECT \ + "if part start mmc ${mmcdev} boot${slot_suffix} boot_start; " \ + "then " \ + "part size mmc ${mmcdev} boot${slot_suffix} " \ + "boot_size; " \ + "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \ + "bootm ${loadaddr}#${fdtfile}; " \ + "else " \ + "echo boot${slot_suffix} partition not found; " \ + "fi;\0" #ifdef CONFIG_OMAP54XX