summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2023-02-01 00:16:13 +0100
committerTom Rini <trini@konsulko.com>2023-02-06 17:10:15 -0500
commit41a29f284cef48a86c86d038c0cd8cc1c851417e (patch)
treef1533069fcdbcf265deb0ea6b3b940e81902d9b3 /test
parentccd0542ab2607228c8e434e2875b014f9bba49f8 (diff)
cmd: Add a SEAMA image load command
Add a command to load SEAMA (Seattle Image), a NAND flash on-flash storage format. This type of flash image is found in some D-Link routers such as DIR-645, DIR-842, DIR-859, DIR-860L, DIR-885L, DIR890L and DCH-M225, as well as in WD and NEC routers on the ath79 (MIPS), Broadcom BCM53xx, and RAMIPS platforms. This U-Boot command will read and decode a SEAMA image from raw NAND flash on any platform. As it is always using big endian format for the data decoding is always necessary on platforms such as ARM. The command is needed to read a SEAMA-encoded boot image on the D-Link DIR-890L router for boot from NAND flash in an upcoming port of U-Boot to the Broadcom Northstar (BCM4709, BCM53xx) architecture. A basic test and documentation is added as well. The test must be run on a target with NAND flash support and at least one resident SEAMA image in flash. Cc: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'test')
-rw-r--r--test/cmd/Makefile1
-rw-r--r--test/cmd/seama.c71
-rw-r--r--test/cmd_ut.c6
3 files changed, 78 insertions, 0 deletions
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 09e410ec30..2ffde8703a 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_CMD_LOADM) += loadm.o
obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
obj-$(CONFIG_CMD_PINMUX) += pinmux.o
obj-$(CONFIG_CMD_PWM) += pwm.o
+obj-$(CONFIG_CMD_SEAMA) += seama.o
ifdef CONFIG_SANDBOX
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
endif
diff --git a/test/cmd/seama.c b/test/cmd/seama.c
new file mode 100644
index 0000000000..b1b56930c6
--- /dev/null
+++ b/test/cmd/seama.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Executes tests for SEAMA (SEAttle iMAge) command
+ *
+ * Copyright (C) 2021 Linus Walleij <linus.walleij@linaro.org>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <dm.h>
+#include <test/suites.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+#define SEAMA_TEST(_name, _flags) UNIT_TEST(_name, _flags, seama_test)
+
+static int seama_test_noargs(struct unit_test_state *uts)
+{
+ /* Test that 'seama' with no arguments fails gracefully */
+ console_record_reset();
+ run_command("seama", 0);
+ ut_assert_nextlinen("seama - Load the SEAMA image and sets envs");
+ ut_assert_skipline();
+ ut_assert_skipline();
+ ut_assert_skipline();
+ ut_assert_skipline();
+ ut_assert_console_end();
+ return 0;
+}
+SEAMA_TEST(seama_test_noargs, UT_TESTF_CONSOLE_REC);
+
+static int seama_test_addr(struct unit_test_state *uts)
+{
+ /* Test that loads SEAMA image 0 to address 0x01000000 */
+ console_record_reset();
+ run_command("seama 0x01000000", 0);
+ ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
+ ut_assert_nextlinen("SEMA IMAGE:");
+ ut_assert_nextlinen(" metadata size ");
+ ut_assert_nextlinen(" image size ");
+ ut_assert_nextlinen(" checksum ");
+ ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
+ ut_assert_console_end();
+ return 0;
+}
+SEAMA_TEST(seama_test_addr, UT_TESTF_CONSOLE_REC);
+
+static int seama_test_index(struct unit_test_state *uts)
+{
+ /* Test that loads SEAMA image 0 exlicitly specified */
+ console_record_reset();
+ run_command("seama 0x01000000 0", 0);
+ ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
+ ut_assert_nextlinen("SEMA IMAGE:");
+ ut_assert_nextlinen(" metadata size ");
+ ut_assert_nextlinen(" image size ");
+ ut_assert_nextlinen(" checksum ");
+ ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
+ ut_assert_console_end();
+ return 0;
+}
+SEAMA_TEST(seama_test_index, UT_TESTF_CONSOLE_REC);
+
+int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct unit_test *tests = UNIT_TEST_SUITE_START(seama_test);
+ const int n_ents = UNIT_TEST_SUITE_COUNT(seama_test);
+
+ return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc,
+ argv);
+}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 1713d0d1c8..409c22bfd2 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -110,6 +110,9 @@ static struct cmd_tbl cmd_ut_sub[] = {
#ifdef CONFIG_CMD_LOADM
U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""),
#endif
+#ifdef CONFIG_CMD_SEAMA
+ U_BOOT_CMD_MKENT(seama, CONFIG_SYS_MAXARGS, 1, do_ut_seama, "", ""),
+#endif
};
static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -212,6 +215,9 @@ static char ut_help_text[] =
#ifdef CONFIG_SANDBOX
"\nstr - basic test of string functions"
#endif
+#ifdef CONFIG_CMD_SEAMA
+ "\nseama - seama command parameters loading and decoding"
+#endif
#ifdef CONFIG_UT_TIME
"\ntime - very basic test of time functions"
#endif