diff options
author | Tom Rini <trini@konsulko.com> | 2022-10-18 07:36:52 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-10-18 07:36:52 -0400 |
commit | 700b4fe782f9fc46b7be1b1a93a49356baeccc3f (patch) | |
tree | 7c4f01a95ceb7288ac9f95ffb59c2ea11b0a33cf /test/boot/bootstd_common.c | |
parent | d3031d442b941f059eb83bb67ca10a28a0539f9a (diff) | |
parent | ae0bf2214b81b56a5670819958234947443680be (diff) |
Merge tag 'dm-pull-18oct22' of https://source.denx.de/u-boot/custodians/u-boot-dm
Update uclass iterators to work better when devices fail to probe
Support VBE OS requests / fixups
Minor error-handling tweaks to bootm command
Diffstat (limited to 'test/boot/bootstd_common.c')
-rw-r--r-- | test/boot/bootstd_common.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index 05347d87106..7a40836507a 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -9,10 +9,52 @@ #include <common.h> #include <bootstd.h> #include <dm.h> +#include <memalign.h> +#include <mmc.h> +#include <linux/log2.h> #include <test/suites.h> #include <test/ut.h> +#include <u-boot/crc.h> #include "bootstd_common.h" +/* tracks whether bootstd_setup_for_tests() has been run yet */ +bool vbe_setup_done; + +/* set up MMC for VBE tests */ +int bootstd_setup_for_tests(void) +{ + ALLOC_CACHE_ALIGN_BUFFER(u8, buf, MMC_MAX_BLOCK_LEN); + struct udevice *mmc; + struct blk_desc *desc; + int ret; + + if (vbe_setup_done) + return 0; + + /* Set up the version string */ + ret = uclass_get_device(UCLASS_MMC, 1, &mmc); + if (ret) + return log_msg_ret("mmc", -EIO); + desc = blk_get_by_device(mmc); + + memset(buf, '\0', MMC_MAX_BLOCK_LEN); + strcpy(buf, TEST_VERSION); + if (blk_dwrite(desc, VERSION_START_BLK, 1, buf) != 1) + return log_msg_ret("wr1", -EIO); + + /* Set up the nvdata */ + memset(buf, '\0', MMC_MAX_BLOCK_LEN); + buf[1] = ilog2(0x40) << 4 | 1; + *(u32 *)(buf + 4) = TEST_VERNUM; + buf[0] = crc8(0, buf + 1, 0x3f); + if (blk_dwrite(desc, NVDATA_START_BLK, 1, buf) != 1) + return log_msg_ret("wr2", -EIO); + + vbe_setup_done = true; + + return 0; +} + int bootstd_test_drop_bootdev_order(struct unit_test_state *uts) { struct bootstd_priv *priv; @@ -29,6 +71,13 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test); const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd_test); + int ret; + + ret = bootstd_setup_for_tests(); + if (ret) { + printf("Failed to set up for bootstd tests (err=%d)\n", ret); + return CMD_RET_FAILURE; + } return cmd_ut_category("bootstd", "bootstd_test_", tests, n_ents, argc, argv); |