changeset 490:3d7b546c710c

target-utils/flash-boot-test: more watchdog experimentation commands
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 21 May 2019 23:48:26 +0000
parents 9fce32cc6220
children 34795475dd4f
files target-utils/flash-boot-test/cmdtab.c target-utils/flash-boot-test/watchdog.c
diffstat 2 files changed, 49 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/flash-boot-test/cmdtab.c	Tue May 21 21:25:07 2019 +0000
+++ b/target-utils/flash-boot-test/cmdtab.c	Tue May 21 23:48:26 2019 +0000
@@ -11,7 +11,11 @@
 extern void cmd_w32();
 
 extern void cmd_memdump_human();
-extern void cmd_watchdog_disable();
+
+extern void cmd_wd();
+extern void cmd_we();
+extern void cmd_wr();
+extern void cmd_ww();
 
 extern void abb_init();
 extern void abb_power_off();
@@ -29,6 +33,9 @@
 	{"w8", cmd_w8},
 	{"w16", cmd_w16},
 	{"w32", cmd_w32},
-	{"wd", cmd_watchdog_disable},
+	{"wd", cmd_wd},
+	{"we", cmd_we},
+	{"wr", cmd_wr},
+	{"ww", cmd_ww},
 	{0, 0}
 };
--- a/target-utils/flash-boot-test/watchdog.c	Tue May 21 21:25:07 2019 +0000
+++ b/target-utils/flash-boot-test/watchdog.c	Tue May 21 23:48:26 2019 +0000
@@ -1,9 +1,48 @@
+#include <sys/types.h>
 #include "types.h"
 
 void
-cmd_watchdog_disable()
+cmd_wd()
 {
 	/* stop/disable the watchdog timer */
 	*(volatile u16 *)0xFFFFF804 = 0xF5;
 	*(volatile u16 *)0xFFFFF804 = 0xA0;
 }
+
+void
+cmd_we()
+{
+	/* watchdog enable */
+	*(volatile u16 *)0xFFFFF804 = 0x8000;
+}
+
+void
+cmd_wr()
+{
+	/* read and display watchdog downcount register */
+	printf("%04X\n", *(volatile u16 *)0xFFFFF802);
+}
+
+void
+cmd_ww(argbulk)
+	char *argbulk;
+{
+	/* single or double write to WATCHDOG_TIM_MODE */
+	char *argv[3];
+	u_long w1, w2;
+
+	if (parse_args(argbulk, 1, 2, argv, 0) < 0)
+		return;
+	if (parse_hexarg(argv[0], 4, &w1) < 0) {
+		printf("ERROR: arg1 must be a valid 16-bit hex value\n");
+		return;
+	}
+	if (argv[1] && parse_hexarg(argv[1], 4, &w2) < 0) {
+		printf("ERROR: arg2 must be a valid 16-bit hex value\n");
+		return;
+	}
+	/* do it */
+	*(volatile u16 *)0xFFFFF804 = w1;
+	if (argv[1])
+		*(volatile u16 *)0xFFFFF804 = w2;
+}