The NAND tests use the devices which were registered when U-Boot started. If an earlier test probes the sandbox NAND controller, e.g. by calling mtd_probe_devices(), the controller registers its devices again, in the driver model of that test. When that test finishes, the controller is removed and the devices are unregistered, so the NAND tests which run after it fail, since there are no NAND devices left.
This happens if imagemap_test_mtd_blk runs before the NAND tests, and also with the MTD virtual concat tests, which are added next to the dm suite, ahead of the NAND tests. Probe the controller in each test, so that the devices are registered in the driver model of the test. Signed-off-by: Padmarao Begari <[email protected]> --- Changes in v2: - New patch: needed so that the new MTD virtual concat tests do not break the NAND tests which run after them test/dm/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/dm/nand.c b/test/dm/nand.c index c7e09850503..5ab52fc8051 100644 --- a/test/dm/nand.c +++ b/test/dm/nand.c @@ -3,6 +3,7 @@ * Copyright (C) 2023 Sean Anderson <[email protected]> */ +#include <dm.h> #include <nand.h> #include <part.h> #include <rand.h> @@ -15,6 +16,7 @@ static int run_test_nand(struct unit_test_state *uts, int dev, bool end) { nand_erase_options_t opts = { }; + struct udevice *ctrl; struct mtd_info *mtd; size_t length; loff_t size; @@ -28,6 +30,14 @@ static int run_test_nand(struct unit_test_state *uts, int dev, bool end) /* Seed RNG for bit errors */ srand((off >> 32) ^ off ^ ~dev); + /* + * Probe the controller, which registers the NAND devices. Another test + * may have probed it before, in a driver model which is now gone, in + * which case its devices are no longer registered. + */ + ut_assertok(uclass_get_device_by_driver(UCLASS_MTD, + DM_DRIVER_GET(sand_nand), + &ctrl)); mtd = get_nand_dev_by_index(dev); ut_assertnonnull(mtd); size = mtd->erasesize * 4; -- 2.34.1
