From patchwork Thu Oct 29 04:47:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 319356 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp142727ilc; Wed, 28 Oct 2020 21:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIvEuqgipcoBe9akiMcJ3UkscJytBpKfKdrdqmXEkQbXrBHzg++nGUjICCb1TVm5x8quxe X-Received: by 2002:a17:906:e10e:: with SMTP id gj14mr2517591ejb.134.1603947160417; Wed, 28 Oct 2020 21:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603947160; cv=none; d=google.com; s=arc-20160816; b=IGLIq6NBJPNLUoJmMpAVkYmW8uqdKtqq48+hQEgD4dvxAO33coeELOiJlQuuZhvARK 2O5EbmijPOs5SnM9WSvuHv/SAc/zD5n2fF+047pYyvYj6zPSdYXxqR95H2WUeswf68AR 9zNOfYohAfmO4wskhsA6GQvJLeZ452YIJZQD/OJlX6SQQky499fvhckGWLS5WiS2POSX NTpL9ZggLS0CaGJRXqcqDsxfBU3Xo37JIcktWs9VuPIyfbPH51xrZtqiJi6FC82hD/Rw 2qA1kU/RbfLEIRKSTqcH0ejfeVfrUVC03MvW6H838u+FhJaSVUCSJNqUXBfFhz0wEc8I eVWw== 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=e+bP40PtYl8m3CzqZT8PEUoHwtgUwdV5/efSwBIR7p29BXYHNtoKI8lRepKxdtEs9j 2cL8dfssqIwU5gxp8nKUIZcm3nuVQCshc3kWt/2g4vIg72zwUAy6HHr+3LU4n81UirE1 cf5AHya8ltffwssfGW78jg5gsw59gC38olFPT9leAlNL8r/YgwgUjng9rMLuaBMTrM64 60zLj0V+8NvlJHuDyOSN1h+Rrf/Q2/BPqx6Kv77YwV3uuRT1t3SF79ytMqRdtJ1msVY3 74CNbgAEGJYFBdun/yYAEQAQboQgKcIyVYmApHGBo2TP7MO0p3788w3xuS4aCEBhZ7NO p49Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="R0Vs7g/x"; 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 m26si1173815edq.372.2020.10.28.21.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 21:52:40 -0700 (PDT) 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="R0Vs7g/x"; 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 F28768253B; Thu, 29 Oct 2020 05:50: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="R0Vs7g/x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBEBF8253A; Thu, 29 Oct 2020 05:50:31 +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-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (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 691FE82544 for ; Thu, 29 Oct 2020 05:50:28 +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-pf1-x431.google.com with SMTP id 13so1338580pfy.4 for ; Wed, 28 Oct 2020 21:50:28 -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=R0Vs7g/xyCkYS7uarC/83cI713bkpaf+7EG8G07XXcq7DIULd714RSCup3AfHpQyDp Oyk8BWFyS0VkLznXKktMcAbaLjsIdN5k7Xl503TL4xVcSfkfH8d7g/7iQZ8Hi+gqPqy/ oJ5sJHP/gOvYK6sdsfHCjML1XtsJSQ+DQO/OsTf/yJxDt3COgF2f9vd3GAXrfGYXkABb MbNpDU5e1fsHmPy1e2pAjZT0zwVrjeA2G9Q+aBs49pnG8yqLBMwSckJv7BvU/PRLVrvZ fDQYX5xfwbGcmJA9xUPOVaG8sk47vAMUX+ISU5X3TK4TYRI1hyNLY3AuZMzw80miUHnh TJpg== 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=VEyPfzLceUWVjQ/gieQfVcS0raYjj3t+cCdbwX6Xg8EiCeSYJFfnW92kFgDEs4qk69 oiNJYym2KcN1VKiuYRWnOxx62qZP/MmcxaejIIFmo8ARn3LskHvy3B8e9M4O8UyIHsQQ r5TJYfG8NiUgpqaul8tVSXHtcLPW/xxyYd7VQkVoJadNEvHjwNF48W4UqUGuQG7n1Lun 6KZ+gkYmcnUEXG7jIwBpljjX3SbCUHdwu9tZefeJ8vQGJmoWZzDj9fdYlKJubQQl/K1Z DKbcy4o6nsd96zdiUotiPcOBII9h1kgARVdqtjEjSNsV7B23T+gT520Hgpoc+bNtJ7Zi YwAQ== X-Gm-Message-State: AOAM5315Lb0GRQClPTAUXhqaMCedNCnD+vpD4aW4sQfGNqWfaDnVsM1K 23EXQ7T21Ktnb+vF1Evf3Db1nA== X-Received: by 2002:a17:90a:de8f:: with SMTP id n15mr1411290pjv.9.1603947026984; Wed, 28 Oct 2020 21:50:26 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id t14sm830689pjy.46.2020.10.28.21.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 21:50:26 -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: [PATCH v7 17/17] test/py: efi_capsule: test for raw image capsule Date: Thu, 29 Oct 2020 13:47:57 +0900 Message-Id: <20201029044757.183262-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029044757.183262-1-takahiro.akashi@linaro.org> References: <20201029044757.183262-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)