From patchwork Mon Sep 7 05:34:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 249205 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp3416348ilg; Sun, 6 Sep 2020 22:40:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4FGDLh9/NGwtpfS5KDPWTOMs9cl2dSeUbEJV9Q8Sal9DFkW0a1F0zg40eMBhInpqpnKAy X-Received: by 2002:a17:906:d8bc:: with SMTP id qc28mr20207997ejb.490.1599457256059; Sun, 06 Sep 2020 22:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599457256; cv=none; d=google.com; s=arc-20160816; b=byTIhgkUqEqkS0DWBUdEaOsQWPBOFtO0gDs8vMv5KNdKafOAouV3tKE8C0gomycJ/8 x1LQ0pKVvm+dKN1O3ngAuGLv6QrCGbVqElpXCrQNtnA6VcyRkomwzY2tQ2owfD3KKbid wtEEa59erEmOAXzUIKtE3mtT2ENwipTACn/5g0QfWDVZWtwTrObkxv9bwvs0rMGMxNxA yuEPLWrTRNQh+qukj/3uiPOFkGjfNNGMfh8P44iGtTyGFSb1Xt8789aFUd/UQi/KSyO2 /UbWGbOdFnt5KeWVS6gAxKVSz/tqOeij8eCWiePRuiWkRmEETfOKMpqON8/0+vzWWWGx 8Gsw== 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=ovgvpl5gnTTh2K316OqP9Lr/+buyql+1HrURePhnu8hT97He1w4BcJtljYl6gM/TN7 FMAdvp9rbA8Hm5sSqoHlhsDL1QKjtw6w/3PzoPlY53VGsiJf0Sx4lhhFKkCAcJfjOx3U 5G5BNX1CT6zReUEG5tmsa9socgOLR4jzzXGprAYCr+OFpxaG6Mxn8BQV4VeYT4m1RKN+ BLvFDQE4hE5TlFRmW+GHZqF/1efgV1vxyg451qzktEXGc1a8IZMQs9Cd7I+jUIRbGBnB eIm/3phyrfdJhbTkSnbZNpZU+HC/TsFWW7wvIjy49M0sfjc0iynRa1XY4o/aGr0TMgzd ZS6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gpo3DHc6; 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 fx6si8738589ejb.432.2020.09.06.22.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 22:40:56 -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=Gpo3DHc6; 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 428578252A; Mon, 7 Sep 2020 07:36:53 +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="Gpo3DHc6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C50EB82511; Mon, 7 Sep 2020 07:36:41 +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-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (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 CD5B9824BB for ; Mon, 7 Sep 2020 07:36:35 +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-pl1-x633.google.com with SMTP id k13so2005937plk.3 for ; Sun, 06 Sep 2020 22:36:35 -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=Gpo3DHc644IdWwgrxpcGHTI0ruKQVPn4G/E0RRMYn+Mhr4myKBV0SZSRVy5fd2THqA 11pBZbaHdKh+fAKtGktxG7XBCS1Ow2s9lFfTNR9RoW6Z99RJ6NQrCJHeZ6yi8ahs0pp9 oLxlDh5CtmqGd0jSZ3iaIJWM996ItufT8PZDskcrs1ZSHXk/gHJztFN5aLtW+Tid7orO G3Q/nXM7c9pHO44rbH4ciqJGDyjnRJld+sWUHNNOzj/VFuSbVAQy8ZluEw6v5um6yaIq NFRNQ3fvdyOIK6uRNcn9zkd7JpJvs0KoM2nstKDibY8VpUTn/5DN88K2/sLcP5P8K50U zaQw== 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=ibkISj8dI7W7ZuvF0Mwskfe6WmtAkOjayv5PS6qAro+2Eo+H/0nrLC6bKBWBLiI5SX /tMM+C+DhJnqAbTDJGg7rm0asnBqU3AZTLHry/YkrdtmC3b8wb8k+3LI8cVJ8bmZdJpV 5gNld0rTF3RguhA499kqzbTYTrL8ANsqQvzKc0e89cKjQCq9GECYQNcKelISJkdTQwbn dtiRfnyWgUK4zLb/KLpwLQti1F6e3zg4GlUGq0uCKC85XGPdvJo8bK/pUSnL29vpzyJx R+tTfrD4Kp+tkQxDnusCyKO/zx9x5oGp9vhaBsL6EL3C2cQjmZaNFa6YsjveMaUGohcv HsVw== X-Gm-Message-State: AOAM531ty+XBl7Z4F7FztxhV1H9FfK93V2iBaqkSVRILU4DnxoqWV2YB 9OwMvaMuZkXnrro3Co1zudA/+g== X-Received: by 2002:a17:90a:e64e:: with SMTP id ep14mr19423038pjb.173.1599456988851; Sun, 06 Sep 2020 22:36:28 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id w6sm10783939pgr.82.2020.09.06.22.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 22:36:28 -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 v6 17/17] test/py: efi_capsule: test for raw image capsule Date: Mon, 7 Sep 2020 14:34:26 +0900 Message-Id: <20200907053426.1675646-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907053426.1675646-1-takahiro.akashi@linaro.org> References: <20200907053426.1675646-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)