From patchwork Thu Oct 29 00:25:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 319320 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp16331ilc; Wed, 28 Oct 2020 17:29:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjDPy8mASk+jPvmpAvgSqVFRJr8rHFglJoF4tv1LMD+cW27ZebXiXwlX7PjyC+waKotP0K X-Received: by 2002:a50:ef0a:: with SMTP id m10mr1549784eds.116.1603931354913; Wed, 28 Oct 2020 17:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603931354; cv=none; d=google.com; s=arc-20160816; b=DMCeNccHimHtXbSPxXUcEve2QdQs9DFoZ6cobeVwi5hm+zn4jtFAJZFqaqYA79oGna 2M06m2TaEWvdyxPpo9YdnSq+g+ZrsGqYoiLBG8fhFX1ACwNGXhNWOP6ENd1iN80pB2iY +8Nb5LENRokPha0axw6aTXFCoZj4sZswIg7Em2FgQyt69BtKB5Hwu/RfVtdDdq1t4sXD p0vjmS+T/1iimzKFGX/uYaCRRv2YyPBmthgbwwYOZ27ufJifH0NATzjvmaXB9ODZuqW9 QGbym4jNWgpkxySLIq3SVfHkMnApPnYrMoQfhWpyP4Gdf0NgIxlJA5RgACHhqmS5C0Hr njAA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vOZL7HMoUBm2QgX/veSjMfzSO/qPFQVDFF4KFNeP7Lw=; b=IDmQTys8sdVEHlqxweEVBVg/nsq8EsCJUw97eY3qBWU6BDpZl7j3pvMPX5hZU/zToW xC6mA1R4v2G3LEnWeciwLK817wHTWt1G2hOIZGHoPLcLIqe7lGSnOJhxdNH2dDPv6Rat hyokqGEbKp5CjRpj+0w/SBOoRZbF+vJoqxk1JmT1TFUGKaeE33QGLkuI2bhtUEDZDdbY FRnJ1dT07S7G4nCv8e2H+Ut/BvD+i2isrUmcuJrdak+nrdDZTyTYaOY1qa7I7UNNM9+l B6xN750zXdjlzZKaGnlj1RC2HSdWU1k7dIPGDkPkcXl2Y1OyfxQ+/oTuWsiTTT2RnwMV oBYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p1CrF+Q9; 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 b20si650872ejz.383.2020.10.28.17.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 17:29:14 -0700 (PDT) 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=p1CrF+Q9; 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 A593382545; Thu, 29 Oct 2020 01:26: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="p1CrF+Q9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EB4588253E; Thu, 29 Oct 2020 01:26:48 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 AE2D2823F3 for ; Thu, 29 Oct 2020 01:26:45 +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=takahiro.akashi@linaro.org Received: by mail-pg1-x52f.google.com with SMTP id o3so882410pgr.11 for ; Wed, 28 Oct 2020 17:26:45 -0700 (PDT) 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=vOZL7HMoUBm2QgX/veSjMfzSO/qPFQVDFF4KFNeP7Lw=; b=p1CrF+Q94m61bO/1wyRjsGU9S3xphezOQXjmKOUlUrTnWBSbmx0DLd6iEMx9UIhmMG zP0k8h5syjxpOmKWHVOewYkR+yQQ2rRiP2qrPOclLD3j66+VOqcNBYBmW4NVLgnY10ej 1/fOBSZAIjZ5hiOov/RQTR4jW8g7n32HXzBbgnIX5mrClmorfh1Wk8vD2JSqxMhTKnq3 5/s5ysX0auIg7uTc4n+nuF5pnv5NUvcgKegVqq4vTJF6FZiFncFcNLRnzYwd7RyBdjxa jG+xt9vjcT9pUcgrUn7E3mRgs0rthUQri5XXo+dsUfxtnYsputWgU6IC+E0T+IPggN9A 0PqQ== 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=vOZL7HMoUBm2QgX/veSjMfzSO/qPFQVDFF4KFNeP7Lw=; b=H+YdxI29itT8b01z08/CSv7Y2u8iEypY0+zUi8mte3t4S6dYWrTMiEIj/wazsnwOyL QcWjXkxD92RO1qH8kku3SVj1dgJwEOa3GqAMza09G5+rS43E9ztYor2W88Ol8GjqatyC 7t087zMhoqI0NZD0gJUKvPpz6NCST865MGeTgy/6IdQEcM6LBsAmG4c+zw6UPL7Q+R3X SfSsJLokuQqmcjlgGoO2TkBl14YTqZ68a3rYLETRNEwvLxc107T4JKPfAhfxCvUzLekt +n7Vf2bq3ZeZ2MXDwZmeIPNcp31hwFKIIAJyQb55RI01VVVHXS88Z2aIo+RdKWkZsCQJ EBpg== X-Gm-Message-State: AOAM530x/HJMwYtrR7l2DtBQf0JWbqjKpUBYSxFfW2ddi0Sis7T0c0y0 s684H8Miro03P4zfxJQvCKt6jQ== X-Received: by 2002:a17:90a:f184:: with SMTP id bv4mr1395431pjb.1.1603931204270; Wed, 28 Oct 2020 17:26:44 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id s22sm731502pfu.119.2020.10.28.17.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 17:26:43 -0700 (PDT) From: AKASHI Takahiro To: lukma@denx.de, trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Cc: sughosh.ganu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RESEND PATCH v6 17/17] test/py: efi_capsule: test for raw image capsule Date: Thu, 29 Oct 2020 09:25:28 +0900 Message-Id: <20201029002528.34408-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029002528.34408-1-takahiro.akashi@linaro.org> References: <20201029002528.34408-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The test can run on sandbox build and it attempts to execute a firmware update via a capsule-on-disk, using a raw image capsule, CONFIG_EFI_CAPSULE_RAW. To run this test successfully, you need configure U-Boot specifically; See test_capsule_firmware.py for requirements, and hence it won't run on Travis CI, at least, for now. Signed-off-by: AKASHI Takahiro --- test/py/tests/test_efi_capsule/conftest.py | 3 + .../test_efi_capsule/test_capsule_firmware.py | 63 +++++++++++++++++++ 2 files changed, 66 insertions(+) -- 2.28.0 diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 4e7c36f04ba5..4544a24d5351 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -51,6 +51,9 @@ def efi_capsule_data(request, u_boot_config): check_call('cd %s; %s/tools/mkeficapsule --fit uboot_bin_env.itb --version 1 --index 1 Test01' % (data_dir, u_boot_config.build_dir), shell=True) + check_call('cd %s; %s/tools/mkeficapsule --raw u-boot.bin.new --version 1 --index 1 Test02' % + (data_dir, u_boot_config.build_dir), + shell=True) # Create a disk image with EFI system partition check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s %s' % 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 ab7c2a7d6bea..c9b180ac65e8 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -15,6 +15,7 @@ from defs import * @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('efi_capsule_firmware_fit') +@pytest.mark.buildconfigspec('efi_capsule_firmware_raw') @pytest.mark.buildconfigspec('efi_capsule_on_disk') @pytest.mark.buildconfigspec('dfu') @pytest.mark.buildconfigspec('dfu_sf') @@ -176,3 +177,65 @@ class TestEfiCapsuleFirmwareFit(object): 'sf read 4000000 150000 10', 'md.b 4000000 10']) assert 'u-boot-env:New' in ''.join(output) + + def test_efi_capsule_fw3( + self, u_boot_config, u_boot_console, efi_capsule_data): + """ + Test Case 3 - Update U-Boot on SPI Flash, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) + """ + disk_img = efi_capsule_data + with u_boot_console.log.section('Test Case 3-a, before reboot'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'efidebug boot add 1 TEST host 0:1 /helloworld.efi ""', + 'efidebug boot order 1', + 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'env save']) + + # initialize content + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 100000 10', + 'sf read 5000000 100000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + + # place a capsule file + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test02' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test02 $filesize' % CAPSULE_INSTALL_DIR, + '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') + 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 + # are not available. + 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"', + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test02' in ''.join(output) + + # need to run uefi command to initiate capsule handling + output = u_boot_console.run_command( + 'env print -e -all Capsule0000') + + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test02' not in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'sf read 4000000 100000 10', + 'md.b 4000000 10']) + assert 'u-boot:New' in ''.join(output)