Initial commit
This commit is contained in:
Executable
+78
@@ -0,0 +1,78 @@
|
||||
From 88d810c49f7101a8bb46b2a1af17626bd61a5d07 Mon Sep 17 00:00:00 2001
|
||||
From: roly <Rolyli.Li@luxshare-ict.com>
|
||||
Date: Wed, 18 Dec 2024 13:55:03 +0800
|
||||
Subject: [PATCH] Detect boot image source
|
||||
|
||||
---
|
||||
detect-slot-aspeed | 21 +++++++++++++++++----
|
||||
reset-cs0-aspeed | 12 +++++++++++-
|
||||
2 files changed, 28 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/detect-slot-aspeed b/detect-slot-aspeed
|
||||
index 231eb33..6631722 100644
|
||||
--- a/detect-slot-aspeed
|
||||
+++ b/detect-slot-aspeed
|
||||
@@ -1,16 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
-# Check the /sys/class/watchdog/watchdog1/access_cs0 and tell if it's running on the primary or the secondary flash.
|
||||
-
|
||||
-ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
|
||||
SLOT_FILE="/run/media/slot"
|
||||
|
||||
+if [ -f ${SLOT_FILE} ]; then
|
||||
+ # Slot info already detected
|
||||
+ exit 0
|
||||
+fi
|
||||
+
|
||||
+# Check the sysfs attribute and tell if it's running on the primary or the secondary flash.
|
||||
+SOC_FAMILY=$(cat /sys/bus/soc/devices/soc0/family)
|
||||
+if [ "${SOC_FAMILY}" = "AST2500" ]; then
|
||||
+ ACCESS_PRIMARY="/sys/class/watchdog/watchdog1/access_cs0"
|
||||
+elif [ "${SOC_FAMILY}" = "AST2600" ]; then
|
||||
+ ACCESS_PRIMARY="/sys/devices/platform/ahb/1e620000.spi/access_primary"
|
||||
+else
|
||||
+ echo "SOC Family is neither AST2500 nor AST2600"
|
||||
+ exit 1
|
||||
+fi
|
||||
+
|
||||
# Create directory if not exist
|
||||
mkdir -p "$(dirname "${SLOT_FILE}")"
|
||||
|
||||
# Write slot info
|
||||
-if [ -f ${ACCESS_CS0} ]; then
|
||||
+if [ -f ${ACCESS_PRIMARY} ]; then
|
||||
echo "1" > ${SLOT_FILE}
|
||||
else
|
||||
echo "0" > ${SLOT_FILE}
|
||||
diff --git a/reset-cs0-aspeed b/reset-cs0-aspeed
|
||||
index e2cf1e0..e761e77 100644
|
||||
--- a/reset-cs0-aspeed
|
||||
+++ b/reset-cs0-aspeed
|
||||
@@ -11,11 +11,21 @@ SHUTDOWN_EXTRA_SCRIPT="/run/initramfs/shutdown_task_after_umount"
|
||||
|
||||
cat <<'EOF' >"${SHUTDOWN_EXTRA_SCRIPT}"
|
||||
#!/bin/sh
|
||||
-ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
|
||||
+
|
||||
+ACCESS_CS0=""
|
||||
+
|
||||
+SOC_FAMILY=$(cat /sys/bus/soc/devices/soc0/family)
|
||||
+if [ "${SOC_FAMILY}" = "AST2500" ]; then
|
||||
+ ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
|
||||
+elif [ "${SOC_FAMILY}" = "AST2600" ]; then
|
||||
+ ACCESS_CS0="/sys/devices/platform/ahb/1e620000.spi/access_primary"
|
||||
+fi
|
||||
+
|
||||
if [ -f "${ACCESS_CS0}" ]; then
|
||||
echo "Reset aspeed chip select"
|
||||
echo 1 > "${ACCESS_CS0}"
|
||||
fi
|
||||
+
|
||||
EOF
|
||||
chmod +x "${SHUTDOWN_EXTRA_SCRIPT}"
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user