From patchwork Fri Jul 10 01:25:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1326395 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=VKgfgCMx; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B2wSP1Jksz9sRf for ; Fri, 10 Jul 2020 11:29:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A8B428220A; Fri, 10 Jul 2020 03:27:16 +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="VKgfgCMx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EAC7181F14; Fri, 10 Jul 2020 03:27:06 +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-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (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 01E86821C9 for ; Fri, 10 Jul 2020 03:26:58 +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-x435.google.com with SMTP id s26so1804836pfm.4 for ; Thu, 09 Jul 2020 18:26:58 -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=nSISMT+YScS+jgBR3yPDcgMll95omrnidh9EMcW9TgY=; b=VKgfgCMxU+AwMbTQB1+7F7DW7PqiW75tA1zpOqwhY0HYODq52pL8ocScu5kbUYoM/3 63L9oHS0zMChEf7rjN+ENwOQ26w9DV2WeeIKnFy50doheUW2V0Tw1A1OdeMLBqQSYfoy CEQnX2z/KVhm699+Ga8my7CIQhPelNbcQvjkYo9SIyZTkg0lqhYp/9KEPZ8jRqbOmdtp jfzYxlUbt748b8/zfReaJM8ZX4ybfS4KDCPb+MET3t74rgH3U8i41aZf9IQTa1uiB7Og XWvrsaEEdG7akJOFusCiPeGJp67fGfINtF5Km0S7AkLnJJ4V1mjCXDytt8JVnYBd6DJR nCwQ== 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=nSISMT+YScS+jgBR3yPDcgMll95omrnidh9EMcW9TgY=; b=SP/bVifKUpCP0bj3O4Ct9ayMboH60qkbCU646kG6ikCRo3De0Q8hauYxpjaDsAxUnP 2Siu6RO78a1atcon1UBjs5ltka/B6wU4WyV5tVwfKTx1KAoVRYn0eaLmmdlitVs05OZU pX7R0YJNkLNcfikTc3BHcQvRUGAhwi86MazApBycISOIsfvpbQ6c2CEWax9ujmUT9j3y xRQRsJZ6zbyRtgW69ifdBoARBA3aXCIaA/dZtNtXOB21QwgdB7Zzzp/O/w8Zzf0XcaOe Cb/67R1LZ8JZ0GYI1o1IFJOcPM+h6jBjUT8KH04lWh6K9o+hofRodbTZ0uGTF6kwkUsC rgXA== X-Gm-Message-State: AOAM5327sb+uMOxLPdbm7pmDeEKs04NtvoKv/eQOXSAUsveMlFmLO5Sx Z2/y+QGLntKhaYEmXy8tIUW0VQ== X-Google-Smtp-Source: ABdhPJxFS8Hgi1vvYZ6mCyXZHTuFUqqgn2lC/mF+QZJSt9l24VYhi8ownX1r/ftN+nU592nui4a6yQ== X-Received: by 2002:a62:7991:: with SMTP id u139mr967139pfc.87.1594344417513; Thu, 09 Jul 2020 18:26:57 -0700 (PDT) Received: from localhost.localdomain (p6e421564.tkyea130.ap.so-net.ne.jp. [110.66.21.100]) by smtp.gmail.com with ESMTPSA id c1sm3629006pgi.52.2020.07.09.18.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 18:26:56 -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 v3 17/17] test/py: add a test for uefi firmware update capsule of raw image Date: Fri, 10 Jul 2020 10:25:37 +0900 Message-Id: <20200710012537.6264-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200710012537.6264-1-takahiro.akashi@linaro.org> References: <20200710012537.6264-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_efi_capsule/test_capsule_firmware.py | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) 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 490dc039d81f..e7c88c796a65 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -306,3 +306,78 @@ class TestEfiCapsuleFirmwareFit(object): 'sf read 4000000 150000 10', 'md.b 4000000 10']) assert 'u-boot-env:New' in ''.join(output) + + def test_efi_capsule_fw4( + self, u_boot_config, u_boot_console, efi_capsule_data): + """ + Test Case 4 - 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 4-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) + + # create a capsule file + try: + loop_dev = check_output( + 'sudo losetup -o 1MiB --sizelimit %dMiB --show -f %s | tr -d "\n"' % + (EFI_BOOTDEV_PART_SIZE, disk_img), shell=True).decode() + check_call('sudo mount -t %s -o umask=000 %s %s' + % (EFI_BOOTDEV_FS_TYPE, loop_dev, MNT_PNT), shell=True) + check_call( + '%s/tools/mkeficapsule --raw %s%s/u-boot.bin.new --version 1 --index 1 %s%s/Test01' % + (u_boot_config.build_dir, + MNT_PNT, + CAPSULE_DATA_DIR, + MNT_PNT, + CAPSULE_INSTALL_DIR), + shell=True) + check_call('ls -l %s/%s' % (MNT_PNT, CAPSULE_INSTALL_DIR), + shell=True) + check_call('sudo umount %s' % loop_dev, shell=True) + check_call('sudo losetup -d %s' % loop_dev, shell=True) + except CalledProcessError as exception: + assert 'failed to create firmware capsule: %s' % exception.cmd + + # 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 4-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 'Test01' 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 'Test01' 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)