From patchwork Tue Nov 27 19:57:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 152169 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp221550ljp; Tue, 27 Nov 2018 12:16:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/UIROeTJjfLuHmFonTQ1gYC1DzF0UnOvu6UluM1qvTo7SlMODL6tPUHkLSv03epOBPbE/wG X-Received: by 2002:a50:b3c9:: with SMTP id t9mr28406501edd.270.1543349762031; Tue, 27 Nov 2018 12:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543349762; cv=none; d=google.com; s=arc-20160816; b=1FkFMox7TlGa1CH1RJ9KMBTStnwO9LXxy5MEkJ+UVE51nsunSvsZkLeu403pLytE2G TaJ1gfYzyCoqP1l8ZGqrJNAmhdPq72Ky0rfs42LAH3dUa8CfUh+r6tn8bnCU3uo5ypgc DzIiDXMWCXBoX8HTf/NL7lB9VX5F4I4kbBCkcJphq7q75KZbXGEc7d2S1grzaHCXJE/O TvEXhf2Zjw7kDeFDFFcV0Y8etD1gRO4iiHixTWZl8bMplAVn2Of4a5EcVIxmFruWmzh7 6J6PHNsV3mo0x9ujqkla9jKyqg+8cVswVoae9i1oMgO5nvuKnS6tm4LhKWon3Ijz1/0s Izrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature; bh=VZ6H9i2aPseda/2dlA2ehdTbtfTY/U53r3Y4/bqkHeE=; b=i5QipvNvlg6pYPmYRE4rifl2fs05gB0deJqIFcoGmeyjwX1TsL/7GR1WiPuRED3mc+ 4hDfiu+gMBEpyQjNNiJ7OCbNvV6NpRINw/OHtG//R39KuFxsJfYr2ZgiZeRsuIz8+zhn J3CQs3gN17yXSn4aNLgDlByeZwTtn/S7yxRFti9whhdVThWAJ6rtNJe6pFlR6XZZEZ94 XLnGcfFYVNJRweaShBGWBVk2XMjm5nlD1Qk2yv0gBlvnnFZSHqf3EhAzhZFyGuPz2z3t p+CMdaMqoHiwZRAH2dd5FHTr1d+MfEl/+pgUZruqH2KzhdJVVSgCA6jG624qNFNQ28Pc bcZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="CwlI/qH/"; 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 v57si621211edc.38.2018.11.27.12.16.01; Tue, 27 Nov 2018 12:16:02 -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="CwlI/qH/"; 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 914E5C222BD; Tue, 27 Nov 2018 20:13:20 +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 4E9F3C22258; Tue, 27 Nov 2018 20:10:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 74A68C21EAE; Tue, 27 Nov 2018 19:57:34 +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 136A1C21DD7 for ; Tue, 27 Nov 2018 19:57:34 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id f23so17499411lfc.13 for ; Tue, 27 Nov 2018 11:57:34 -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=GhuCnt9nw1BTunbAHLO2hw5OzI4cDQJNyjLf5DIPBvY=; b=CwlI/qH/13pQc3z6+Qs6LSUAyhiV35NBewwj+su7ZAc9JPFqHPJtIb6871xBL4M7l1 6RTPum54tOzXD8lHDV4D6a3JvxRDzKmNa6ieYgnfBtW2UjKH1t7Yw6JiTefHpjXoUPt3 YZDMaUblV0ZDBzagHq8krse0sG7unIHSJS7Go= 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=GhuCnt9nw1BTunbAHLO2hw5OzI4cDQJNyjLf5DIPBvY=; b=O+dYL7jInkvjkEJZOkdzG+ffI7hGKVdbQ+Z3faVcJqCyeNbXwIZRwIhrdMlTQfCTSl QphuPbFB5RClsdmf6OeeJj/Zsa26ehHCvhQsPofStpcyLtR8T/i+nv7b4RG8Cbgbb+st Phy3rHBHK8f1NnvQtdl+ueOrJLB3lg6LHCzJqdu+yuZYuLHYMF/1MqFuIIhkTeWH3C1g qzOCTMy/coIEXQ3Vk7SaFnWMybHDmi3ApgAniW4KRvqM9bEaTtMmahLp1Uz8TY0Y++mE jxJVQOwqqMjx/v19qalvAEbqQtOxFrszlM06FBwYBNQ+2pwyS/zrMoY4szYPSMffwULp Nz7g== X-Gm-Message-State: AGRZ1gIo04l96arcevV0wFh1d6+UUCRRxZ97GzehcgYTkDkg/6BAH9kv do71rJjzl4HEv6k5ZeNO7lGDm+mYO98= X-Received: by 2002:a19:5394:: with SMTP id h20mr20349276lfl.75.1543348653305; Tue, 27 Nov 2018 11:57:33 -0800 (PST) Received: from kbp1-dhp-f54913.synapse.com ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id g12-v6sm738725lja.74.2018.11.27.11.57.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Nov 2018 11:57:32 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Tue, 27 Nov 2018 21:57:22 +0200 Message-Id: <1543348642-31045-8-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543348642-31045-1-git-send-email-ruslan.trofymenko@linaro.org> References: <1543348642-31045-1-git-send-email-ruslan.trofymenko@linaro.org> X-Mailman-Approved-At: Tue, 27 Nov 2018 20:10:30 +0000 Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH 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" Add support for A/B boot process on AM57xx based boards: 1. Define 'slot_suffix' variable (using 'android_ab_select' command) 2. Extend 'emmc_android_boot' boot command (add commands for A/B boot process) 'android_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_ANDROID_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 --- include/environment/ti/boot.h | 44 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index 3c9c87f..3ace316 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -63,6 +63,36 @@ #define AVB_VERIFY_CMD "" #endif +#define CONTROL_PARTITION "misc" + +#if defined(CONFIG_CMD_ANDROID_AB_SELECT) +#define AB_SELECT \ + "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ + "then " \ + "echo " CONTROL_PARTITION \ + " partition number:${control_part_number};" \ + "android_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 +121,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