From e45d22655aed0c81fa5890f47c1647c6e95bedb6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:12 -0600 Subject: vbe: Drop the U-Boot prefix from the version We don't need the U-Boot prefix on the version and in fact it is harmful since pytest gets confused seeing the U-Boot banner bring displayed when the version is printed. Drop the prefix from the string. We could produce an entirely new string from the component parts, but this adds to the rodata size and would break the use of version_string as the only thing which holds this information. Signed-off-by: Simon Glass --- test/boot/vbe_simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/boot/vbe_simple.c') diff --git a/test/boot/vbe_simple.c b/test/boot/vbe_simple.c index faba9e8f90..a50785dbbf 100644 --- a/test/boot/vbe_simple.c +++ b/test/boot/vbe_simple.c @@ -77,7 +77,7 @@ static int vbe_simple_test_base(struct unit_test_state *uts) bl_version = ofnode_read_string(node, "bootloader-version"); ut_assertnonnull(bl_version); - ut_asserteq_str(version_string, bl_version); + ut_asserteq_str(version_string + 7, bl_version); return 0; } -- cgit v1.2.3 From a56f663f07073713042bb0fd08053aeb667e717b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:14 -0600 Subject: vbe: Add info about the VBE device to the fwupd node At present we put the driver in the /chosen node in U-Boot. This is a bit strange, since U-Boot doesn't normally use that node itself. It is better to put it under the bootstd node. To make this work we need to copy create the node under /chosen when fixing up the device tree. Copy over all the properties so that fwupd knows what to do. Update the sandbox device tree accordingly. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 29 ++++++++++++++--------------- boot/vbe_simple_os.c | 26 ++++++++++++++++++-------- test/boot/vbe_simple.c | 7 ++++++- 3 files changed, 38 insertions(+), 24 deletions(-) (limited to 'test/boot/vbe_simple.c') diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index db72c64b1e..2bcc2e84a7 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -78,6 +78,7 @@ }; bootstd { + u-boot,dm-vpl; compatible = "u-boot,boot-std"; filename-prefixes = "/", "/boot/"; @@ -90,6 +91,19 @@ efi { compatible = "u-boot,distro-efi"; }; + + firmware0 { + u-boot,dm-vpl; + compatible = "fwupd,vbe-simple"; + storage = "mmc1"; + skip-offset = <0x200>; + area-start = <0x400>; + area-size = <0x1000>; + state-offset = <0x400>; + state-size = <0x40>; + version-offset = <0x800>; + version-size = <0x100>; + }; }; fuzzing-engine { @@ -1404,21 +1418,6 @@ compatible = "denx,u-boot-fdt-test"; reg = <9 1>; }; - - fwupd { - compatible = "simple-bus"; - firmware0 { - compatible = "fwupd,vbe-simple"; - storage = "mmc1"; - area-start = <0x400>; - area-size = <0x1000>; - skip-offset = <0x200>; - state-offset = <0x400>; - state-size = <0x40>; - version-offset = <0x800>; - version-size = <0x100>; - }; - }; }; translation-test@8000 { diff --git a/boot/vbe_simple_os.c b/boot/vbe_simple_os.c index 87778bba97..b2041a95a3 100644 --- a/boot/vbe_simple_os.c +++ b/boot/vbe_simple_os.c @@ -62,24 +62,34 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event) */ for (vbe_find_first_device(&dev); dev; vbe_find_next_device(&dev)) { struct simple_state state; - ofnode node, subnode; + ofnode node, subnode, chosen; int ret; if (strcmp("vbe_simple", dev->driver->name)) continue; - /* Check if there is a node to fix up */ - node = oftree_path(tree, "/chosen/fwupd"); - if (!ofnode_valid(node)) - continue; - subnode = ofnode_find_subnode(node, dev->name); - if (!ofnode_valid(subnode)) + /* Check if there is a node to fix up, adding if not */ + chosen = oftree_path(tree, "/chosen"); + if (!ofnode_valid(chosen)) continue; + ret = ofnode_add_subnode(chosen, "fwupd", &node); + if (ret && ret != -EEXIST) + return log_msg_ret("fwu", ret); + + ret = ofnode_add_subnode(node, dev->name, &subnode); + if (ret && ret != -EEXIST) + return log_msg_ret("dev", ret); - log_debug("Fixing up: %s\n", dev->name); ret = device_probe(dev); if (ret) return log_msg_ret("probe", ret); + + /* Copy over the vbe properties for fwupd */ + log_debug("Fixing up: %s\n", dev->name); + ret = ofnode_copy_props(dev_ofnode(dev), subnode); + if (ret) + return log_msg_ret("cp", ret); + ret = vbe_simple_read_state(dev, &state); if (ret) return log_msg_ret("read", ret); diff --git a/test/boot/vbe_simple.c b/test/boot/vbe_simple.c index a50785dbbf..5e61840652 100644 --- a/test/boot/vbe_simple.c +++ b/test/boot/vbe_simple.c @@ -16,7 +16,12 @@ #include #include "bootstd_common.h" -/* Basic test of reading nvdata and updating a fwupd node in the device tree */ +/* + * Basic test of reading nvdata and updating a fwupd node in the device tree + * + * This sets up its own VBE info in the device, using bootstd_setup_for_tests() + * then does a VBE fixup and checks that everything is present. + */ static int vbe_simple_test_base(struct unit_test_state *uts) { const char *version, *bl_version; -- cgit v1.2.3