Skip to contentSkip to conversation

initramfs-framework: support force reboot if fatal error occurs

RFC PATCH Superseded Igor Opaniuk 2 participants 3 messages May 20, 2024 – May 21, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 initramfs-framework: support force reboot if fatal error occurs

Add support for force reboot in the case of fatal error. In some cases it's better to force reboot (especially when hw watchdog is not engaged) instead of waiting for 3600 seconds, for example in order to trigger some recovery procedure during next boot procedure (after unsuccessful OTA update etc).

ALso fix indendation issues in the fatal() function implementation.

---
 .../initrdscripts/initramfs-framework/init    | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)
meta/recipes-core/initrdscripts/initramfs-framework/init +13 -10
index 567694aff7..e3d8caa0e1 100755
@@ -54,17 +54,20 @@ debug() {
 }
 
 # Prints a message and start a endless loop
+# Force reboot if init_fatal_reboot bootparam is set
 fatal() {
-    echo $1 >/dev/console
-    echo >/dev/console
-
-    if [ -n "$bootparam_init_fatal_sh" ]; then
-        sh
-    else
-	while [ "true" ]; do
-		sleep 3600
-	done
-    fi
+	echo $1 >/dev/console
+	echo >/dev/console
+
+	if [ -n "$bootparam_init_fatal_reboot" ]; then
+		reboot -f
+	elif [ -n "$bootparam_init_fatal_sh" ]; then
+		sh
+	else
+		while [ "true" ]; do
+			sleep 3600
+		done
+	fi
 }
 
 # Variables shared amoung modules
Signature · 1 line
2.34.1
#1 lore raw

Seems ok to me, you can resend without the RFC.

Alex

Quoted 61 lines · Igor Opaniuk via lists.openembedded.org

Add support for force reboot in the case of fatal error. In some cases it's better to force reboot (especially when hw watchdog is not engaged) instead of waiting for 3600 seconds, for example in order to trigger some recovery procedure during next boot procedure (after unsuccessful OTA update etc).

ALso fix indendation issues in the fatal() function implementation.

---
 .../initrdscripts/initramfs-framework/init    | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)
meta/recipes-core/initrdscripts/initramfs-framework/init +13 -11
index 567694aff7..e3d8caa0e1 100755
@@ -54,17 +54,20 @@ debug() {
 }
 
 # Prints a message and start a endless loop
+# Force reboot if init_fatal_reboot bootparam is set
 fatal() {
-    echo $1 >/dev/console
-    echo >/dev/console
-
-    if [ -n "$bootparam_init_fatal_sh" ]; then
-        sh
-    else
-       while [ "true" ]; do
-               sleep 3600
-       done
-    fi
+       echo $1 >/dev/console
+       echo >/dev/console
+
+       if [ -n "$bootparam_init_fatal_reboot" ]; then
+               reboot -f
+       elif [ -n "$bootparam_init_fatal_sh" ]; then
+               sh
+       else
+               while [ "true" ]; do
+                       sleep 3600
+               done
+       fi
 }
 
 # Variables shared amoung modules
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199595): https://lists.openembedded.org/g/openembedded-core/message/199595
Mute This Topic: https://lists.openembedded.org/mt/106205536/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Hello Alex,

Quoted 2 lines · Alexander Kanavin

Seems ok to me, you can resend without the RFC.

I'll just send v2 without the RFC tag, thanks!

Quoted 66 lines

Alex

Quoted 61 lines · Igor Opaniuk via lists.openembedded.org

Add support for force reboot in the case of fatal error. In some cases it's better to force reboot (especially when hw watchdog is not engaged) instead of waiting for 3600 seconds, for example in order to trigger some recovery procedure during next boot procedure (after unsuccessful OTA update etc).

ALso fix indendation issues in the fatal() function implementation.

---
 .../initrdscripts/initramfs-framework/init    | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)
meta/recipes-core/initrdscripts/initramfs-framework/init +13 -11
index 567694aff7..e3d8caa0e1 100755
@@ -54,17 +54,20 @@ debug() {
 }
 
 # Prints a message and start a endless loop
+# Force reboot if init_fatal_reboot bootparam is set
 fatal() {
-    echo $1 >/dev/console
-    echo >/dev/console
-
-    if [ -n "$bootparam_init_fatal_sh" ]; then
-        sh
-    else
-       while [ "true" ]; do
-               sleep 3600
-       done
-    fi
+       echo $1 >/dev/console
+       echo >/dev/console
+
+       if [ -n "$bootparam_init_fatal_reboot" ]; then
+               reboot -f
+       elif [ -n "$bootparam_init_fatal_sh" ]; then
+               sh
+       else
+               while [ "true" ]; do
+                       sleep 3600
+               done
+       fi
 }
 
 # Variables shared amoung modules
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199595): https://lists.openembedded.org/g/openembedded-core/message/199595
Mute This Topic: https://lists.openembedded.org/mt/106205536/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 6 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk
Senior Software Engineer, Embedded & Security
E: [email protected]
W: www.foundries.io