From patchwork Wed Jul 22 06:05:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 246963 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp255157ilg; Tue, 21 Jul 2020 23:09:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrlERptlZTUrFKEQnZwfr+5olhIiLZAKaYpl7rAjG9x526Pazhdlb94D9sfdL2mFytPYti X-Received: by 2002:a17:906:9387:: with SMTP id l7mr27644998ejx.274.1595398167471; Tue, 21 Jul 2020 23:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595398167; cv=none; d=google.com; s=arc-20160816; b=zAR2urtIhcf/4OUp/7fBfyb635gAV10r5dk3eaRFZ3fIUTaZFSELqaUsH9bN/Vs8pC bB4Q3RzkeiGaOPH0OsZneSmK4nexc3vEwRPAgtFyGHhC6mrcDLDWpOqFkgiwRrcD/p3e eWrZl9n85XLVQUtF8NVZVn0CgAibnTEXo/V63ywHrkVavNxcbFjKap/BedVA23Zh08NO xLyYMO7isuRGQIx83RSGLXlLiFNo7ra7X4ypED2hQqsANPCc4O/TOMcd1SGKL7cDQ80b 5nOIa02/4Htht49689tMh8svLzkSWWr4bw6TxN1+PzQJbFyjgtTzvFB7zNuncq7LBIeU X9wQ== 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=Cel1jchhsKYTHWlPd9NQaVTLkqOuTw/3g9g6lGJxJBg=; b=gr8T2EkzdJEa5YcE3cPvc8olFuedVe0P0uqaYQh2udvGgZwJBlkkvdaejgSzdtu6DI D+BAjqvY//sOaxXqIcazp5x3SALzgR7FkBeJ13JXNnekjcmWzByb9E+X+vpOOuwz0n29 DmmTcFWRaM9n+1qs+C6WLm51C5kUZL8262oMl1MwC47O4xOS8p4ucjscUHCk49Z6ORDe m99wKRt+ZF2YR5VZZPpwpzECZRXJb+9Sy+WN/wq5ZTEFN+7i4BDyq1K8Xhs4PCnIMpx8 TAj+B2vDukN5dO3jFsrxuI7Xtsl7+myf0UDdgWNyGPzJh9SXN7tWUquub9MTcmLt5hB+ 2TvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KYSKNhxN; 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 k23si13782725ejo.308.2020.07.21.23.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 23:09:27 -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=KYSKNhxN; 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 2207B8218B; Wed, 22 Jul 2020 08:07:27 +0200 (CEST) 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="KYSKNhxN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6DC9582165; Wed, 22 Jul 2020 08:07:08 +0200 (CEST) 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-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 9A0F881F5A for ; Wed, 22 Jul 2020 08:07:04 +0200 (CEST) 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-pj1-x102b.google.com with SMTP id k1so597212pjt.5 for ; Tue, 21 Jul 2020 23:07:04 -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=Cel1jchhsKYTHWlPd9NQaVTLkqOuTw/3g9g6lGJxJBg=; b=KYSKNhxNFG2Z2/IGiWm55ZM804Gz4FizH3vZuUQx2LFMt7WIY/fw/aim9YoT//biWR WJwgQ2BkaThXMI8iwGNROD0s8UMrkHgZo0tbng1bLGVQgNyBIU+36BfkITpcRYQOOwJl qv8DsmYFbM16ev1qc1qs9RXRxbk5NDikKmkyoD8KApdp3Jziji0zVTew+xipt3Ccpp3x ew24KNavnQXXZxtdb5RPFxJ6VbwtbmDSaCGz4UXECgHU5ZLZLTXg7Ln3L5tr+jq600GZ 4MsUKqHZzx+GMpjACqyndMQ9ur7DWJe3IgQ6uLBV1DfoebHR2GXu4qePOEK5WwVL5QrN 07Qw== 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=Cel1jchhsKYTHWlPd9NQaVTLkqOuTw/3g9g6lGJxJBg=; b=UToHhvs7wXGXumJmRaRQQaSMoSWJydG5oUrd98BOoVW6UWd9Si+9bWNno4hKCTLMXa 9dBllStyZ1tok+MVQnp2cxoITOGtxOBTmAEwL2hUL1geECwPJnX1Uq+xfQQ/QVk6q5xE 5iAWaDC1uqfxT8RNRBhOZTOHBVdVueo6A297MdORa22QvzRiehRNiCLVsaVrzv6uAqLb QxtlHqaY0He7/og6LyxcJ82M6qtf3cOcZXe1v5OV8D3Gg89wTJCZixORcOZm8nV4M6FY cOqobd2s+hGJlLCyuDK7JEG6C/J08KftoJSJ+wUAWbwdbclEioBShJn0WkZDeyG5r5Pw RvGw== X-Gm-Message-State: AOAM533PD5vCq4xhOTjIaGvJyAUhfeG1pthGfqtGzPhbmhv1ncVsFR2Q NL9RGEZAnBFN4gwBgEWZ7FmpRg== X-Received: by 2002:a17:902:7b92:: with SMTP id w18mr25603110pll.258.1595398023158; Tue, 21 Jul 2020 23:07:03 -0700 (PDT) Received: from localhost.localdomain (p6e424d9a.tkyea130.ap.so-net.ne.jp. [110.66.77.154]) by smtp.gmail.com with ESMTPSA id p10sm19578759pgn.6.2020.07.21.23.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 23:07:02 -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 v4 16/16] test/py: add a test for uefi firmware update capsule of raw image Date: Wed, 22 Jul 2020 15:05:39 +0900 Message-Id: <20200722060539.15168-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200722060539.15168-1-takahiro.akashi@linaro.org> References: <20200722060539.15168-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. 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.27.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 1673a4877778..2b2c7baa7ba6 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) + """ + # "-T" (or "-D") is required to enable spi flash on sandbox + u_boot_console.restart_uboot_with_flags('-T') + + 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_with_flags('-T') + + 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: + output = u_boot_console.run_command_list([ + '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)