public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Takahiro Akashi <takahiro.akashi@linaro.org>
To: Sughosh Ganu <sughosh.ganu@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>,
	Tom Rini <trini@konsulko.com>,
	Etienne Carriere <etienne.carriere@linaro.org>,
	Michal Simek <monstr@monstr.eu>,
	Jassi Brar <jaswinder.singh@linaro.org>
Subject: Re: [PATCH v5 23/23] sandbox: fwu: Add support for testing FWU feature on sandbox
Date: Fri, 17 Jun 2022 10:08:40 +0900	[thread overview]
Message-ID: <20220617010840.GB7986@laputa> (raw)
In-Reply-To: <CADg8p94N2-NDHtkbCLtxwQPAqT_sLaOc3JuNGiU32_iXandQLA@mail.gmail.com>

Sughosh,

On Wed, Jun 15, 2022 at 05:40:12PM +0530, Sughosh Ganu wrote:
> On Wed, 15 Jun 2022 at 11:07, Takahiro Akashi
> <takahiro.akashi@linaro.org> wrote:
> >
> > On Thu, Jun 09, 2022 at 06:00:10PM +0530, Sughosh Ganu wrote:
> > > Add a python test script for testing the FWU Multi Bank Update
> > > functionality on the sandbox platform. The script has test cases for
> > > updation of the u-boot binary and the u-boot environment image to the
> > > non active bank.
> > >
> > > The FWU metadata is being stored on the SPI NOR flash, along with the
> > > updatable images, and the FWU metadata driver for MTD devices is being
> > > used for accessing the metadata. Certain FWU boottime checks are
> > > bypassed due to the unavailability of the EFI variable access very
> > > early in the boot on the sandbox platform -- the variable access is
> > > only available once the block disk image has been bound through the
> > > host interface.
> > >
> > > The FWU Multi Bank feature being enabled on the sandbox64 platform is
> > > enabling the RAW Firmware Management Protocol(FMP) instance, therefore
> > > the FIT FMP instance is being removed -- the FIT FMP is already being
> > > tested on the sandbox flattree variant.
> >
> > IMO,
> > Thinking of the importance of this feature, FIT FMP should also be
> > tested *with FWU*.
> 
> How will the FWU update feature work for FIT images? As I understand

So are you deliberately designing and proposing a solution that is
incompatible with (or not applicable to) an existing interface (FIT FMP)?

> FIT, it is a way of packaging different firmware images into a single
> package. At the time of writing the images, the FIT image parser would
> check the image configuration, and write the images to their
> respective locations. As you are aware, for the FWU feature, the
> information about the images, and the update bank is obtained from the
> structure called metadata. How does the FIT update mechanism map with
> the FWU metadata which is used to identify which bank needs to be
> updated. The bank to which the image is to be written translates into
> the DFU alt_num value for that image, and this gets computed at
> runtime. In the case of the FIT image, as per my understanding, the
> alt_num value is irrelevant. So my question is, how do we map the
> information obtained from the FWU metadata to tell the FIT image
> writing function(fit_update) which locations do the images need to be
> written to. I think this needs some more thought.
> 
> >
> > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > > ---
> > >  arch/sandbox/Kconfig                          |   6 +
> > >  arch/sandbox/dts/test.dts                     |  45 ++-
> > >  board/sandbox/sandbox.c                       |  49 +++
> > >  configs/sandbox64_defconfig                   |  12 +-
> > >  include/fwu.h                                 |   2 +
> > >  lib/fwu_updates/Kconfig                       |   2 +-
> > >  lib/fwu_updates/fwu.c                         |  18 +-
> > >  lib/fwu_updates/fwu_mtd.c                     |  10 +-
> > >  .../test_capsule_firmware_fit.py              |   1 -
> > >  .../py/tests/test_fwu_updates/capsule_defs.py |  10 +
> > >  test/py/tests/test_fwu_updates/conftest.py    |  78 ++++
> > >  .../test_fwu_updates/test_fwu_updates.py      | 367 ++++++++++++++++++
> > >  12 files changed, 587 insertions(+), 13 deletions(-)
> > >  create mode 100644 test/py/tests/test_fwu_updates/capsule_defs.py
> > >  create mode 100644 test/py/tests/test_fwu_updates/conftest.py
> > >  create mode 100644 test/py/tests/test_fwu_updates/test_fwu_updates.py
> > >
> 
> <snip>
> 
> > > diff --git a/test/py/tests/test_fwu_updates/conftest.py b/test/py/tests/test_fwu_updates/conftest.py
> > > new file mode 100644
> > > index 0000000000..cdf824c3be
> > > --- /dev/null
> > > +++ b/test/py/tests/test_fwu_updates/conftest.py
> > > @@ -0,0 +1,78 @@
> > > +# SPDX-License-Identifier:      GPL-2.0+
> > > +# Copyright (c) 2020, Linaro Limited
> > > +# Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
> >
> > If this file is exactly same as test_efi_capsule/conftest.py,
> > why not move all the tests (test_fwu_updates.py) to test_efi_capsule?
> 
> The files are not exactly the same. There is use of the mkfwumdata
> utility used for FWU tests, along with the capsule files that are
> being generated. I had tried putting the code under the
> test_efi_capsule directory, but the result was getting cluttered.

Okay, but from my curiosity, how cluttered was it?
It seems to me that you are simply adding extra setup steps.

My simple concern is that, if there is a fair amount of common code
between two tests, it should be unified for maintainability.

-Takahiro Akashi

> Which is why I decided to put the changes separately under the
> test_fwu_updates directory.
> 
> >
> > The basic scenario of updating firmware, u-boot.bin and u-boot.env,
> > is also the same, isn't it? The only difference is whether FWU_MULTI_BANK_UPDATE
> > is enabled or not.
> 
> There are two capsule files per image, one per bank. Also, the FWU
> metadata is being written to the SPI NOR device, which is being
> formatted as a MTD partitioned device. The underlying update mechanism
> is the same, yes.
> 
> -sughosh
> 
> >
> > -Takahiro Akashi
> >
> > > +
> > > +import os
> > > +import os.path
> > > +import re
> > > +from subprocess import call, check_call, check_output, CalledProcessError
> > > +import pytest
> > > +from capsule_defs import *
> > > +
> > > +#
> > > +# Fixture for UEFI capsule test
> > > +#
> > > +
> > > +@pytest.fixture(scope='session')
> > > +def efi_capsule_data(request, u_boot_config):
> > > +    """Set up a file system to be used in UEFI capsule and
> > > +       authentication test.
> > > +
> > > +    Args:
> > > +        request: Pytest request object.
> > > +        u_boot_config: U-boot configuration.
> > > +
> > > +    Return:
> > > +        A path to disk image to be used for testing
> > > +    """
> > > +    global CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
> > > +
> > > +    mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule'
> > > +    data_dir = mnt_point + CAPSULE_DATA_DIR
> > > +    install_dir = mnt_point + CAPSULE_INSTALL_DIR
> > > +    image_path = u_boot_config.persistent_data_dir + '/test_efi_capsule.img'
> > > +
> > > +    try:
> > > +        # Create a target device
> > > +        check_call('dd if=/dev/zero of=./spi.bin bs=1MiB count=16', shell=True)
> > > +
> > > +        check_call('rm -rf %s' % mnt_point, shell=True)
> > > +        check_call('mkdir -p %s' % data_dir, shell=True)
> > > +        check_call('mkdir -p %s' % install_dir, shell=True)
> > > +
> > > +        # Create capsule files
> > > +        # two regions: one for u-boot.bin and the other for u-boot.env
> > > +        check_call('cd %s; echo -n u-boot-a:Old > u-boot-a.bin.old; echo -n u-boot-env-a:Old > u-boot-env-a.old; echo -n u-boot-a:New > u-boot-a.bin.new; echo -n u-boot-env-a:New > u-boot-env-a.new; echo -n u-boot-b:Old > u-boot-b.bin.old; echo -n u-boot-env-b:Old > u-boot-env-b.old; echo -n u-boot-b:New > u-boot-b.bin.new; echo -n u-boot-env-b:New > u-boot-env-b.new;' % data_dir,
> > > +                   shell=True)
> > > +        check_call('cd %s; %s/tools/mkfwumdata -i 2 -b 2 -a 0 -g af9e8c96-bec5-48be-9dab-3491c04b1366,09D7CF52-0720-4710-91D1-08469B7FE9C8,a8f61787-5d68-4c9d-9e4a-37bb0df99da7,52377abf-c4e4-4d0b-aafd-ba081a500847 af9e8c96-bec5-48be-9dab-3491c04b1366,5A7021F5-FEF2-48B4-AABA-832E777418C0,ea9d59af-e0e8-4ef5-9b16-4c80ff67524c,4e01d1fa-eebb-437e-9cfe-e7dfbcd04bb3 metadata_bank0.bin' %(data_dir, u_boot_config.build_dir), shell=True)
> > > +        check_call('cd %s; %s/tools/mkfwumdata -i 2 -b 2 -a 1 -g af9e8c96-bec5-48be-9dab-3491c04b1366,09D7CF52-0720-4710-91D1-08469B7FE9C8,a8f61787-5d68-4c9d-9e4a-37bb0df99da7,52377abf-c4e4-4d0b-aafd-ba081a500847 af9e8c96-bec5-48be-9dab-3491c04b1366,5A7021F5-FEF2-48B4-AABA-832E777418C0,ea9d59af-e0e8-4ef5-9b16-4c80ff67524c,4e01d1fa-eebb-437e-9cfe-e7dfbcd04bb3 metadata_bank1.bin' %(data_dir, u_boot_config.build_dir), shell=True)
> > > +
> > > +        check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 u-boot-b.bin.new Test01' %
> > > +                   (data_dir, u_boot_config.build_dir),
> > > +                   shell=True)
> > > +        check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 u-boot-env-b.new Test02' %
> > > +                   (data_dir, u_boot_config.build_dir),
> > > +                   shell=True)
> > > +
> > > +        check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 u-boot-a.bin.new Test03' %
> > > +                   (data_dir, u_boot_config.build_dir),
> > > +                   shell=True)
> > > +        check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 u-boot-env-a.new Test04' %
> > > +                   (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' %
> > > +                   (mnt_point, image_path), shell=True)
> > > +        check_call('sgdisk %s -A 1:set:0 -t 1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B' %
> > > +                   image_path, shell=True)
> > > +
> > > +    except CalledProcessError as exception:
> > > +        pytest.skip('Setup failed: %s' % exception.cmd)
> > > +        return
> > > +    else:
> > > +        yield image_path
> > > +    finally:
> > > +        call('rm -rf %s' % mnt_point, shell=True)
> > > +        call('rm -f %s' % image_path, shell=True)
> > > +        call('rm -f ./spi.bin', shell=True)
> > > diff --git a/test/py/tests/test_fwu_updates/test_fwu_updates.py b/test/py/tests/test_fwu_updates/test_fwu_updates.py
> > > new file mode 100644
> > > index 0000000000..d9dff3afaf
> > > --- /dev/null
> > > +++ b/test/py/tests/test_fwu_updates/test_fwu_updates.py
> > > @@ -0,0 +1,367 @@
> > > +# SPDX-License-Identifier:      GPL-2.0+
> > > +# Copyright (c) 2022, Linaro Limited
> > > +#
> > > +# FWU Multi Bank Firmware Update Test
> > > +
> > > +"""
> > > +This test verifies FWU Multi Bank firmware update for raw images
> > > +"""
> > > +
> > > +from subprocess import check_call, check_output, CalledProcessError
> > > +import pytest
> > > +from capsule_defs import *
> > > +
> > > +
> > > +@pytest.mark.boardspec('sandbox64')
> > > +@pytest.mark.buildconfigspec('efi_capsule_firmware_raw')
> > > +@pytest.mark.buildconfigspec('efi_capsule_on_disk')
> > > +@pytest.mark.buildconfigspec('dfu')
> > > +@pytest.mark.buildconfigspec('dfu_sf')
> > > +@pytest.mark.buildconfigspec('cmd_efidebug')
> > > +@pytest.mark.buildconfigspec('cmd_fat')
> > > +@pytest.mark.buildconfigspec('cmd_memory')
> > > +@pytest.mark.buildconfigspec('cmd_nvedit_efi')
> > > +@pytest.mark.buildconfigspec('cmd_sf')
> > > +@pytest.mark.buildconfigspec('fwu_multi_bank_update')
> > > +@pytest.mark.buildconfigspec('dm_fwu_mdata')
> > > +@pytest.mark.buildconfigspec('fwu_mdata_mtd')
> > > +@pytest.mark.slow
> > > +class TestEfiCapsuleFirmwareRaw(object):
> > > +    def test_fwu_updates_fw1(
> > > +            self, u_boot_config, u_boot_console, efi_capsule_data):
> > > +        """
> > > +        Test Case 1 - Update U-Boot Bank 1 binary on SPI Flash
> > > +                      0x100000-0x150000: U-Boot binary Bank 0 (but dummy)
> > > +                      0x150000-0x200000: U-Boot binary Bank 1 (but dummy)
> > > +        """
> > > +
> > > +        # other tests might have run and the
> > > +        # system might not be in a clean state.
> > > +        # Restart before starting the tests.
> > > +        u_boot_console.restart_uboot()
> > > +
> > > +        disk_img = efi_capsule_data
> > > +        with u_boot_console.log.section('Test Case 1-a, before reboot'):
> > > +            output = u_boot_console.run_command_list([
> > > +                'host bind 0 %s' % disk_img,
> > > +                'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""',
> > > +                'efidebug boot order 1',
> > > +                'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
> > > +                'env save'])
> > > +
> > > +            # initialize contents
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'fatload host 0:1 4000000 %s/u-boot-a.bin.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 100000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-b.bin.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 140000 10'])
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 100000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5100000 140000 10',
> > > +                'md.b 5100000 10'
> > > +                ])
> > > +            assert 'u-boot-b:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'fatload host 0:1 4000000 %s/metadata_bank0.bin' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 0 $filesize',
> > > +                'sf write 4000000 10000 $filesize'])
> > > +
> > > +            output = u_boot_console.run_command(
> > > +                'fwu_mdata_read')
> > > +            assert 'active_index: 0x0' in ''.join(output)
> > > +            assert 'previous_active_index: 0x1' in ''.join(output)
> > > +
> > > +            # place a capsule file
> > > +            output = u_boot_console.run_command_list([
> > > +                'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR,
> > > +                'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR,
> > > +                'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR])
> > > +            assert 'Test01' in ''.join(output)
> > > +
> > > +        # reboot
> > > +        u_boot_console.restart_uboot()
> > > +
> > > +        with u_boot_console.log.section('Test Case 1-b, after reboot'):
> > > +            # make sure that dfu_alt_info exists even persistent variables
> > > +            # are not available.
> > > +            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(
> > > +                'efidebug capsule disk-update', wait_for_reboot = True)
> > > +
> > > +            output = u_boot_console.run_command(
> > > +                'fwu_mdata_read')
> > > +            assert 'active_index: 0x1' in ''.join(output)
> > > +            assert 'previous_active_index: 0x0' 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-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 4000000 140000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-b:New' in ''.join(output)
> > > +
> > > +    def test_fwu_updates_fw2(
> > > +            self, u_boot_config, u_boot_console, efi_capsule_data):
> > > +        """
> > > +        Test Case 2 - Update U-Boot and U-Boot Env Bank 1 binary on SPI Flash
> > > +                      0x100000-0x110000: U-Boot binary Bank 0 (but dummy)
> > > +                      0x120000-0x130000: U-Boot Env binary Bank 0 (but dummy)
> > > +                      0x140000-0x150000: U-Boot binary Bank 1 (but dummy)
> > > +                      0x160000-0x170000: U-Boot Env binary Bank 1 (but dummy)
> > > +        """
> > > +
> > > +        # other tests might have run and the
> > > +        # system might not be in a clean state.
> > > +        # Restart before starting the tests.
> > > +        u_boot_console.restart_uboot()
> > > +
> > > +        disk_img = efi_capsule_data
> > > +        with u_boot_console.log.section('Test Case 2-a, before reboot'):
> > > +            output = u_boot_console.run_command_list([
> > > +                'host bind 0 %s' % disk_img,
> > > +                'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""',
> > > +                'efidebug boot order 1',
> > > +                'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
> > > +                'env save'])
> > > +
> > > +            # initialize contents
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'fatload host 0:1 4000000 %s/u-boot-a.bin.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 100000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-env-a.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 120000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-b.bin.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 140000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-env-b.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 160000 10'])
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 100000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 120000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-env-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5100000 140000 10',
> > > +                'md.b 5100000 10'
> > > +                ])
> > > +            assert 'u-boot-b:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 160000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-env-b:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'fatload host 0:1 4000000 %s/metadata_bank0.bin' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 0 100',
> > > +                'sf write 4000000 10000 100'])
> > > +
> > > +            output = u_boot_console.run_command(
> > > +               'fwu_mdata_read')
> > > +            assert 'active_index: 0x0' in ''.join(output)
> > > +            assert 'previous_active_index: 0x1' in ''.join(output)
> > > +
> > > +            # place a capsule file
> > > +            output = u_boot_console.run_command_list([
> > > +                'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR,
> > > +                'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR,
> > > +                '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 'Test01' in ''.join(output)
> > > +            assert 'Test02' in ''.join(output)
> > > +
> > > +        # reboot
> > > +        u_boot_console.restart_uboot()
> > > +
> > > +        with u_boot_console.log.section('Test Case 2-b, after reboot'):
> > > +            # make sure that dfu_alt_info exists even persistent variables
> > > +            # are not available.
> > > +            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)
> > > +            assert 'Test02' in ''.join(output)
> > > +
> > > +            # need to run uefi command to initiate capsule handling
> > > +            output = u_boot_console.run_command(
> > > +                'efidebug capsule disk-update', wait_for_reboot = True)
> > > +
> > > +            output = u_boot_console.run_command(
> > > +                'fwu_mdata_read')
> > > +            assert 'active_index: 0x1' in ''.join(output)
> > > +            assert 'previous_active_index: 0x0' 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-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'sf read 4000000 120000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-env-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 4000000 140000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-b:New' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 4000000 160000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-env-b:New' in ''.join(output)
> > > +
> > > +    def test_fwu_updates_fw3(
> > > +            self, u_boot_config, u_boot_console, efi_capsule_data):
> > > +        """
> > > +        Test Case 3 - Update U-Boot and U-Boot Env Bank 0 binary on SPI Flash
> > > +                      0x100000-0x110000: U-Boot binary Bank 0 (but dummy)
> > > +                      0x120000-0x130000: U-Boot Env binary Bank 0 (but dummy)
> > > +                      0x140000-0x150000: U-Boot binary Bank 1 (but dummy)
> > > +                      0x160000-0x170000: U-Boot Env binary Bank 1 (but dummy)
> > > +        """
> > > +
> > > +        # other tests might have run and the
> > > +        # system might not be in a clean state.
> > > +        # Restart before starting the tests.
> > > +        u_boot_console.restart_uboot()
> > > +
> > > +        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 -b 1 TEST host 0:1 /helloworld.efi -s ""',
> > > +                'efidebug boot order 1',
> > > +                'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
> > > +                'env save'])
> > > +
> > > +            # initialize contents
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'fatload host 0:1 4000000 %s/u-boot-a.bin.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 100000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-env-a.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 120000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-b.bin.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 140000 10',
> > > +                'fatload host 0:1 4000000 %s/u-boot-env-b.old' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 160000 10'])
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 100000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 120000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-env-a:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5100000 140000 10',
> > > +                'md.b 5100000 10'
> > > +                ])
> > > +            assert 'u-boot-b:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 5000000 160000 10',
> > > +                'md.b 5000000 10'
> > > +                ])
> > > +            assert 'u-boot-env-b:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'fatload host 0:1 4000000 %s/metadata_bank1.bin' % CAPSULE_DATA_DIR,
> > > +                'sf write 4000000 0 100',
> > > +                'sf write 4000000 10000 100'])
> > > +
> > > +            output = u_boot_console.run_command(
> > > +                'fwu_mdata_read')
> > > +            assert 'active_index: 0x1' in ''.join(output)
> > > +            assert 'previous_active_index: 0x0' in ''.join(output)
> > > +
> > > +            # place a capsule file
> > > +            output = u_boot_console.run_command_list([
> > > +                'fatload host 0:1 4000000 %s/Test03' % CAPSULE_DATA_DIR,
> > > +                'fatwrite host 0:1 4000000 %s/Test03 $filesize' % CAPSULE_INSTALL_DIR,
> > > +                'fatload host 0:1 4000000 %s/Test04' % CAPSULE_DATA_DIR,
> > > +                'fatwrite host 0:1 4000000 %s/Test04 $filesize' % CAPSULE_INSTALL_DIR,
> > > +                'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR])
> > > +            assert 'Test03' in ''.join(output)
> > > +            assert 'Test04' in ''.join(output)
> > > +
> > > +        # reboot
> > > +        u_boot_console.restart_uboot()
> > > +
> > > +        with u_boot_console.log.section('Test Case 3-b, after reboot'):
> > > +            # make sure that dfu_alt_info exists even persistent variables
> > > +            # are not available.
> > > +            output = u_boot_console.run_command_list([
> > > +                'host bind 0 %s' % disk_img,
> > > +                'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR])
> > > +            assert 'Test03' in ''.join(output)
> > > +            assert 'Test04' in ''.join(output)
> > > +
> > > +            # need to run uefi command to initiate capsule handling
> > > +            output = u_boot_console.run_command(
> > > +                'efidebug capsule disk-update', wait_for_reboot = True)
> > > +
> > > +            output = u_boot_console.run_command(
> > > +                'fwu_mdata_read')
> > > +            assert 'active_index: 0x0' in ''.join(output)
> > > +            assert 'previous_active_index: 0x1' 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-a:New' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf probe 0:0',
> > > +                'sf read 4000000 120000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-env-a:New' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 4000000 140000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-b:Old' in ''.join(output)
> > > +
> > > +            output = u_boot_console.run_command_list([
> > > +                'sf read 4000000 160000 10',
> > > +                'md.b 4000000 10'])
> > > +            assert 'u-boot-env-b:Old' in ''.join(output)
> > > --
> > > 2.25.1
> > >

  reply	other threads:[~2022-06-17  1:08 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 12:29 [PATCH v5 00/23] FWU: Add FWU Multi Bank Update feature support Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 01/23] dt/bindings: Add bindings for FWU Metadata storage device Sughosh Ganu
2022-06-16 13:34   ` Michal Simek
2022-06-17  6:21     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 02/23] FWU: Add FWU metadata structure and driver for accessing metadata Sughosh Ganu
2022-06-21 10:54   ` Etienne Carriere
2022-06-23  6:24     ` Sughosh Ganu
2022-06-23 11:55       ` Etienne Carriere
2022-06-09 12:29 ` [PATCH v5 03/23] FWU: Add FWU metadata access driver for GPT partitioned block devices Sughosh Ganu
2022-06-21  9:34   ` Patrick DELAUNAY
2022-06-22 12:39     ` Patrick DELAUNAY
2022-06-28 10:01     ` Sughosh Ganu
2022-06-21 10:55   ` Etienne Carriere
2022-06-28 10:11     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 04/23] stm32mp1: dk2: Add a node for the FWU metadata device Sughosh Ganu
2022-06-21  9:36   ` Patrick DELAUNAY
2022-06-09 12:29 ` [PATCH v5 05/23] stm32mp1: dk2: Add image information for capsule updates Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 06/23] FWU: stm32mp1: Add helper functions for accessing FWU metadata Sughosh Ganu
2022-06-10 11:53   ` Ilias Apalodimas
2022-06-13 12:37     ` Sughosh Ganu
2022-06-21  9:49   ` Patrick DELAUNAY
2022-06-23  6:04     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 07/23] FWU: STM32MP1: Add support to read boot index from backup register Sughosh Ganu
2022-06-10 12:02   ` Ilias Apalodimas
2022-06-21 11:27   ` Patrick DELAUNAY
2022-06-23  6:30     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 08/23] FWU: Add boot time checks as highlighted by the FWU specification Sughosh Ganu
2022-06-15  6:34   ` Heinrich Schuchardt
2022-06-15  6:39     ` Takahiro Akashi
2022-06-21 10:56   ` Etienne Carriere
2022-06-23  9:45     ` Sughosh Ganu
2022-06-23 12:32       ` Etienne Carriere
2022-06-28 10:42         ` Sughosh Ganu
2022-06-21 11:46   ` Patrick DELAUNAY
2022-06-23  9:49     ` Sughosh Ganu
2022-06-09 12:29 ` [PATCH v5 09/23] FWU: Add support for the FWU Multi Bank Update feature Sughosh Ganu
2022-06-21 10:56   ` Etienne Carriere
2022-06-21 11:55   ` Patrick DELAUNAY
2022-06-09 12:29 ` [PATCH v5 10/23] FWU: cmd: Add a command to read FWU metadata Sughosh Ganu
2022-06-10 12:07   ` Ilias Apalodimas
2022-06-13 12:38     ` Sughosh Ganu
2022-06-20 12:53   ` Michal Simek
2022-06-21 12:07   ` Patrick DELAUNAY
2022-06-09 12:29 ` [PATCH v5 11/23] mkeficapsule: Add support for generating empty capsules Sughosh Ganu
2022-06-09 16:27   ` Heinrich Schuchardt
2022-06-13 12:33     ` Sughosh Ganu
2022-06-15  5:11   ` Takahiro Akashi
2022-06-15 10:49     ` Sughosh Ganu
2022-06-16  1:01       ` Takahiro Akashi
2022-06-16  7:12         ` Sughosh Ganu
2022-06-17  0:46           ` Takahiro Akashi
2022-06-17  8:01             ` Sughosh Ganu
2022-06-21 10:58   ` Etienne Carriere
2022-06-09 12:29 ` [PATCH v5 12/23] FWU: doc: Add documentation for the FWU feature Sughosh Ganu
2022-06-21 12:12   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 13/23] FWU: Add FWU metadata access driver for non-GPT MTD devices Sughosh Ganu
2022-06-21 10:56   ` Etienne Carriere
2022-06-21 12:39   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 14/23] dt/bindings: firmware: Add FWU metadata on MTD devices binding Sughosh Ganu
2022-06-21 10:56   ` Etienne Carriere
2022-06-21 12:26   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 15/23] tools: Add mkfwumdata tool for FWU metadata image Sughosh Ganu
2022-06-21 10:57   ` Etienne Carriere
2022-06-21 12:59     ` Michal Simek
2022-06-21 12:55   ` Patrick DELAUNAY
2022-06-09 12:30 ` [PATCH v5 16/23] FWU: doc: Update documentation for the FWU non-GPT MTD Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 17/23] synquacer: Update for TBBR (BL2) based new FIP layout Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 18/23] developerbox: synquacer: Use FIP as the updatable image Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 19/23] FWU: synquacer: Add FWU Multi bank update support for DeveloperBox Sughosh Ganu
2022-06-17 14:00   ` Michal Simek
2022-06-20  8:23   ` Michal Simek
2022-07-18 14:43     ` Jassi Brar
2022-07-18 14:46       ` Ilias Apalodimas
2022-07-18 15:08         ` Jassi Brar
2022-07-18 15:16           ` Ilias Apalodimas
2022-07-18 15:31             ` Jassi Brar
2022-07-18 15:34               ` Ilias Apalodimas
2022-07-18 15:34               ` Jassi Brar
2022-07-18 15:37                 ` Ilias Apalodimas
2022-07-18 21:00               ` Tom Rini
2022-07-19 15:23                 ` Jassi Brar
2022-07-20  1:17                   ` Tom Rini
2022-07-19 15:27                 ` Jassi Brar
2022-07-20  7:53                   ` Ilias Apalodimas
2022-07-20 14:30                     ` Jassi Brar
2022-07-22  8:37                       ` Ilias Apalodimas
2022-07-22 17:01                         ` Jassi Brar
2022-06-09 12:30 ` [PATCH v5 20/23] FWU: synquacer: Generate dfu_alt_info from devicetree partition Sughosh Ganu
2022-06-17 14:02   ` Michal Simek
2022-07-18 14:49     ` Jassi Brar
2022-07-20  1:13       ` Takahiro Akashi
2022-07-20  3:16         ` Jassi Brar
2022-06-09 12:30 ` [PATCH v5 21/23] doc: synquacer: Add how to enable FWU Multi Bank Update Sughosh Ganu
2022-06-17 13:59   ` Michal Simek
2022-06-09 12:30 ` [PATCH v5 22/23] [TEMP]configs: synquacer: Add FWU support for DeveloperBox Sughosh Ganu
2022-06-09 12:30 ` [PATCH v5 23/23] sandbox: fwu: Add support for testing FWU feature on sandbox Sughosh Ganu
2022-06-15  5:37   ` Takahiro Akashi
2022-06-15 12:10     ` Sughosh Ganu
2022-06-17  1:08       ` Takahiro Akashi [this message]
2022-06-17  7:57         ` Sughosh Ganu
2022-06-15  6:30   ` Takahiro Akashi
2022-06-15 12:13     ` Sughosh Ganu
2022-06-20 18:12 ` [PATCH v5 00/23] FWU: Add FWU Multi Bank Update feature support Patrick DELAUNAY
2022-06-21  9:23   ` Sughosh Ganu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220617010840.GB7986@laputa \
    --to=takahiro.akashi@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=etienne.carriere@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jaswinder.singh@linaro.org \
    --cc=monstr@monstr.eu \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox