diff options
author | Sean Anderson <seanga2@gmail.com> | 2023-10-14 16:48:05 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-17 20:50:52 -0400 |
commit | 60d76e332d8031eab6937778b3ed7b6558c2b3f1 (patch) | |
tree | 8e63d4db50b7aef9db5b2106e5e6ec3780410ebc /test/image | |
parent | 65efaac425e948dc56db5cf315d0497faeddb5b0 (diff) | |
download | u-boot-60d76e332d8031eab6937778b3ed7b6558c2b3f1.tar.gz u-boot-60d76e332d8031eab6937778b3ed7b6558c2b3f1.tar.bz2 u-boot-60d76e332d8031eab6937778b3ed7b6558c2b3f1.zip |
test: spl: Add a test for the SPI load method
Add test for the SPI load method. This one is pretty straightforward. We
can't enable FIT_EXTERNAL with LOAD_FIT_FULL because spl_spi_load_image
doesn't know the total image size and has to guess from fdt_totalsize. This
doesn't include external data, so loading it will fail.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/image')
-rw-r--r-- | test/image/Kconfig | 8 | ||||
-rw-r--r-- | test/image/Makefile | 1 | ||||
-rw-r--r-- | test/image/spl_load.c | 1 | ||||
-rw-r--r-- | test/image/spl_load_spi.c | 41 |
4 files changed, 51 insertions, 0 deletions
diff --git a/test/image/Kconfig b/test/image/Kconfig index 99c5078781..8f9e6ae036 100644 --- a/test/image/Kconfig +++ b/test/image/Kconfig @@ -32,6 +32,14 @@ config SPL_UT_LOAD_NET help Test loading images over TFTP using the NET image load method. +config SPL_UT_LOAD_SPI + bool "Test loading from SPI Flash" + depends on SANDBOX && SPL_OF_REAL + depends on SPL_SPI_LOAD + default y + help + Test the SPI flash image load metod. + config SPL_UT_LOAD_OS bool "Test loading from the host OS" depends on SANDBOX && SPL_LOAD_FIT diff --git a/test/image/Makefile b/test/image/Makefile index a82aa40449..b30210106a 100644 --- a/test/image/Makefile +++ b/test/image/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_SPL_UT_LOAD_FS) += spl_load_fs.o obj-$(CONFIG_SPL_UT_LOAD_NET) += spl_load_net.o obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_load_nor.o obj-$(CONFIG_SPL_UT_LOAD_OS) += spl_load_os.o +obj-$(CONFIG_SPL_UT_LOAD_SPI) += spl_load_spi.o diff --git a/test/image/spl_load.c b/test/image/spl_load.c index 07a986258d..ab4c14d649 100644 --- a/test/image/spl_load.c +++ b/test/image/spl_load.c @@ -9,6 +9,7 @@ #include <mapmem.h> #include <memalign.h> #include <rand.h> +#include <spi_flash.h> #include <spl.h> #include <test/spl.h> #include <test/ut.h> diff --git a/test/image/spl_load_spi.c b/test/image/spl_load_spi.c new file mode 100644 index 0000000000..8f9b6e0139 --- /dev/null +++ b/test/image/spl_load_spi.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Sean Anderson <seanga2@gmail.com> + */ + +#include <common.h> +#include <dm.h> +#include <spi_flash.h> +#include <spl.h> +#include <test/spl.h> +#include <test/ut.h> + +static int spl_test_spi_write_image(struct unit_test_state *uts, void *img, + size_t img_size) +{ + struct spi_flash *flash; + + flash = spi_flash_probe(spl_spi_boot_bus(), spl_spi_boot_cs(), + CONFIG_SF_DEFAULT_SPEED, + CONFIG_SF_DEFAULT_MODE); + ut_assertnonnull(flash); + ut_assertok(spi_flash_write(flash, spl_spi_get_uboot_offs(flash), + img_size, img)); + + return 0; +} + +static int spl_test_spi(struct unit_test_state *uts, const char *test_name, + enum spl_test_image type) +{ + return do_spl_test_load(uts, test_name, type, + SPL_LOAD_IMAGE_GET(1, BOOT_DEVICE_SPI, + spl_spi_load_image), + spl_test_spi_write_image); +} +SPL_IMG_TEST(spl_test_spi, LEGACY, DM_FLAGS); +SPL_IMG_TEST(spl_test_spi, IMX8, DM_FLAGS); +SPL_IMG_TEST(spl_test_spi, FIT_INTERNAL, DM_FLAGS); +#if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) +SPL_IMG_TEST(spl_test_spi, FIT_EXTERNAL, DM_FLAGS); +#endif |