From 90999b456902a7fe760e74f09b88b55141e7c20f Mon Sep 17 00:00:00 2001 From: Roman Kopytin Date: Mon, 20 Mar 2023 03:28:13 +0000 Subject: [PATCH 1/9] test_vboot.py: include test of fdt_add_pubkey tool Add test_fdt_add_pubkey test which provides simple functionality test which contains such steps: create DTB and FIT files add keys with fdt_add_pubkey to DTB sign FIT image check with fit_check_sign that keys properly added to DTB file Signed-off-by: Roman Kopytin Signed-off-by: Ivan Mikhaylov Cc: Rasmus Villemoes --- test/py/tests/test_vboot.py | 186 ++++++++++++++++++++++++++++-------- 1 file changed, 148 insertions(+), 38 deletions(-) diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py index e3e7ca4b215..04fa59f98b0 100644 --- a/test/py/tests/test_vboot.py +++ b/test/py/tests/test_vboot.py @@ -30,6 +30,12 @@ For pre-load header verification: - Check that image verification fails Tests run with both SHA1 and SHA256 hashing. + +This also tests fdt_add_pubkey utility in the simple way: +- Create DTB and FIT files +- Add keys with fdt_add_pubkey to DTB +- Sign FIT image +- Check with fit_check_sign that keys properly added to DTB file """ import os @@ -40,6 +46,41 @@ import u_boot_utils as util import vboot_forge import vboot_evil +# Common helper functions +def dtc(dts, cons, dtc_args, datadir, tmpdir, dtb): + """Run the device tree compiler to compile a .dts file + + The output file will be the same as the input file but with a .dtb + extension. + + Args: + dts: Device tree file to compile. + cons: U-Boot console. + dtc_args: DTC arguments. + datadir: Path to data directory. + tmpdir: Path to temp directory. + dtb: Resulting DTB file. + """ + dtb = dts.replace('.dts', '.dtb') + util.run_and_log(cons, 'dtc %s %s%s -O dtb ' + '-o %s%s' % (dtc_args, datadir, dts, tmpdir, dtb)) + +def make_fit(its, cons, mkimage, dtc_args, datadir, fit): + """Make a new FIT from the .its source file. + + This runs 'mkimage -f' to create a new FIT. + + Args: + its: Filename containing .its source. + cons: U-Boot console. + mkimage: Path to mkimage utility. + dtc_args: DTC arguments. + datadir: Path to data directory. + fit: Resulting FIT file. + """ + util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', + '%s%s' % (datadir, its), fit]) + # Only run the full suite on a few combinations, since it doesn't add any more # test coverage. TESTDATA_IN = [ @@ -82,19 +123,6 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, The SHA1 and SHA256 tests are combined into a single test since the key-generation process is quite slow and we want to avoid doing it twice. """ - def dtc(dts): - """Run the device tree compiler to compile a .dts file - - The output file will be the same as the input file but with a .dtb - extension. - - Args: - dts: Device tree file to compile. - """ - dtb = dts.replace('.dts', '.dtb') - util.run_and_log(cons, 'dtc %s %s%s -O dtb ' - '-o %s%s' % (dtc_args, datadir, dts, tmpdir, dtb)) - def dtc_options(dts, options): """Run the device tree compiler to compile a .dts file @@ -152,17 +180,6 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, assert('sandbox: continuing, as we cannot run' not in ''.join(output)) - def make_fit(its): - """Make a new FIT from the .its source file. - - This runs 'mkimage -f' to create a new FIT. - - Args: - its: Filename containing .its source. - """ - util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', - '%s%s' % (datadir, its), fit]) - def sign_fit(sha_algo, options): """Sign the FIT @@ -286,12 +303,12 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, # Compile our device tree files for kernel and U-Boot. These are # regenerated here since mkimage will modify them (by adding a # public key) below. - dtc('sandbox-kernel.dts') - dtc('sandbox-u-boot.dts') + dtc('sandbox-kernel.dts', cons, dtc_args, datadir, tmpdir, dtb) + dtc('sandbox-u-boot.dts', cons, dtc_args, datadir, tmpdir, dtb) # Build the FIT, but don't sign anything yet cons.log.action('%s: Test FIT with signed images' % sha_algo) - make_fit('sign-images-%s%s.its' % (sha_algo, padding)) + make_fit('sign-images-%s%s.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) run_bootm(sha_algo, 'unsigned images', ' - OK' if algo_arg else 'dev-', True) # Sign images with our dev keys @@ -299,10 +316,10 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, run_bootm(sha_algo, 'signed images', 'dev+', True) # Create a fresh .dtb without the public keys - dtc('sandbox-u-boot.dts') + dtc('sandbox-u-boot.dts', cons, dtc_args, datadir, tmpdir, dtb) cons.log.action('%s: Test FIT with signed configuration' % sha_algo) - make_fit('sign-configs-%s%s.its' % (sha_algo, padding)) + make_fit('sign-configs-%s%s.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) run_bootm(sha_algo, 'unsigned config', '%s+ OK' % ('sha256' if algo_arg else sha_algo), True) # Sign images with our dev keys @@ -352,7 +369,7 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, run_bootm(sha_algo, 'evil kernel@', msg, False, efit) # Create a new properly signed fit and replace header bytes - make_fit('sign-configs-%s%s.its' % (sha_algo, padding)) + make_fit('sign-configs-%s%s.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) sign_fit(sha_algo, sign_options) bcfg = u_boot_console.config.buildconfig max_size = int(bcfg.get('config_fit_signature_max_size', 0x10000000), 0) @@ -399,19 +416,19 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, # Compile our device tree files for kernel and U-Boot. These are # regenerated here since mkimage will modify them (by adding a # public key) below. - dtc('sandbox-kernel.dts') - dtc('sandbox-u-boot.dts') + dtc('sandbox-kernel.dts', cons, dtc_args, datadir, tmpdir, dtb) + dtc('sandbox-u-boot.dts', cons, dtc_args, datadir, tmpdir, dtb) cons.log.action('%s: Test FIT with configs images' % sha_algo) # Build the FIT with prod key (keys required) and sign it. This puts the # signature into sandbox-u-boot.dtb, marked 'required' - make_fit('sign-configs-%s%s-prod.its' % (sha_algo, padding)) + make_fit('sign-configs-%s%s-prod.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) sign_fit(sha_algo, sign_options) # Build the FIT with dev key (keys NOT required). This adds the # signature into sandbox-u-boot.dtb, NOT marked 'required'. - make_fit('sign-configs-%s%s.its' % (sha_algo, padding)) + make_fit('sign-configs-%s%s.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) sign_fit_norequire(sha_algo, sign_options) # So now sandbox-u-boot.dtb two signatures, for the prod and dev keys. @@ -423,7 +440,7 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, # Build the FIT with dev key (keys required) and sign it. This puts the # signature into sandbox-u-boot.dtb, marked 'required'. - make_fit('sign-configs-%s%s.its' % (sha_algo, padding)) + make_fit('sign-configs-%s%s.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) sign_fit(sha_algo, sign_options) # Set the required-mode policy to "any". @@ -461,17 +478,17 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, # Compile our device tree files for kernel and U-Boot. These are # regenerated here since mkimage will modify them (by adding a # public key) below. - dtc('sandbox-kernel.dts') + dtc('sandbox-kernel.dts', cons, dtc_args, datadir, tmpdir, dtb) dtc_options('sandbox-u-boot-global%s.dts' % padding, '-p 1024') # Build the FIT with dev key (keys NOT required). This adds the # signature into sandbox-u-boot.dtb, NOT marked 'required'. - make_fit('simple-images.its') + make_fit('simple-images.its', cons, mkimage, dtc_args, datadir, fit) sign_fit_dtb(sha_algo, '', dtb) # Build the dtb for binman that define the pre-load header # with the global sigature. - dtc('sandbox-binman%s.dts' % padding) + dtc('sandbox-binman%s.dts' % padding, cons, dtc_args, datadir, tmpdir, dtb) # Run binman to create the final image with the not signed fit # and the pre-load header that contains the global signature. @@ -531,3 +548,96 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, # Go back to the original U-Boot with the correct dtb. cons.config.dtb = old_dtb cons.restart_uboot() + + +TESTDATA_IN = [ + ['sha1-basic', 'sha1', '', None, False], + ['sha1-pad', 'sha1', '', '-E -p 0x10000', False], + ['sha1-pss', 'sha1', '-pss', None, False], + ['sha1-pss-pad', 'sha1', '-pss', '-E -p 0x10000', False], + ['sha256-basic', 'sha256', '', None, False], + ['sha256-pad', 'sha256', '', '-E -p 0x10000', False], + ['sha256-pss', 'sha256', '-pss', None, False], + ['sha256-pss-pad', 'sha256', '-pss', '-E -p 0x10000', False], + ['sha256-pss-required', 'sha256', '-pss', None, False], + ['sha256-pss-pad-required', 'sha256', '-pss', '-E -p 0x10000', False], + ['sha384-basic', 'sha384', '', None, False], + ['sha384-pad', 'sha384', '', '-E -p 0x10000', False], + ['algo-arg', 'algo-arg', '', '-o sha256,rsa2048', True], + ['sha256-global-sign', 'sha256', '', '', False], + ['sha256-global-sign-pss', 'sha256', '-pss', '', False], +] + +# Mark all but the first test as slow, so they are not run with '-k not slow' +TESTDATA = [TESTDATA_IN[0]] +TESTDATA += [pytest.param(*v, marks=pytest.mark.slow) for v in TESTDATA_IN[1:]] + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_signature') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +@pytest.mark.parametrize("name,sha_algo,padding,sign_options,algo_arg", TESTDATA) +def test_fdt_add_pubkey(u_boot_console, name, sha_algo, padding, sign_options, algo_arg): + """Test fdt_add_pubkey utility with bunch of different algo options.""" + + def sign_fit(sha_algo, options): + """Sign the FIT + + Signs the FIT and writes the signature into it. + + Args: + sha_algo: Either 'sha1' or 'sha256', to select the algorithm to + use. + options: Options to provide to mkimage. + """ + args = [mkimage, '-F', '-k', tmpdir, fit] + if options: + args += options.split(' ') + cons.log.action('%s: Sign images' % sha_algo) + util.run_and_log(cons, args) + + def test_add_pubkey(sha_algo, padding, sign_options): + """Test fdt_add_pubkey utility with given hash algorithm and padding. + + This function tests if fdt_add_pubkey utility may add public keys into dtb. + + Args: + sha_algo: Either 'sha1' or 'sha256', to select the algorithm to use + padding: Either '' or '-pss', to select the padding to use for the + rsa signature algorithm. + sign_options: Options to mkimage when signing a fit image. + """ + + # Create a fresh .dtb without the public keys + dtc('sandbox-u-boot.dts', cons, dtc_args, datadir, tmpdir, dtb) + + cons.log.action('%s: Test fdt_add_pubkey with signed configuration' % sha_algo) + # Then add the dev key via the fdt_add_pubkey tool + util.run_and_log(cons, [fdt_add_pubkey, '-a', '%s,%s' % ('sha256' if algo_arg else sha_algo, \ + 'rsa3072' if sha_algo == 'sha384' else 'rsa2048'), + '-k', tmpdir, '-n', 'dev', '-r', 'conf', dtb]) + + make_fit('sign-configs-%s%s.its' % (sha_algo, padding), cons, mkimage, dtc_args, datadir, fit) + + # Sign images with our dev keys + sign_fit(sha_algo, sign_options) + + # Check with fit_check_sign that FIT is signed with key + util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb]) + + cons = u_boot_console + tmpdir = os.path.join(cons.config.result_dir, name) + '/' + if not os.path.exists(tmpdir): + os.mkdir(tmpdir) + datadir = cons.config.source_dir + '/test/py/tests/vboot/' + fit = '%stest.fit' % tmpdir + mkimage = cons.config.build_dir + '/tools/mkimage' + binman = cons.config.source_dir + '/tools/binman/binman' + fit_check_sign = cons.config.build_dir + '/tools/fit_check_sign' + fdt_add_pubkey = cons.config.build_dir + '/tools/fdt_add_pubkey' + dtc_args = '-I dts -O dtb -i %s' % tmpdir + dtb = '%ssandbox-u-boot.dtb' % tmpdir + + # keys created in test_vboot test + + test_add_pubkey(sha_algo, padding, sign_options) From 2fb74a1d134bf675869e548c8f3f8c014b7ee473 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 11 Mar 2023 17:29:21 +0100 Subject: [PATCH 2/9] cmd: fdt: Use env_set_hex() for "get addr" and "get size" The 'fdt get addr' and 'env get size' is always assumed to be hex value, drop the prefix, and outright switch to env_set_hex(). Since this might break existing users who depend on the existing behavior with 0x prefix, this is a separate patch. Revert if this breaks anything. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- cmd/fdt.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 04b664e652c..87d9a385075 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -475,18 +475,9 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (ret != 0) return ret; } else if (subcmd[0] == 'a') { - /* Get address */ - char buf[19]; - - snprintf(buf, sizeof(buf), "%lx", - (ulong)map_to_sysmem(nodep)); - env_set(var, buf); + env_set_hex(var, (ulong)map_to_sysmem(nodep)); } else if (subcmd[0] == 's') { - /* Get size */ - char buf[11]; - - sprintf(buf, "0x%08X", len); - env_set(var, buf); + env_set_hex(var, len); } else return CMD_RET_USAGE; return 0; From d0bb00adccb8fb5187b49193127729d591ebd206 Mon Sep 17 00:00:00 2001 From: Quanyang Wang Date: Thu, 16 Mar 2023 14:11:46 +0800 Subject: [PATCH 3/9] pinctrl: fix pinctrl_gpio_get_pinctrl_and_offset for gpio-ranges array Sometimes a multi-element array is used for "gpio-ranges" property in dts file: qe_pio_e: gpio-controller@1460 { ...... gpio-ranges = <&pinctrl1 0 20 10>, <&pinctrl2 10 50 20>; ...... }; But the function pinctrl_gpio_get_pinctrl_and_offset can't handle this case because the "index" argument passed to dev_read_phandle_with_args is fixed to be "0". Use a loop to traverse the array to fix it. Signed-off-by: Quanyang Wang --- drivers/pinctrl/pinctrl-uclass.c | 47 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index 8837726cc16..73dd7b1038b 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -169,34 +169,33 @@ pinctrl_gpio_get_pinctrl_and_offset(struct udevice *dev, unsigned offset, { struct ofnode_phandle_args args; unsigned gpio_offset, pfc_base, pfc_pins; - int ret; + int ret = 0; + int i = 0; - ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3, - 0, &args); - if (ret) { - dev_dbg(dev, "%s: dev_read_phandle_with_args: err=%d\n", - __func__, ret); - return ret; - } + while (ret == 0) { + ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3, + i++, &args); + if (ret) { + dev_dbg(dev, "%s: dev_read_phandle_with_args: err=%d\n", + __func__, ret); + return ret; + } - ret = uclass_get_device_by_ofnode(UCLASS_PINCTRL, - args.node, pctldev); - if (ret) { - dev_dbg(dev, - "%s: uclass_get_device_by_of_offset failed: err=%d\n", - __func__, ret); - return ret; - } + ret = uclass_get_device_by_ofnode(UCLASS_PINCTRL, + args.node, pctldev); + if (ret) { + dev_dbg(dev, + "%s: uclass_get_device_by_of_offset failed: err=%d\n", + __func__, ret); + return ret; + } - gpio_offset = args.args[0]; - pfc_base = args.args[1]; - pfc_pins = args.args[2]; + gpio_offset = args.args[0]; + pfc_base = args.args[1]; + pfc_pins = args.args[2]; - if (offset < gpio_offset || offset > gpio_offset + pfc_pins) { - dev_dbg(dev, - "%s: GPIO can not be mapped to pincontrol pin\n", - __func__); - return -EINVAL; + if (offset >= gpio_offset && offset <= gpio_offset + pfc_pins) + break; } offset -= gpio_offset; From b4fae89c48b9a8c868c5b5f63af2d6737a54621e Mon Sep 17 00:00:00 2001 From: Peter Hoyes Date: Tue, 21 Mar 2023 13:01:16 +0000 Subject: [PATCH 4/9] fdt: Make fdt addr -q quieter 64597346 "fdt: Add -q option to fdt addr for distro_bootcmd" introduced the -q option for fdt addr, which sets the current working fdt address without printing any output. baf41410 "fdt: Show a message when the working FDT changes" made the utility function set_working_fdt_addr (in cmd/fdt.c) output a message on each invocation, even if called via fdt addr -q, in which case its output is now slightly noisier. To fix this, split out set_working_fdt_addr into set_working_fdt_addr plus the static function set_working_fdt_addr_quiet. set_working_fdt_addr_quiet can be called by "quiet" fdt cmd logic and set_working_fdt_addr is exported (as before) to other boot logic. The latter calls the former. Remove the assertion from the fdt addr test case when calling with the -q argument. Signed-off-by: Peter Hoyes Reviewed-by: Marek Vasut Reviewed-by: Simon Glass --- cmd/fdt.c | 19 ++++++++++++++----- test/cmd/fdt.c | 1 - 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 87d9a385075..aae3278526c 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -36,16 +36,21 @@ static int is_printable_string(const void *data, int len); */ struct fdt_header *working_fdt; -void set_working_fdt_addr(ulong addr) +static void set_working_fdt_addr_quiet(ulong addr) { void *buf; - printf("Working FDT set to %lx\n", addr); buf = map_sysmem(addr, 0); working_fdt = buf; env_set_hex("fdtaddr", addr); } +void set_working_fdt_addr(ulong addr) +{ + printf("Working FDT set to %lx\n", addr); + set_working_fdt_addr_quiet(addr); +} + /* * Get a value from the fdt and format it to be set in the environment */ @@ -192,10 +197,14 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if ((quiet && fdt_check_header(blob)) || (!quiet && !fdt_valid(&blob))) return 1; - if (control) + if (control) { gd->fdt_blob = blob; - else - set_working_fdt_addr(addr); + } else { + if (quiet) + set_working_fdt_addr_quiet(addr); + else + set_working_fdt_addr(addr); + } if (argc >= 2) { int len; diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 597fecbf62a..7835da232d5 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -236,7 +236,6 @@ static int fdt_test_addr_resize(struct unit_test_state *uts) /* ...quietly */ ut_assertok(run_commandf("fdt addr -q %08lx %zx", addr, sizeof(fdt) / 4)); - ut_assert_nextline("Working FDT set to %lx", addr); ut_assertok(ut_check_console_end(uts)); /* We cannot easily provoke errors in fdt_open_into(), so ignore that */ From 9599ce514c1801d8fb59f74462138cc92273ff5c Mon Sep 17 00:00:00 2001 From: Corentin Guillevic Date: Fri, 24 Mar 2023 14:43:36 +0100 Subject: [PATCH 5/9] doc: sandbox: replace sgdisk input with options The input provided to sgdisk is in fact aimed for sfdisk. The use of sgdisk and sfdisk, coming from different projects, is not the same. So, this commit translates the sfdisk-formatted input into sgdisk-compatible options. Partitions are not modified. Signed-off-by: Corentin Guillevic --- doc/arch/sandbox/sandbox.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arch/sandbox/sandbox.rst b/doc/arch/sandbox/sandbox.rst index cd7f8a2cb0d..77ca6bc4cc7 100644 --- a/doc/arch/sandbox/sandbox.rst +++ b/doc/arch/sandbox/sandbox.rst @@ -388,7 +388,7 @@ The device can be marked removeable with 'host bind -r'. A disk image can be created using the following commands:: $> truncate -s 1200M ./disk.raw - $> echo -e "label: gpt\n,64M,U\n,,L" | /usr/sbin/sgdisk ./disk.raw + $> /usr/sbin/sgdisk --new=1:0:+64M --typecode=1:EF00 --new=2:0:0 --typecode=2:8300 disk.raw $> lodev=`sudo losetup -P -f --show ./disk.raw` $> sudo mkfs.vfat -n EFI -v ${lodev}p1 $> sudo mkfs.ext4 -L ROOT -v ${lodev}p2 From 74b75aa6977c63f3605b266d6457feee3099934a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 2 Apr 2023 14:01:24 +1200 Subject: [PATCH 6/9] sandbox: Update the VBE firmware location The image size was increased but the firmware-update part was not updated. Correct this so that VBE firmware update can succeed with sandbox_vpl. Signed-off-by: Simon Glass Fixes: 85c66dc95c2 ("sandbox: Expand size for VPL image") --- arch/sandbox/dts/test.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index d72d7a567a7..7c1ee71cb7c 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -129,7 +129,7 @@ status = "disabled"; compatible = "fwupd,vbe-simple"; storage = "mmc3"; - skip-offset = <0x400000>; + skip-offset = <0x800000>; area-start = <0>; area-size = <0xe00000>; state-offset = <0xdffc00>; From 8511aabd98c9d13222846289bbb6bb8596c5f6ed Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 2 Apr 2023 14:01:25 +1200 Subject: [PATCH 7/9] vbe: Use the correct image filename in the test At present this inadvertently relies on having a symlink to the correct file from the current directory. Use the correct path to fix this. Signed-off-by: Simon Glass --- test/py/tests/test_vbe_vpl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/py/tests/test_vbe_vpl.py b/test/py/tests/test_vbe_vpl.py index d1c9d0548ae..ed12d3a4618 100644 --- a/test/py/tests/test_vbe_vpl.py +++ b/test/py/tests/test_vbe_vpl.py @@ -15,6 +15,7 @@ def test_vbe_vpl(u_boot_console): #cmd = [cons.config.build_dir + fname, '-v'] ram = os.path.join(cons.config.build_dir, 'ram.bin') fdt = os.path.join(cons.config.build_dir, 'arch/sandbox/dts/test.dtb') + image_fname = os.path.join(cons.config.build_dir, 'image.bin') # Enable firmware1 and the mmc that it uses. These are needed for the full # VBE flow. @@ -24,12 +25,13 @@ def test_vbe_vpl(u_boot_console): cons, f'fdtput -t s {fdt} /bootstd/firmware1 status okay') u_boot_utils.run_and_log( cons, f'fdtput -t s {fdt} /mmc3 status okay') + u_boot_utils.run_and_log( + cons, f'fdtput -t s {fdt} /mmc3 filename {image_fname}') # Remove any existing RAM file, so we don't have old data present if os.path.exists(ram): os.remove(ram) - flags = ['-p', os.path.join(cons.config.build_dir, 'image.bin'), '-w', - '-s', 'state.dtb'] + flags = ['-p', image_fname, '-w', '-s', 'state.dtb'] cons.restart_uboot_with_flags(flags) # Make sure that VBE was used in both VPL (to load SPL) and SPL (to load From 8b60987899919014f812eeffb807f87f3197b759 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 2 Apr 2023 14:01:26 +1200 Subject: [PATCH 8/9] CI: Ensure that vpl test is run This is actually skipped at present due to the condition in the file. Fix this by running all vpl tests. Signed-off-by: Simon Glass --- .azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 5594a67d6b5..64da11e87f5 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -263,7 +263,7 @@ stages: TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" sandbox_vpl: TEST_PY_BD: "sandbox_vpl" - TEST_PY_TEST_SPEC: "test_vpl_help or test_spl" + TEST_PY_TEST_SPEC: "vpl or test_spl" sandbox_noinst: TEST_PY_BD: "sandbox_noinst" TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5431bf6011a..2a423744c50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -301,7 +301,7 @@ sandbox_noinst_test.py: sandbox_vpl test.py: variables: TEST_PY_BD: "sandbox_vpl" - TEST_PY_TEST_SPEC: "test_vpl_help or test_spl" + TEST_PY_TEST_SPEC: "vpl or test_spl" <<: *buildman_and_testpy_dfn # Enable tracing and disable LTO, to ensure functions are not elided From 00be5197e8423b8b71744ad0e3f2753d4be0132b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 2 Apr 2023 14:01:27 +1200 Subject: [PATCH 9/9] test: Run the VPL tests with 'make check' Update the script to run VPL tests as well as the others. Signed-off-by: Simon Glass --- test/run | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/run b/test/run index 93b556f6cff..768b22577c4 100755 --- a/test/run +++ b/test/run @@ -56,6 +56,11 @@ echo "${prompt}" run_test "sandbox_noinst" ./test/py/test.py --bd sandbox_noinst --build ${para} \ -k 'test_ofplatdata or test_handoff or test_spl' +# Run tests which require sandbox_vpl +echo "${prompt}" +run_test "sandbox_vpl" ./test/py/test.py --bd sandbox_vpl --build ${para} \ + -k 'vpl or test_spl' + if [ -z "$tools_only" ]; then # Run tests for the flat-device-tree version of sandbox. This is a special # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can