1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
From c82bf9de515cbbdb4ea1a350be83fb89f4a83631 Mon Sep 17 00:00:00 2001
From: James Feist <james.feist@linux.intel.com>
Date: Wed, 31 Jul 2019 16:01:49 -0700
Subject: [PATCH 1/1] Reboot into UBOOT on Watchdog Failures
We use watchdog1 to reboot when there is a watchdog
error. Reboot into u-boot as we are using that as
safe mode.
Tested: watchdog -T 0 -F /dev/watchdog1 reboots into
uboot after 3 times
Signed-off-by: James Feist <james.feist@linux.intel.com>
---
.../include/asm/arch-aspeed/ast-g5-intel.h | 1 +
board/aspeed/ast-g5/ast-g5-intel.c | 31 +++++++++++++++++++
common/autoboot.c | 2 ++
3 files changed, 34 insertions(+)
diff --git a/arch/arm/include/asm/arch-aspeed/ast-g5-intel.h b/arch/arm/include/asm/arch-aspeed/ast-g5-intel.h
index a88521a1b3..64f4ed17bf 100644
--- a/arch/arm/include/asm/arch-aspeed/ast-g5-intel.h
+++ b/arch/arm/include/asm/arch-aspeed/ast-g5-intel.h
@@ -14,6 +14,7 @@
#ifndef __ASSEMBLY__
int intel_force_firmware_jumper_enabled(void);
+int intel_failed_boot(void);
void start_fw_update_loop(void);
#endif
diff --git a/board/aspeed/ast-g5/ast-g5-intel.c b/board/aspeed/ast-g5/ast-g5-intel.c
index e68ab8546a..c003d9a7bc 100644
--- a/board/aspeed/ast-g5/ast-g5-intel.c
+++ b/board/aspeed/ast-g5/ast-g5-intel.c
@@ -111,6 +111,24 @@ static const GPIOValue gpio_table[] = {
#define HOST_SERIAL_A_HIGH_SPEED (1 << 0)
#define HOST_SERIAL_B_HIGH_SPEED (1 << 1)
+#define WATCHDOG_RESET_BIT 0x8
+#define BOOT_FAILURE_LIMIT 0x3
+
+static int get_boot_failures(void)
+{
+ return getenv_ulong("bootfailures", 10, 0);
+}
+
+static void set_boot_failures(u32 count)
+{
+ if (count > BOOT_FAILURE_LIMIT)
+ return;
+
+ setenv_ulong("bootfailures", count);
+ saveenv();
+}
+
+
static void sgpio_init(void)
{
uint32_t value;
@@ -270,6 +288,11 @@ int intel_force_firmware_jumper_enabled(void)
return gpio_get_value(GPIO_FF_UPD_JUMPER);
}
+int intel_failed_boot(void)
+{
+ return get_boot_failures() >= BOOT_FAILURE_LIMIT;
+}
+
void arch_preboot_os(void)
{
// last second before booting... set the LEDs
@@ -402,6 +425,7 @@ void ast_g5_intel_late_init(void)
{
char value[32];
u32 reset_reason = 0;
+ u32 boot_failures = 0;
/* By default host serail A and B use normal speed */
uint32_t host_serial_cfg = 0;
@@ -446,6 +470,13 @@ void ast_g5_intel_late_init(void)
update_bootargs_cmd("resetreason", value);
+ boot_failures = get_boot_failures();
+
+ if (reset_reason & WATCHDOG_RESET_BIT)
+ set_boot_failures(boot_failures + 1);
+ else
+ set_boot_failures(0);
+
/* Update the special mode in bootargs */
if (is_mfg_mode_phy_req())
update_bootargs_cmd("special", "mfg");
diff --git a/common/autoboot.c b/common/autoboot.c
index 45a600e663..03fd164501 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -263,6 +263,8 @@ static int abortboot(int bootdelay)
# ifdef AST_G5_INTEL
if (intel_force_firmware_jumper_enabled())
return 1;
+ if (intel_failed_boot())
+ return 1;
# endif
if (bootdelay >= 0)
--
2.17.1
|