From patchwork Mon Aug 3 05:43:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 247360 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp933005ilo; Sun, 2 Aug 2020 22:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA69ybzElumxxLeBbSGsgxKhD85O2nt36ivjE60HEh+sAmA/Q3b/5Mdqjjg2VCWtBrgqN1 X-Received: by 2002:aa7:c889:: with SMTP id p9mr2354601eds.105.1596433666351; Sun, 02 Aug 2020 22:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596433666; cv=none; d=google.com; s=arc-20160816; b=s8x0HNB8tCYyiabyizxXHv58b7VZhC/ZxZudsSCLIlkW/5iyZlZqKecW29zEM4Gd4U Ixl5BYKgnd9oLjy2nUzvHBBDg/u2gCAfo4gMfTiCzTcWxd6uabZflJc3ParXGb1UAYgV 5cCNCSDT8qVbhn3beJyBv9I/rUdnihLKcKUc00xUJQdYZZGrLCfLieoKs8x05+uZEjOI 9eO4yYNGjX/Q6/6RwGEBJju1DEG57pTsnuqo+IZfWF2TO1FlLRryDAH5YCfOHZEhAJGw oshs95xi/0aR8OQYVxRKQrKDjBFAdqjcY3gI4RBfAlz18UlEz1DxMmavTZEYAGsxy3qT zt/g== 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=MEJY55kb9TtEtrkWBnd8tie0No/hzU/IVU/UVGvPXFRom0yaySqlgd9pVKYYLFJFXn UDL34GRT904UCx5qEj/AKW/apOVek5ekPyHwHP78v/A8ARNQRLmsK5LQcahsHv71GpZm bya+9mUtGhTAP7oDokiSmlJr4QeED1Yu0pqQP0LSinRYuWfv6To6r0h4JcG2jGY7xhen MtCB3uoj5unOAV8FMtMJn6pDNcAqNSPM/P2RFknUuy3OCpS7aSiujUROb543ajQwXt64 C9bkoF2wyPSiVEzZjbHs1AhfWZChEj+ExKjM2JVsFQ1RvjrdILdSgmJc8RvUE2I4EqCg lNZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QzLtEgnw; 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 g18si9729565ejb.224.2020.08.02.22.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2020 22:47:46 -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=QzLtEgnw; 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 915CC821D9; Mon, 3 Aug 2020 07:45:33 +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="QzLtEgnw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 92CDC821C3; Mon, 3 Aug 2020 07:45:27 +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-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (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 42166821AF for ; Mon, 3 Aug 2020 07:45:24 +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-pf1-x42d.google.com with SMTP id k18so10351807pfp.7 for ; Sun, 02 Aug 2020 22:45:24 -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=QzLtEgnwrw2OuzzjE3T1BUvrQwQHA9qrgCR/hzGEFHBMD+pWdmIncUA2Xp1EMe+V4Z vqhDtU6QawAGBIBYqTutZ9FpgdSbzXqB4EDg/5igAXu5YazZyizq00467QKORaXrU93t a8OIthFsKKhwF2JpDbuHkWwok73Y4Y2sCO7KSJ5bA+Pnt5GhvSJY7gUNOzOXnQ1BPG3D UsXAVB//S0OV8eBXDrnXQXKPDRwc5KtoLTfSZWbuJKTrktCYmTaabdCcFXZYSzrBUV/G AJgBAfD7rfmXBDpvjzmyrhAa9vgNC9TtFAJxJHnppay/lvQeXQlZ2ePk+NRVE19Coz+E PLAA== 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=gE9h7HE58sYUxnaCjkypk5RbkzZ0NNkiaQ8OqmnX8/LesVy9k9wM9ZrpjrS47Eep9q UpUXBvrFlIGl5fz2ef4gjlsO1md+G4yfE7TeWFpeBeQM8eS8W/JjiJlxhH/kUo5Dzdmj ye1HcLLueXICozqNwBThObqbErLAQ7aw78Q5TUCSzgxfF5HpJWvc8r5yQQZaZ8WY8H3Q wJnT6Y+jCUr3fmS8sJAU6l1SmY87r+vr2RzkiAzp75RarP6SR+t2JRVeyFUl6T57IThA jDdFv/qEuwF9VG9gAdUmA9LZlpcI3tLNSk8D6CXWRm83VC/c3p+bokEtwEIvXNj8qh2l 4tXA== X-Gm-Message-State: AOAM533K/SRlDL0uSX5ONWV8U6t7pQsFdSyTFMNblZDYMfCH8L3Vf/eT pUzHqbYuwVAg8qRqlEbeQ9ojpA== X-Received: by 2002:aa7:9493:: with SMTP id z19mr14336875pfk.190.1596433522678; Sun, 02 Aug 2020 22:45:22 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id r25sm16952633pgv.88.2020.08.02.22.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2020 22:45:22 -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 v5 17/17] test/py: add a test for uefi firmware update capsule of raw image Date: Mon, 3 Aug 2020 14:43:55 +0900 Message-Id: <20200803054355.17356-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200803054355.17356-1-takahiro.akashi@linaro.org> References: <20200803054355.17356-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)