Merge tag 'u-boot-stm32-20250131' of https://source.denx.de/u-boot/custodians/u-boot-stm
[u-boot.git] / cmd / diag.c
blobc6da5aae3fcd9aeba2e62144ace249bf26d63f6a
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2002
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 */
7 /*
8 * Diagnostics support
9 */
10 #include <command.h>
11 #include <post.h>
13 int do_diag(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
15 unsigned int i;
17 if (argc == 1 || strcmp (argv[1], "run") != 0) {
18 /* List test info */
19 if (argc == 1) {
20 puts ("Available hardware tests:\n");
21 post_info (NULL);
22 puts ("Use 'diag [<test1> [<test2> ...]]'"
23 " to get more info.\n");
24 puts ("Use 'diag run [<test1> [<test2> ...]]'"
25 " to run tests.\n");
26 } else {
27 for (i = 1; i < argc; i++) {
28 if (post_info (argv[i]) != 0)
29 printf ("%s - no such test\n", argv[i]);
32 } else {
33 /* Run tests */
34 if (argc == 2) {
35 post_run (NULL, POST_RAM | POST_MANUAL);
36 } else {
37 for (i = 2; i < argc; i++) {
38 if (post_run (argv[i], POST_RAM | POST_MANUAL) != 0)
39 printf ("%s - unable to execute the test\n",
40 argv[i]);
45 return 0;
47 /***************************************************/
49 U_BOOT_CMD(
50 diag, CONFIG_SYS_MAXARGS, 0, do_diag,
51 "perform board diagnostics",
52 " - print list of available tests\n"
53 "diag [test1 [test2]]\n"
54 " - print information about specified tests\n"
55 "diag run - run all available tests\n"
56 "diag run [test1 [test2]]\n"
57 " - run specified tests"