From patchwork Mon Feb 18 16:21:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1044160 X-Patchwork-Delegate: trini@ti.com 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="ufDMIK0Y"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4438NJ0xLBz9s7h for ; Tue, 19 Feb 2019 03:25:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C1C1EC21FC3; Mon, 18 Feb 2019 16:24:08 +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 944F5C21F9B; Mon, 18 Feb 2019 16:22:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 91561C21F98; Mon, 18 Feb 2019 16:22:21 +0000 (UTC) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by lists.denx.de (Postfix) with ESMTPS id 50837C21FC3 for ; Mon, 18 Feb 2019 16:22:15 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id d14so3697759ljl.9 for ; Mon, 18 Feb 2019 08:22:15 -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; bh=R8LorgqMRRMUgyzTZeLzNUqNJbc6d1wCgHzTzT0YgHo=; b=ufDMIK0YF8Zy5XkVnvtWhx2gcWlW+pKGbUXzgL6xVepYtHPP6kMkmEoKg7n40cnCOx B3D/s7lXsD2So89XPPabCfBVta9GUylSxld0GnWKFFejA8o9u/KJNWkx6LW3je3aR2aT j2yDb+ozrhXkLBTnX7fgWPrRMMhfrnzaFak6admGTN9iaKtTjEsPqBbOGULnbjyVOKqs y8HJPwpxdkyPcn2CsItJD7JdLc7omAvTOI/9iDCiVdczhyRXInZPdVZoKhbQCUPGLa21 3MVjSYIHuqpNHJ+FaypQ49WKsC6MgvHVvJmx7+2JYxXIl/0aQezN2H5XvXShimd4asfZ X4Fg== 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; bh=R8LorgqMRRMUgyzTZeLzNUqNJbc6d1wCgHzTzT0YgHo=; b=q21s2FI1fnpS5YqTNg6oXjDDyRRDkD2JPfNeMMEidvZJDKefZJc3Vozf69msJCQlpP 3+oc32iwboTYTLakd5/Rtrk5M0hb9+pQ/qDTQbbaMwYTOicpGXv9vZT5zHlhu1cwm8Bv 174RZv69EdgVZpV84ybbrnMHD/WIduzX5w33tK8kfgM8CW08ODmZ/7NCzDtKb21V0GV5 LQluTnkAS0ejDTcEbE2NLO0XdaN3dK/YDqQmthyxQzxodlaX9O4qJcxJtIoxmuLM/uem L7F3HMnYSCPw45GgE4BOcEhV2L9HyBewbVhjRJT5dzv7TPFKIkA79MBxcQDJUV6XenAU dbRA== X-Gm-Message-State: AHQUAuYIPs8CdOfDf7uwmwkR4ZPOrSMnQsMt2EJnvRwoCPkjvDbFiDi8 cMK4OWwO6jd1kj5IzV5IhN8KoLm+PYE= X-Google-Smtp-Source: AHgI3IbYt27awuFLG8+HNYVtEZGHG0CVMIavWB3KuhKzlLCiGdK8kJXv6Ryuplqe+wIKt434XYynYA== X-Received: by 2002:a2e:85cf:: with SMTP id h15mr14425785ljj.73.1550506933548; Mon, 18 Feb 2019 08:22:13 -0800 (PST) Received: from localhost ([195.238.92.223]) by smtp.gmail.com with ESMTPSA id h123sm3336995lfh.26.2019.02.18.08.22.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 08:22:12 -0800 (PST) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Mon, 18 Feb 2019 18:21:57 +0200 Message-Id: <1550506917-25547-8-git-send-email-igor.opaniuk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550506917-25547-1-git-send-email-igor.opaniuk@linaro.org> References: <1550506917-25547-1-git-send-email-igor.opaniuk@linaro.org> Cc: trini@konsulko.com, deymo@google.com, praneeth@ti.com, astrachan@google.com, semen.protsenko@linaro.org Subject: [U-Boot] [PATCH v3 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Ruslan Trofymenko 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 Signed-off-by: Igor Opaniuk Reviewed-by: Alistair Strachan Reviewed-by: Sam Protsenko Reviewed-by: Simon Glass --- Changes in v3: None Changes in v2: * Add changes 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 05bdbbc..bc05bca 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 \ @@ -38,8 +50,7 @@ "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \ - "name=boot,size=10M,uuid=${uuid_gpt_boot};" \ - "name=system,size=1024M,uuid=${uuid_gpt_system};" \ + COMMON_PARTS \ "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \ VBMETA_PART \ "name=userdata,size=-,uuid=${uuid_gpt_userdata}" @@ -58,6 +69,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" \ @@ -86,10 +126,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