From patchwork Mon Nov 30 09:12:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 334700 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp4468636ilb; Mon, 30 Nov 2020 01:14:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwApYKHfzVuKWO8o93jc/7sdp4DYEgzSbWADFpV++J394qYNMZeMleAgDFmLjK6WXcYCyER X-Received: by 2002:a50:d757:: with SMTP id i23mr20551332edj.116.1606727688427; Mon, 30 Nov 2020 01:14:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606727688; cv=none; d=google.com; s=arc-20160816; b=RkOvdlw2un8lXSkGZhUMXFuPHz35xbRICgCin3/TRDMxXBYzHBJluEAIMQt9QAh/5S kvqyfG5Po0zKe+KzA6a7OPFP+Ys6ARGe5JrKkGgtTo43w75fNhYUY6QIq9P2cSHz62qB VI73s8/YBSUpXj1pM1wmN+Vq5FqX+7ITg5nye7pelkpIM/95P2w89Ye3q8FgINnlT2MP tIyuxor+ZwaalW/VG0ol7fSw49vftoogD8b2GACHhjJ5vSQfkzTtfhTsHEgMs83uyeOd VHbpQoMMXou/BNv5Exrs/Q/oSTaeS/kgKZGefsHcPE+gWXwxFU9BkdBQyvpvABbKTCLB /ykg== 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=+3Eggs+5nxuppY6QQUBf9f8IqWUGwL9RrQc0q34JB1M=; b=CAN++kGhQkWcI0/Fjx1nFYvQAScGMjwupojsRMppIFWmTh7uR5i7d9FZN/ujBzV/Np IDqY5sgeZB6KjVDgSdiyzOSDRWUyHMNJG4xuUndu4Rwm9p8jURpECfdnE/wgwBGacfRZ Xex0r3WHGFV3NvenntySLqjf2WuPyukqbGSKZPATEwCBtRB+RIPc0HkQUmtj97Bk2Eaz lUmLuUWyjygKfadYNOYJc9Qc/AAoDSntXjYddl/yyMUjD0hoef5+mX9nUda4QPjo1XQ1 ItCFLl1+7fXsenxXZ4GE/n00pckcSJAOIYNVhNIeFOPQ5CmI5AEB38a968veKGVlJ++P Azgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CdJRO1Bl; 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 bf2si5656644edb.112.2020.11.30.01.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 01:14:48 -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=CdJRO1Bl; 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 ED7BA827ED; Mon, 30 Nov 2020 10:13:52 +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="CdJRO1Bl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 66350827CC; Mon, 30 Nov 2020 10:13:21 +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,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 74579827C6 for ; Mon, 30 Nov 2020 10:13:09 +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-x531.google.com with SMTP id k11so9722429pgq.2 for ; Mon, 30 Nov 2020 01:13:09 -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=+3Eggs+5nxuppY6QQUBf9f8IqWUGwL9RrQc0q34JB1M=; b=CdJRO1Bl2X4GFq0MfQBXkUmdRk4xJwGd+gblQNnuOBSyak1jzbJX42NpCRFsQO+T4U CpWWfyrN6xTZfLqhSA+n49BN2W8RX1yBKq6NqByPzUFWjfT24HW1nLsksQyuDi5JAaaP c3shVhzQT+bCIJDrdEb9anQzZfasswN3/4PvLNHwUwsklk8b4lfyJ15egdNDUcl/QlD5 KcktlUEpAmmITcUdwPc0uhO6ZBgHM1HJzAZ189+02XnMsKeae//zbXIO7OxO667rxwje Ul593vbIB5iXwh/jvh6EPtCuLYj6E/72tAk3vz5sbnmLV6quSKKooBPnQPcd+8GrUZPA QVzg== 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=+3Eggs+5nxuppY6QQUBf9f8IqWUGwL9RrQc0q34JB1M=; b=nfKU246khu7wJDGEFqKTz82nAzLDn8QajnL0BNHJZMIPRyxeBpsTRJKzOXqFCcPzO4 9ZPc58QRHPWZgXDl3L7RQC/RlwDAdohRqq1Ze0NfzOXuXzYJlYhD6Wi93KSpyDYVwt90 Hll5cYsWK+sqMgbnlZB8yrxbLWXVIYBqplgZQ0TTUk0xLRqivd2EJLI+NxHFcMc+OcrF wnzxAwtiLrHIF5dUBLkLhVie3bdUwAdU2s8SHa16w7Hzub3ECkBFbgAwsRw4+ySh9yBA X2GzRay6lJoaaKOGrN3A+wessfcIqT+OpqbYgQnHOFdubRvIcFkkqaQvQkTt8jSZP/dI Dyhg== X-Gm-Message-State: AOAM532ImW6ELOKfj4WLaxHmSmZKou5Zk7pP88TXsPy5i5TPOmBmOWEF KlwlVGmh1A81MRduFrkVKkPHqg== X-Received: by 2002:a63:e849:: with SMTP id a9mr16288577pgk.300.1606727588028; Mon, 30 Nov 2020 01:13:08 -0800 (PST) Received: from localhost.localdomain (p784a5642.tkyea130.ap.so-net.ne.jp. [120.74.86.66]) by smtp.gmail.com with ESMTPSA id y19sm16015792pfn.147.2020.11.30.01.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 01:13:07 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: sughosh.ganu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v10 10/11] test/py: efi_capsule: test for raw image capsule Date: Mon, 30 Nov 2020 18:12:17 +0900 Message-Id: <20201130091218.66413-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201130091218.66413-1-takahiro.akashi@linaro.org> References: <20201130091218.66413-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 d10494a7eed5..6ad5608cd71c 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -53,6 +53,9 @@ def efi_capsule_data(request, u_boot_config): check_call('cd %s; %s/tools/mkeficapsule --fit uboot_bin_env.itb --index 1 Test01' % (data_dir, u_boot_config.build_dir), shell=True) + check_call('cd %s; %s/tools/mkeficapsule --raw u-boot.bin.new --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 d8e27707fd79..f006fa95d650 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 capsule_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)