From patchwork Fri Nov 13 04:15:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 324274 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp900308ils; Thu, 12 Nov 2020 20:19:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOrHiICxQIRoFMC+W0ZJzgCYB4YyDm1Zeb/qVz9WfXSzMbGCJdtf/xoPoAL7TR+Oc9UMud X-Received: by 2002:a17:906:d8a8:: with SMTP id qc8mr203142ejb.149.1605241198207; Thu, 12 Nov 2020 20:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605241198; cv=none; d=google.com; s=arc-20160816; b=LWoeL5PzBJj1beWrfMFySm0KPjzSa8QtFU0L21dzggg0Fm1PuokKWTA2KqLV3EtUL9 HsTTKN1J7K6+E466KHP7XAgQjgAe8gK3P8TBVeETlsovmcvSgAboQkELjHupQ5jcv5mi i5SfTfLkHhUEewGDD/TqVq/04oA2OX0Ff0gTtZhCUT2NXtGEr8vVzaegCtUx0BvF8Qow Gpt63hPEo+dX4K+lcogdc2mSUfJsLil+casdevVbmnPF7PjvE0DL1aWnV4gwjGRQwGzI NbxqpKg2sxuDyFgIwQUugsya6LTAx+PgZC+h7FIfUhNt7871rMWO+hI5fr8BfsatyLlJ +LVw== 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=1V5zlCoZ1xTo6TQ0f5yeAmrzEUbapMfNgI1FhlifC0A=; b=wl3QR76X1Ce/bKepe8YuLNYwaGYVdUFRKR8Yj7nTqS9UWD40D4bOvfd7n4DgC7fNry gqB/6xqjCUI4x5j70Ok3FuXT8abQ8RgHXYpw3RSDHnWJu7pSe2bqhMux2riyMeakNbB0 Ganks48d6LEpIC6LO7vCMMTuiQtB153DcY2b9/dOJbG3U9kk7Hkwzfwklm000w4YhLrt zGhssZcsy35HalLKVsd3LYXsLSnC4xNK75115xM1I+pTuQAT3vRAivjvP/PaNlHv1Q1d aGebSgaFSir99djUmjZpba04wSamHRL2M3AU9SjzTCGTWNjdPVt9MT0frtTg8tne94Ao cR+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q3wlkvrD; 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 s17si4809291edt.578.2020.11.12.20.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 20:19:58 -0800 (PST) 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=Q3wlkvrD; 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 BAAB582592; Fri, 13 Nov 2020 05:18:19 +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="Q3wlkvrD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D5B718255F; Fri, 13 Nov 2020 05:16:41 +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-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 CD6488255F for ; Fri, 13 Nov 2020 05:16:25 +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-pl1-x62d.google.com with SMTP id u2so3934989pls.10 for ; Thu, 12 Nov 2020 20:16:25 -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=1V5zlCoZ1xTo6TQ0f5yeAmrzEUbapMfNgI1FhlifC0A=; b=Q3wlkvrDyGzwHTfeg7mdumi+qj4gmM4fA9CFGf9Rnf3kl0VjRfoJ6X0jWYa0+jkUkL 51n2lMNPTKox8643Fp3eT+cXJNhWu60WLxWN1uAS268vjKrtnz3Z7lIekea5nZ671Ab0 ziFA41DUaFEnBvTi+g6vwVVvnkH71eBno1X8DMBAdcd0u6snzquhQZaETwz2zAd7gFZR 6DucXdz45xwjrMPpKmwJeo3BL3cVWWkD/ncSEIwzUuGPvekiHWNjLLhClyKOwbPFls9E SgCrSuiQK8vTjkDru4Jmo2U8Nbzr0R3qzfUB7EgHperwXbIy4K9G37XWhvLJQYfJKCye 532A== 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=1V5zlCoZ1xTo6TQ0f5yeAmrzEUbapMfNgI1FhlifC0A=; b=jqscQIUlp1E5cy6QICU2Xo417QTKVI9pJq9K4lUN+hBx3WbrmVJl8AIRRqJm6ujLN1 L17D0+B6+dCoWXrHJnfV9sNXOQVpXaZ5IrpFWuedXruCtyuQtDhkGJBU61s810rmTVJy jgiC72EjArwUAE8FKFckU/0YdLHcQi+sKskXrDwZaJlNhclnmFn1x8nBl776vNpiEAHe mceXJVqh48PNr0HV3HT/MFBgNGGnDuO/Um+jzueW+uiVZvcF+8GQzjyJvhT9QQIY5S62 uLjEo4c6nOKTIoUcIOVmUtp4Q9hkKo9RJYhlhVz0AIqNeQceyrDsfY7V+Rv5RBBLM3PH z8rw== X-Gm-Message-State: AOAM532kTOT1rbCLzVvWm1IIr4R1dsgsYK5J2DzPaqE1kt9uOm3gYumB tPbohIUPuZbm+PXUSiX2ku9PXio623ER6A== X-Received: by 2002:a17:902:788e:b029:d6:9a57:ccab with SMTP id q14-20020a170902788eb02900d69a57ccabmr300368pll.41.1605240984235; Thu, 12 Nov 2020 20:16:24 -0800 (PST) Received: from localhost.localdomain (p784a5642.tkyea130.ap.so-net.ne.jp. [120.74.86.66]) by smtp.gmail.com with ESMTPSA id s10sm4588340pjn.35.2020.11.12.20.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 20:16:23 -0800 (PST) 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 v8 17/18] test/py: efi_capsule: test for raw image capsule Date: Fri, 13 Nov 2020 13:15:10 +0900 Message-Id: <20201113041511.48207-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113041511.48207-1-takahiro.akashi@linaro.org> References: <20201113041511.48207-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 147266189912..e037bd20560d 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 --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 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)