Skip to contentSkip to conversation

cmd: add a panic command

PATCH Superseded Heiko Stuebner 2 participants 2 messages Jun 26, 2020 – Jun 29, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: add a panic command

From: Heiko Stuebner <[email protected]>

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 uboot and can take an optional message.

---
 cmd/Makefile |  1 +
 cmd/panic.c  | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 cmd/panic.c
cmd/Makefile +1 -0
index ac843b4b16..027fa9083a 100644
@@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
 obj-y += boot.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y += help.o
+obj-y += panic.o
 obj-y += version.o
 
 # command
cmd/panic.c new file +22 -0
new file mode 100644
index 0000000000..696b4c73a3
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH
+ */
+
+#include <common.h>
+#include <command.h>
+
+static int do_panic(cmd_tbl_t *cmdtp, int flag, int argc,
+		    char * const argv[])
+{
+	char *text = (argc < 2) ? "" : argv[1];
+
+	panic(text);
+	return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+	panic,	2,	1,	do_panic,
+	"Panic with optional message",
+	"[message]"
+);
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 cmd: add a panic command

Quoted 9 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

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 uboot and can take an optional message.

U-Boot

Quoted 7 lines
---
 cmd/Makefile |  1 +
 cmd/panic.c  | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 cmd/panic.c

nit below

Quoted 23 lines
cmd/Makefile +1 -0
index ac843b4b16..027fa9083a 100644
@@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
 obj-y += boot.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y += help.o
+obj-y += panic.o
 obj-y += version.o
 
 # command
cmd/panic.c new file +4 -0
new file mode 100644
index 0000000000..696b4c73a3
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH
+ */

cmd/panic.c line 14

Quoted 10 lines
cmd/panic.c new file +10 -0
+
+#include <common.h>
+#include <command.h>
+
+static int do_panic(cmd_tbl_t *cmdtp, int flag, int argc,
+                   char * const argv[])
+{
+       char *text = (argc < 2) ? "" : argv[1];
+
+       panic(text);

blank line here

Quoted 11 lines
cmd/panic.c new file +8 -1
+       return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+       panic,  2,      1,      do_panic,
+       "Panic with optional message",
+       "[message]"
+);
--

2.26.2