From patchwork Wed Feb 16 06:15:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543040 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090503imn; Tue, 15 Feb 2022 22:16:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV4CumeV2/gDEIohEaf5pa3B7h7nh4XDsfCWn1XI/RlZ2ZuLH+Pl75LDqaflZGEDm7iMHZ X-Received: by 2002:a17:907:234c:b0:6cd:7ca0:8423 with SMTP id we12-20020a170907234c00b006cd7ca08423mr1113250ejb.218.1644992160743; Tue, 15 Feb 2022 22:16:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992160; cv=none; d=google.com; s=arc-20160816; b=DWjP8FfEaKklE11l0u1n/iiNGXHumipA7eHEItAvQCc7bTbySXgo7H6rb+OFffAT38 Rh+0k4e3bTEOFj76UvifT6FOnjQ/GnArS0YbvLMZLUOOPVROU3AlQn7E10nB/1hiqQkB XS/LW2Skjehxh+qISCFdygEgGwYyM5Yzp4BFzoLCuKu68lifeXe5p7vluo6kgx6UIUHU HVr0PTjIlL70ljhzNCn7immPFogQYC5E3dX1klW93TlzWv6YjPzoWvG4CF5iVj7voANE /SEThPnwHVQFqGMSVqhfp9VVNpGRQpYjmKThI8TUDgb4RJ3b9TEnCjX7erC026ICNZeq yhkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=XU/XvCB5GBh7rbgCYtx1g1/zzRC3wTTXfCCp8nOMpvY=; b=JkrHkBZoVhNVm878+yZfB8LSFxfw0IBOM2ZMdnO/Nui7km//2ED4ycG6Ujm/GOa6gD dZtEvJuzRSetsW/893yqWdcaqXQ/g2H0gTJ+AkvfcrH2nIBeWBrrMa1gM6HA3OXx9V9T B3dor9Yeu6Vhk9OqbnC71kRWxGF6QPpKJ3a7vxhEPKql4lpizOkkTQdYxqoU2XtzFM6w 0Fj4JSjYfeJXvSb1Pf+C4gq3KKxsdVJXd1i/o2g0/7PbVdi4H+XEfBnaLww4ob36Gv0F +ou8j02BcbrwcRbM1h8WblSRTSvYBz76yvLiK7TD+pBt1r+3OxlsHQCEaipZNZv+0lGU Oa+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oLO+zBg4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id qo14si1743192ejb.870.2022.02.15.22.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:00 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oLO+zBg4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99B5183A5A; Wed, 16 Feb 2022 07:15:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oLO+zBg4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F7F183A41; Wed, 16 Feb 2022 07:15:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 904E2839EB for ; Wed, 16 Feb 2022 07:15:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pl1-x62e.google.com with SMTP id u12so1201640plf.13 for ; Tue, 15 Feb 2022 22:15:48 -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 :user-agent:mime-version:content-transfer-encoding; bh=XU/XvCB5GBh7rbgCYtx1g1/zzRC3wTTXfCCp8nOMpvY=; b=oLO+zBg4knlJ3UhFeFyHVGR4eDqJJdjjpR1qqzyB5am0CYSF5WbrOAhRAlnKxteLIq oB/vbVBGVNogMcsm8CLyco6ansbUJA/GFEpvs6QNqemqPQQSjmeqeKOBVTfoU3gum5// h1BIq7zEArdfuzAWB3ll0+LjgXQCCtZOgzsJgaDxyKY+9GHZHHMRonMs1/rm+bTgtxEH W37c4q6abocOnUQPYszuvIZR6jcvJOUjgBtYE45k2lJIS/k/R2gArT8RnjrJlHW3ix4W uigYUt0CrZePOJ+gGUuWmiE1TB/eqFIGyEc2xp80viStbVPAjjibqhq3SMzXqtF3XMEN NEAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=XU/XvCB5GBh7rbgCYtx1g1/zzRC3wTTXfCCp8nOMpvY=; b=pxGKITqA5L+WnJ2SyNLexDaVQQy7EEvftusljQwODnKLKzkSgciWQ+Q0rrEmmGdaXj aubHCjTaBqKi4/1XAPH8G0Av59S7MGWsO4EUHQPW3Q7hLap29bD/2jqD9MwiTkp/VBGN mGDJYRTodeQSB1pBih14LAgdXr0MKo5Agj3YO/qW41xW34BocJwqHLjuMmAdN8lgf66E EyXipC6ozaqqLpw+MB6gXBGsNFkgp/lSkguNDgWTj+1SzFLIedoEetNKf4d+IMr4lHL8 zBf4tbLGqPHDxWeXrCa4CcMrp4ElEvrbqoJ251vzXzagnlc7ODHczIfmlTYY43Ra9FQz WG0g== X-Gm-Message-State: AOAM5323M0kHTHU1+dcf6hGRMEIFW9cd8xkY04pR/X02C6NnBwt42gEY sVaVC3EO9miEzoIo9lY9DQSx79HHZMXalw== X-Received: by 2002:a17:902:e8c2:b0:14d:80cb:dbc with SMTP id v2-20020a170902e8c200b0014d80cb0dbcmr1092043plg.142.1644992146638; Tue, 15 Feb 2022 22:15:46 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id a9sm1644421pfl.124.2022.02.15.22.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:15:46 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v5 1/4] efi_loader: use efi_update_capsule_firmware() for capsule on disk Date: Wed, 16 Feb 2022 15:15:42 +0900 Message-Id: <164499214202.688621.9498927693969899089.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164499213192.688621.17382243642029677399.stgit@localhost> References: <164499213192.688621.17382243642029677399.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Since the efi_update_capsule() represents the UpdateCapsule() runtime service, it has to handle the capsule flags and update ESRT. However the capsule-on-disk doesn't need to care about such things. Thus, the capsule-on-disk should use the efi_capsule_update_firmware() directly instead of calling efi_update_capsule(). This means the roles of the efi_update_capsule() and capsule-on-disk are different. We have to keep the efi_update_capsule() for providing runtime service API at boot time. Suggested-by: AKASHI Takahiro Signed-off-by: Masami Hiramatsu Reviewed-by: Heinrich Schuchardt --- Changes in v4: - Update patch description. --- lib/efi_loader/efi_capsule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index f4519c7317..d8141176df 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -1118,7 +1118,7 @@ efi_status_t efi_launch_capsules(void) index = 0; ret = efi_capsule_read_file(files[i], &capsule); if (ret == EFI_SUCCESS) { - ret = EFI_CALL(efi_update_capsule(&capsule, 1, 0)); + ret = efi_capsule_update_firmware(capsule); if (ret != EFI_SUCCESS) log_err("Applying capsule %ls failed\n", files[i]); From patchwork Wed Feb 16 06:15:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543041 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090637imn; Tue, 15 Feb 2022 22:16:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJywUDo0AyK/GzOhCSQ46cqfgUiG18lezRR4NwX5YhRAsIKuKQEVK4F80iSVNYSRdLHpAI3G X-Received: by 2002:a05:6402:349:b0:410:a0bd:35ad with SMTP id r9-20020a056402034900b00410a0bd35admr1342481edw.12.1644992177020; Tue, 15 Feb 2022 22:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992177; cv=none; d=google.com; s=arc-20160816; b=kpuV6KrCuuu1x7Tvl8kpSpelDuiCp43dxQUGb8xc8PekSolsbpW4L3JscYtkVsZDNi oNV0hCCG7hB99SfnDJ/hp7+n6OFS3aRe7cFjagMvm/8NOwq4nd9HtDvSiFFh2vrzOJTE Kjkp+rUSqPa/bLrkitxNBN8y9SVf135vyrKXZUZBOiuZOZN1Iz/vC50tUjrhoIIXlMVS 3ZeIxT11gZMU3IRCyovr3Nk6YylZkFX0zpl9MIRI/CI8H5tF0H7BlCGyKZmC0URBQ+W7 cdbOjmthlQDpcjrj/Slb9sx6CBaJQ6GMF3NZJvPh1FJjEJ+IzmtTsDl4X1e7F365PZdc RU1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gvU4w67g5o/oDmUQA8J5u0oVm1JiCU+boU2O6MKmaVc=; b=gA101X+DYO41y+cBTs+TU2aOckX4j0fk4/JryiOVsbbUO3FxOvknaREUVd1V0HU4tX NFD3Q+WQoSADlVBbwAz7J5dIpMCGIQZ6lZe3HMZQgdi8GyeJzVcOHbBsa7Br9VGyo3LF 7cjHhufBDoAvIc/mvc5omZGovUjzguKTuLI8xrClVh3aWf3C2oVUNQeyvbMucMECsueO xYW4bEAaiTQ0DkPrNYEMrhz+4HvnULuD3sXRsVHIOX70bKa0RYVxeODx4yVFuGS4qzIa S9utRZcoMmtAdORGqQyokG/I3ZvXUeRKcXiOwY0bDEyl+L33qp5HVnGe9Ft9lPuPaNGU 3M7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sb7WV8yh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id he34si4061269ejc.18.2022.02.15.22.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:17 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sb7WV8yh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC0A683A3C; Wed, 16 Feb 2022 07:16:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Sb7WV8yh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C4E7283A3C; Wed, 16 Feb 2022 07:16:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2748983A5C for ; Wed, 16 Feb 2022 07:15:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pf1-x432.google.com with SMTP id c4so1324034pfl.7 for ; Tue, 15 Feb 2022 22:15:59 -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 :user-agent:mime-version:content-transfer-encoding; bh=gvU4w67g5o/oDmUQA8J5u0oVm1JiCU+boU2O6MKmaVc=; b=Sb7WV8yhoEQDIKRO+HezUvDACKAo3m+/CSozdLvlcTtcaRqLQ1FaevHzUwOHDLh4NT Br2Nkx8tdxla1fGKIOrjRaYWjEGlg3prS1WEp1Ekgd7JTXQy1FtGFbPaPh4+ikQQvYZP /JESOVgweuA05wTFRdJuql3SvPfRth9KVazLU8swA60CIZ9Jn4yoeo7gW+DSKRhhJbjh wwF5E0SGnJaB7XiRxrWcNB/Mp4KPpq9nwbesb+xB1Sz5Yhtky2B0kaXGi1w0VgOe3iEO aiLZEbyOEyDyD2J3JX/T/TGXZW4NM+SgqsnHT7eCniUq2EMSldY/EUTG282vAQyE1eKZ LqsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=gvU4w67g5o/oDmUQA8J5u0oVm1JiCU+boU2O6MKmaVc=; b=GcJq24FXpSEABzzkWfmw25xksBmOLLFPMbzgepnxOyHitfp2cCmZzilSPpz9wilee0 XeaY2Xu4hf1QJBoROc50PqAhxFNEB9E/KhiQvZF4bHwk8t+V8mRFl9NPM0v1CWYkGtjR TD3dClNg8f0vXQuQQeXKRTnzo0/gNVRsFlvcSMwCtjRg32IMS3OudzP/5CuSxCr5V4bw h5R+zLaGPCwTjDHyusheoEtuHGP9u5AfPiyZEsXbFJ1ERDBTFRZ/uKevqlLrlLfJHjek rrG9dJD9U0oTYcxmuBprty2Ds8o7BzMmOQOlP7zXm0iyAFn7nvM+nBav/xEsdN0xXNEE on9g== X-Gm-Message-State: AOAM532WJ4mXyBhVKSVgpWAR6UeFu2cjI+EMhNB6j2QRhlooWio4iKY/ p2FROeYu5AzLmYg7pfIlMYbg7Zt+pPvc8Q== X-Received: by 2002:a63:f053:0:b0:364:cff3:55f8 with SMTP id s19-20020a63f053000000b00364cff355f8mr1009882pgj.578.1644992157125; Tue, 15 Feb 2022 22:15:57 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id i3sm4284702pgq.65.2022.02.15.22.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:15:56 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v5 2/4] test/py: Handle expected reset by command Date: Wed, 16 Feb 2022 15:15:52 +0900 Message-Id: <164499215201.688621.12198458581018156227.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164499213192.688621.17382243642029677399.stgit@localhost> References: <164499213192.688621.17382243642029677399.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add wait_for_reboot optional argument to ConsoleBase::run_command() so that it can handle an expected reset by command execution. This is useful if a command will reset the sandbox while testing such commands, e.g. run_command("reset", wait_for_reboot = True) Signed-off-by: Masami Hiramatsu --- Changes in v5: - Split the wait-for-boot-prompt code as an internal function so that it is able to be shared with ensure_spawned(). - Fix wait_for_reboot parameter description. --- test/py/u_boot_console_base.py | 99 +++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 384fd53c65..afae07d9cc 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -139,8 +139,53 @@ class ConsoleBase(object): self.p.close() self.logstream.close() + def wait_for_boot_prompt(self): + """Wait for the boot up until command prompt. This is for internal use only. + """ + try: + bcfg = self.config.buildconfig + config_spl = bcfg.get('config_spl', 'n') == 'y' + config_spl_serial = bcfg.get('config_spl_serial', 'n') == 'y' + env_spl_skipped = self.config.env.get('env__spl_skipped', False) + env_spl2_skipped = self.config.env.get('env__spl2_skipped', True) + + if config_spl and config_spl_serial and not env_spl_skipped: + m = self.p.expect([pattern_u_boot_spl_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL console: ' + + self.bad_pattern_ids[m - 1]) + if not env_spl2_skipped: + m = self.p.expect([pattern_u_boot_spl2_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL2 console: ' + + self.bad_pattern_ids[m - 1]) + m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 1]) + self.u_boot_version_string = self.p.after + while True: + m = self.p.expect([self.prompt_compiled, + pattern_stop_autoboot_prompt] + self.bad_patterns) + if m == 0: + break + if m == 1: + self.p.send(' ') + continue + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 2]) + + except Exception as ex: + self.log.error(str(ex)) + self.cleanup_spawn() + raise + finally: + self.log.timestamp() + def run_command(self, cmd, wait_for_echo=True, send_nl=True, - wait_for_prompt=True): + wait_for_prompt=True, wait_for_reboot=False): """Execute a command via the U-Boot console. The command is always sent to U-Boot. @@ -168,6 +213,9 @@ class ConsoleBase(object): wait_for_prompt: Boolean indicating whether to wait for the command prompt to be sent by U-Boot. This typically occurs immediately after the command has been executed. + wait_for_reboot: Boolean indication whether to wait for the + reboot U-Boot. If this sets True, wait_for_prompt must also + be True. Returns: If wait_for_prompt == False: @@ -202,11 +250,14 @@ class ConsoleBase(object): self.bad_pattern_ids[m - 1]) if not wait_for_prompt: return - m = self.p.expect([self.prompt_compiled] + self.bad_patterns) - if m != 0: - self.at_prompt = False - raise Exception('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 1]) + if wait_for_reboot: + self.wait_for_boot_prompt() + else: + m = self.p.expect([self.prompt_compiled] + self.bad_patterns) + if m != 0: + self.at_prompt = False + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 1]) self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt # Only strip \r\n; space/TAB might be significant if testing @@ -349,41 +400,7 @@ class ConsoleBase(object): if not self.config.gdbserver: self.p.timeout = 30000 self.p.logfile_read = self.logstream - bcfg = self.config.buildconfig - config_spl = bcfg.get('config_spl', 'n') == 'y' - config_spl_serial = bcfg.get('config_spl_serial', - 'n') == 'y' - env_spl_skipped = self.config.env.get('env__spl_skipped', - False) - env_spl2_skipped = self.config.env.get('env__spl2_skipped', - True) - if config_spl and config_spl_serial and not env_spl_skipped: - m = self.p.expect([pattern_u_boot_spl_signon] + - self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on SPL console: ' + - self.bad_pattern_ids[m - 1]) - if not env_spl2_skipped: - m = self.p.expect([pattern_u_boot_spl2_signon] + - self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on SPL2 console: ' + - self.bad_pattern_ids[m - 1]) - m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 1]) - self.u_boot_version_string = self.p.after - while True: - m = self.p.expect([self.prompt_compiled, - pattern_stop_autoboot_prompt] + self.bad_patterns) - if m == 0: - break - if m == 1: - self.p.send(' ') - continue - raise Exception('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 2]) + self.wait_for_boot_prompt() self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt except Exception as ex: From patchwork Wed Feb 16 06:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543042 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090762imn; Tue, 15 Feb 2022 22:16:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwW5nLdzKb5ep2pRkht/rBwweEL3ThSVbg+WajspwlH1l5DqP+Av2kKt4GA9wfkpew4mysv X-Received: by 2002:a17:906:bc46:b0:6cd:e855:18fc with SMTP id s6-20020a170906bc4600b006cde85518fcmr1016581ejv.263.1644992191079; Tue, 15 Feb 2022 22:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992191; cv=none; d=google.com; s=arc-20160816; b=0Ef1acMTiHbXuutQdADPRf371hGQlG6kuliUYWm2xMpMVD0eCnx6QEw1ZaEc/DbLmy jWid8cs4tKRS3iLZvjiLVpHWiuOUDCjoZm7F8pkKNdIPIzHkFJzj3NoZoVILNASESDfP 61tJCHnMrpF/7xAKjIpD1VEVZAEZptLhic7wOWdvkTKTkdI5DhKPety6HQyIuxdquFdO k91dIORsAcnTTYpXBKNAWznPhCSiILMMT3t42QWBkEtEWu+ICbZ7Q19N3sSjtd8pTgtj hUJB3pQ8tDIpTfL00k/ilossx9mFV3zEporCEEW2KcscodDXnTlDccJtSkPsyE2xgHCP wWrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=bgxY9nSI15ZZyavE+mtMTVzzTw7FqNqYxwYLBLhJ0rU=; b=mxXkpEm3gPrZqVhrGqTMDAmQ+MvJHzC6wdBS5WNGCQsUsXXNgqUHCRFu7OHCquKEMf LtqDmqVZ8pq4sG01aFR+3jSQjamL6HsqahjuHKdZVKRFRvyQslivzbqRNW8qQj/+2JVx iSLKS2Y7aR4+YFOgkk6DMGJAcJiUtZ9WKNAGAK2slYj8cF+LsIg8v81Dx8dPTao6YfwH yj5sWzj4y4R1neYXgpsdxFvQvtBXpTftWpmefN4QgZn7M095izjqWo4cqpdPkeucYJ9F tLq5Bfhd2QhAy1UrpjvkQGKaTmlHNUZO5h3bEC2lys22C4eMK3HL0dE1O/1wsoX+0n3R BVXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Moqzu1ny; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 11si18086054eje.845.2022.02.15.22.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:31 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Moqzu1ny; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9E3C8366F; Wed, 16 Feb 2022 07:16:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Moqzu1ny"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C9088839EC; Wed, 16 Feb 2022 07:16:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E551B83A6E for ; Wed, 16 Feb 2022 07:16:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pl1-x635.google.com with SMTP id c3so1232390pls.5 for ; Tue, 15 Feb 2022 22:16:08 -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 :user-agent:mime-version:content-transfer-encoding; bh=bgxY9nSI15ZZyavE+mtMTVzzTw7FqNqYxwYLBLhJ0rU=; b=Moqzu1ny0yby1JzeAc/DQOYe2pnwIyKDn2uUenuNwOWdTVtfGiNTpQpvDEgiEQnWCs goWrrJw613YuLhIu4JWvJUTwvtBp86GrWtxkVgss2shW6/SKRIJMZvzZzfvWzhdhjIPi elmsmkGsBmixR6cP/lzDAUeOsRYEsRaCizZhYLZgM1Q8ndg3Omyw0iGnJ3iAvK/kSK9B 1lBCAb/52MW4KYOZh2nnQIRS0yvMbwsS55N3xIXsa5qRJq3J+QD1s82SIAeN78WpW1z9 uI+hLYJtuO/ZCadPfgYyf25vRKtD7DdrPd+gOD0JxVz4orMWBWyJx6+cjiC7e7rZzs2M rrNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=bgxY9nSI15ZZyavE+mtMTVzzTw7FqNqYxwYLBLhJ0rU=; b=Q0UQzXN7myinhg5h54m/+HKHqYP0PACUJEe9LyV5mUgFOC+EfKqedd4gUXtbIYm1JK 61jmyGasK2ve+m9Bl0DB0T5l92gHX7PJQaU6mbM7HwNqhad7myPRavvKhgKv+wYZFlS6 D8gi7nUpu3g9tO+2Rd6veeFZizGZIfOahOMCx0o9JgQZeKzH3EvrEpVtxDG4owd22UmZ bsHIUpuCl1b8WdfeHqGUDEyDAcZapY7YFKl2zZysaOPtYx2IMxluM1Nlhqj0AHq7dRiu 8t/APVTzt+0iXiwuHndIgBQXE6LbLYhEL9K++zqZgpJBH6Hts96GsHwJhi2fznzEZPI9 KoVQ== X-Gm-Message-State: AOAM5326v54oOx7D/sY5gQNQJ0hbIRzrNtFmE5PJalMi20SVg7DPCIPt j1zscgiB74F7A7ZZplKl6lle42YmN0JV/A== X-Received: by 2002:a17:90a:4308:b0:1b8:bed5:c747 with SMTP id q8-20020a17090a430800b001b8bed5c747mr85197pjg.0.1644992167102; Tue, 15 Feb 2022 22:16:07 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id e8sm25356960pfv.168.2022.02.15.22.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:06 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v5 3/4] test/py: Handle expected reboot while booting sandbox Date: Wed, 16 Feb 2022 15:16:02 +0900 Message-Id: <164499216253.688621.5866897494911875372.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164499213192.688621.17382243642029677399.stgit@localhost> References: <164499213192.688621.17382243642029677399.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add expected_reset optional argument to ConsoleBase::ensure_spawned(), ConsoleBase::restart_uboot() and ConsoleSandbox::restart_uboot_with_flags() so that it can handle a reset while the 1st boot process after main boot logo before prompt correctly. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Rename parameter to expect_reset and update the description to clarify the reset will happen between main boot and the command prompt. --- test/py/u_boot_console_base.py | 48 ++++++++++++++++++++++--------------- test/py/u_boot_console_sandbox.py | 7 ++++- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index afae07d9cc..3938ec1302 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -139,7 +139,7 @@ class ConsoleBase(object): self.p.close() self.logstream.close() - def wait_for_boot_prompt(self): + def wait_for_boot_prompt(self, loop_num = 1): """Wait for the boot up until command prompt. This is for internal use only. """ try: @@ -149,22 +149,24 @@ class ConsoleBase(object): env_spl_skipped = self.config.env.get('env__spl_skipped', False) env_spl2_skipped = self.config.env.get('env__spl2_skipped', True) - if config_spl and config_spl_serial and not env_spl_skipped: - m = self.p.expect([pattern_u_boot_spl_signon] + - self.bad_patterns) + while loop_num > 0: + loop_num -= 1 + if config_spl and config_spl_serial and not env_spl_skipped: + m = self.p.expect([pattern_u_boot_spl_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL console: ' + + self.bad_pattern_ids[m - 1]) + if not env_spl2_skipped: + m = self.p.expect([pattern_u_boot_spl2_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL2 console: ' + + self.bad_pattern_ids[m - 1]) + m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns) if m != 0: - raise Exception('Bad pattern found on SPL console: ' + - self.bad_pattern_ids[m - 1]) - if not env_spl2_skipped: - m = self.p.expect([pattern_u_boot_spl2_signon] + - self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on SPL2 console: ' + + raise Exception('Bad pattern found on console: ' + self.bad_pattern_ids[m - 1]) - m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 1]) self.u_boot_version_string = self.p.after while True: m = self.p.expect([self.prompt_compiled, @@ -372,7 +374,7 @@ class ConsoleBase(object): finally: self.p.timeout = orig_timeout - def ensure_spawned(self): + def ensure_spawned(self, expect_reset=False): """Ensure a connection to a correctly running U-Boot instance. This may require spawning a new Sandbox process or resetting target @@ -381,7 +383,9 @@ class ConsoleBase(object): This is an internal function and should not be called directly. Args: - None. + expect_reset: Boolean indication whether this boot is expected + to be reset while the 1st boot process after main boot before + prompt. False by default. Returns: Nothing. @@ -400,7 +404,11 @@ class ConsoleBase(object): if not self.config.gdbserver: self.p.timeout = 30000 self.p.logfile_read = self.logstream - self.wait_for_boot_prompt() + if expect_reset: + loop_num = 2 + else: + loop_num = 1 + self.wait_for_boot_prompt(loop_num = loop_num) self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt except Exception as ex: @@ -433,10 +441,10 @@ class ConsoleBase(object): pass self.p = None - def restart_uboot(self): + def restart_uboot(self, expect_reset=False): """Shut down and restart U-Boot.""" self.cleanup_spawn() - self.ensure_spawned() + self.ensure_spawned(expect_reset) def get_spawn_output(self): """Return the start-up output from U-Boot diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index 7e1eb0e0b4..ce4ca7e55e 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -57,11 +57,14 @@ class ConsoleSandbox(ConsoleBase): cmd += self.sandbox_flags return Spawn(cmd, cwd=self.config.source_dir) - def restart_uboot_with_flags(self, flags): + def restart_uboot_with_flags(self, flags, expect_reset=False): """Run U-Boot with the given command-line flags Args: flags: List of flags to pass, each a string + expect_reset: Boolean indication whether this boot is expected + to be reset while the 1st boot process after main boot before + prompt. False by default. Returns: A u_boot_spawn.Spawn object that is attached to U-Boot. @@ -69,7 +72,7 @@ class ConsoleSandbox(ConsoleBase): try: self.sandbox_flags = flags - return self.restart_uboot() + return self.restart_uboot(expect_reset) finally: self.sandbox_flags = [] From patchwork Wed Feb 16 06:16:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543043 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090830imn; Tue, 15 Feb 2022 22:16:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoGwzScFZSN5dr9WZcP8GRdjRgR0DcIPlIcQobVNo6adlk9G/dMN7UGXv10CODo4DoRkoZ X-Received: by 2002:a50:c04c:0:b0:410:b929:d658 with SMTP id u12-20020a50c04c000000b00410b929d658mr1346327edd.5.1644992200479; Tue, 15 Feb 2022 22:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992200; cv=none; d=google.com; s=arc-20160816; b=ELvO9BDet1ch2WnZFhtQXg/6SxmNgSkj8CgwbT/fx+cKhx9naNrgS2jjGZQ+S211EK d4k2EsoezLFaTponVVZCthtj6B9jGqp8A3PV2J3civ4szlVDVjq5dUqhx3tTwBApdTaa NTHr41KXEqeaROmZlXtYVNTSsgAr5CLbzDPkgLTd+jbMmOHo8nSBH0ZPYIuWmdyzF5fT mJCtz0tKYFqRrbhBHxWUhvTxSrnB0LyRIB6MLJ27bCfNkD7IenVb7tQ90imo5MNR8K9w NbuSyhzTG23Dwn+HkwQVHLUJwT+k3lMlFHzg/OZLVXEiV5/W0ynDu6V4x8BZdsZgutbr 7dPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=LumW1kbBw+ZbXeaNx023/i11I6rVSgeSVwxqUko2df0=; b=t8BtzvOnQtfqJloMxLKbVeCzq3q+8FzAK+E9U0iYp9WrzUeOQ8387absRr4teJziIG B958ydyh5m2NZgz2dcEh3C0kL+06gkJ/xHKxcJvcLabCC/kFmfvtB9XPCaRm37VvYFjy nBfWsg4l7mX6ReNHgJglMnr130vnUReV0/RSazsG6QlSWRGNMsCinM6V7SOJaYARqQKp jmKHxYCR9xjg3wWzfRcK+RkMijbNe/nVm5HniDN5AnXEi57igrX6cvPbwyjAqXs5w0NR G8XFiLNT7vL6M6L6D97UGlimt4X28D33z8gcsfpGfnq/XplY/qEwSPVOHpvf86jU7DR7 TR8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lBb9rvPQ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z7si1451629edb.146.2022.02.15.22.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:40 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lBb9rvPQ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A0FA839FB; Wed, 16 Feb 2022 07:16:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lBb9rvPQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85CF68380E; Wed, 16 Feb 2022 07:16:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DFE00838F4 for ; Wed, 16 Feb 2022 07:16:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pj1-x102b.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso5518731pjt.4 for ; Tue, 15 Feb 2022 22:16:18 -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 :user-agent:mime-version:content-transfer-encoding; bh=LumW1kbBw+ZbXeaNx023/i11I6rVSgeSVwxqUko2df0=; b=lBb9rvPQ6DuRGm/jHDKQfgCPZaeVRt91HDXbfD8qPgnzN6s8Gi0EboiQjMuODdYUom GDUZrsyF8DXEbYVe3ntoUj8LbxY4lwSbLjld98d38FtBX+1wkS1OOHMgHE4OYHXMwpB9 wKAZer6dmAD+lCAL6xS5BEfunYeO+AH91Q9sdft1I1ix83eLxjKGGpvj78qpmhESH1/3 DDueAHFqLOADK1uVnQfHVGXVRgPuGwu2pwBGB1LiC9/W8ne+FrCs4lTNi6kQplS1JS96 wp5tzIlzsV4Du3sTMuzv7bLyRqPtEIkyWY/zqduIZB17jzfHfZgXTlgItu1Kg4NonzO4 PUWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=LumW1kbBw+ZbXeaNx023/i11I6rVSgeSVwxqUko2df0=; b=Yifjnqk5VH1yPTWPJoy90pJi3O2XcNjl4HN5aXHZxtNsmpATjCKkgtuOlwE+AL2W0p Vlz4AhbPlyYehkcbqY/5XekyU+eDLdxeGQWKV+yAA93xjR7Hcy8fTGSbvk9IQ6e9YdnD nusZYnh9VtK6SrpiT+onrrN1zFiat5LpKGzfwfpUc0aRqgbkFSzAPpdaHhB4Rv/9CsX6 nn/fJMrrchLpcH9eHjblsn9hwMrIir5IK+T6vSa0rrQLfNlU7CA48z6eMtG3yH/392UH a4u2mWUwNdc/exzD7LeXSGdiiV4/sGzRZItQZ1ATQSRwvUECPzkNLqWosUxiNeSDdqBT 3O7w== X-Gm-Message-State: AOAM530U+2YhM5PYORq4gpg4PMRzt02jKFND3nEnGKRiK1vIAlVIhh5M O++3obQu0F3EZPIIX3PEx/vZJ8sMeiMisg== X-Received: by 2002:a17:903:11cc:b0:14d:a0d5:76f with SMTP id q12-20020a17090311cc00b0014da0d5076fmr1375846plh.109.1644992177048; Tue, 15 Feb 2022 22:16:17 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id j7sm39017952pfa.36.2022.02.15.22.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:16 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v5 4/4] efi_loader: test/py: Reset system after capsule update on disk Date: Wed, 16 Feb 2022 15:16:12 +0900 Message-Id: <164499217249.688621.8559174804587563729.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164499213192.688621.17382243642029677399.stgit@localhost> References: <164499213192.688621.17382243642029677399.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add a cold reset soon after processing capsule update on disk. This is required in UEFI specification 2.9 Section 8.5.5 "Delivery of Capsules via file on Mass Storage device" as; In all cases that a capsule is identified for processing the system is restarted after capsule processing is completed. This also reports the result of each capsule update so that the user can notice that the capsule update has been succeeded or not from console log. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Update testcase because this will change the expected behavior. - Merge dfu_alt_info setting with showing esrt command. - Remove redundant assertion from the test update. Changes in v4: - Do not use sysreset because that is a warm reset. - Fix patch description. --- lib/efi_loader/efi_capsule.c | 18 +++++++++- .../test_efi_capsule/test_capsule_firmware.py | 37 ++++++++++++-------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index d8141176df..613b531b82 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1120,8 +1121,11 @@ efi_status_t efi_launch_capsules(void) if (ret == EFI_SUCCESS) { ret = efi_capsule_update_firmware(capsule); if (ret != EFI_SUCCESS) - log_err("Applying capsule %ls failed\n", + log_err("Applying capsule %ls failed.\n", files[i]); + else + log_info("Applying capsule %ls succeeded.\n", + files[i]); /* create CapsuleXXXX */ set_capsule_result(index, capsule, ret); @@ -1142,6 +1146,16 @@ efi_status_t efi_launch_capsules(void) free(files[i]); free(files); - return ret; + /* + * UEFI spec requires to reset system after complete processing capsule + * update on the storage. + */ + log_info("Reboot after firmware update"); + /* Cold reset is required for loading the new firmware. */ + do_reset(NULL, 0, 0, NULL); + hang(); + /* not reach here */ + + return 0; } #endif /* CONFIG_EFI_CAPSULE_ON_DISK */ diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py b/test/py/tests/test_efi_capsule/test_capsule_firmware.py index 6e803f699f..1dcf1c70f4 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -143,13 +143,14 @@ class TestEfiCapsuleFirmwareFit(object): 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test01' in ''.join(output) - # reboot - u_boot_console.restart_uboot() - capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') capsule_auth = u_boot_config.buildconfig.get( 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 2-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -162,7 +163,7 @@ class TestEfiCapsuleFirmwareFit(object): # need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') + 'env print -e Capsule0000', wait_for_reboot = True) output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, @@ -218,13 +219,14 @@ class TestEfiCapsuleFirmwareFit(object): 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test02' in ''.join(output) - # reboot - u_boot_console.restart_uboot() - capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') capsule_auth = u_boot_config.buildconfig.get( 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 3-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -237,9 +239,12 @@ class TestEfiCapsuleFirmwareFit(object): # need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') + 'env print -e Capsule0000', wait_for_reboot = True) - output = u_boot_console.run_command_list(['efidebug capsule esrt']) + # make sure the dfu_alt_info exists because it is required for making ESRT. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'efidebug capsule esrt']) # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID is in the ESRT. assert 'AE13FF2D-9AD4-4E25-9AC8-6D80B3B22147' in ''.join(output) @@ -293,13 +298,14 @@ class TestEfiCapsuleFirmwareFit(object): 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test03' in ''.join(output) - # reboot - u_boot_console.restart_uboot() - capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') capsule_auth = u_boot_config.buildconfig.get( 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 4-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -312,9 +318,12 @@ class TestEfiCapsuleFirmwareFit(object): # need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') + 'env print -e Capsule0000', wait_for_reboot = True) - output = u_boot_console.run_command_list(['efidebug capsule esrt']) + # make sure the dfu_alt_info exists because it is required for making ESRT. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'efidebug capsule esrt']) # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID is in the ESRT. assert 'E2BB9C06-70E9-4B14-97A3-5A7913176E3F' in ''.join(output)