Skip to content

Commit 85ecfd1

Browse files
mmindtrini
authored andcommitted
cmd: add a panic command
Even in boot scripts it may be needed to "panic" when all options are exhausted and the device specification specifies hanging instead of resetting the board. So add a new panic command that just wraps around the core panic call in U-Boot and can take an optional message. Signed-off-by: Heiko Stuebner <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
1 parent ce6515e commit 85ecfd1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cmd/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
88
obj-y += boot.o
99
obj-$(CONFIG_CMD_BOOTM) += bootm.o
1010
obj-y += help.o
11+
obj-y += panic.o
1112
obj-y += version.o
1213

1314
# command

cmd/panic.c

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH
4+
*/
5+
6+
#include <common.h>
7+
#include <command.h>
8+
9+
static int do_panic(struct cmd_tbl *cmdtp, int flag, int argc,
10+
char * const argv[])
11+
{
12+
char *text = (argc < 2) ? "" : argv[1];
13+
14+
panic(text);
15+
16+
return CMD_RET_SUCCESS;
17+
}
18+
19+
U_BOOT_CMD(
20+
panic, 2, 1, do_panic,
21+
"Panic with optional message",
22+
"[message]"
23+
);

0 commit comments

Comments
 (0)