From 87bc6780d73b449e66ac7e4ba2e21895475e82d0 Mon Sep 17 00:00:00 2001
From: Andreas Gnau <andreas.gnau@iopsys.eu>
Date: Mon, 10 Mar 2025 14:01:43 +0100
Subject: [PATCH] brcmbca: Acknowledge boot using steadystate as well

Acknowledge the boot using the steadystate / support_fallback feature
introduced in BCM SDK 5.04L.04p2 as well. Not doing so and having the
feature enabled will lead to fallbacks to the other bank.

Signed-off-by: Andreas Gnau <andreas.gnau@iopsys.eu>
---
 .../base-files/etc/init.d/ack_boot_success    | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/brcmbca/base-files/etc/init.d/ack_boot_success b/brcmbca/base-files/etc/init.d/ack_boot_success
index c0764999e..c3c5ca9f9 100755
--- a/brcmbca/base-files/etc/init.d/ack_boot_success
+++ b/brcmbca/base-files/etc/init.d/ack_boot_success
@@ -4,6 +4,23 @@
 # because bcm_bootsate resets /proc/bootstate/reset_reason
 START=13
 
+boot() {
+	local ret=0
+	# If the loader attempts to load a committed image with support_fallback / bcm_support_fallback
+	# enabled, the watchdog and bootstate driver are set to detect if a reboot occurs before
+	# the Linux userspace sets the "steadystate" as done below
+	set_steady_state || ret=$?
+	# If the image reboots prior to reaching steady state, the loader boots the non-committed image once.
+	#
+	# Ordinarily, the non-committed image then commits itself after having itself
+	# booted successfully (see set_bank_permanently function) as done below
+	set_bank_permanently || ret=$?
+	return $ret
+}
+
+set_steady_state() {
+	echo "steadystate" >/proc/bootstate/reset_reason
+}
 
 # Set bank temporarily booted by sysupgrade to boot permanently after
 # "successful" boot
@@ -50,9 +67,4 @@ set_bank_permanently() {
 		fi
 		echo "Permanently set boot bank to $booted_partition" | tee /dev/console
 	fi
-
-}
-
-boot() {
-	set_bank_permanently
 }
-- 
GitLab