summaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2024-02-25 21:01:01 +0000
committerDaniel Golle <daniel@makrotopia.org>2024-02-26 01:29:22 +0000
commit5992f976b39a0a0a79e5b9656279186cd471e353 (patch)
tree3d34fe57fc5a9f94810b3b4d5d19c3c1594887e3 /package/base-files
parent0acf0bc2043e56dc90df3b61192cd312b6cf8fdd (diff)
downloadopenwrt-5992f976b39a0a0a79e5b9656279186cd471e353.tar.gz
openwrt-5992f976b39a0a0a79e5b9656279186cd471e353.tar.bz2
openwrt-5992f976b39a0a0a79e5b9656279186cd471e353.zip
base-files: recognize bootdevice on devices using fitblk
Boards using the fitblk driver need special treatment when it comes to detecting the actual block device used to store the image used to boot from. Transparently handle this in 'export_bootdevice' and provide new 'fitblk_get_bootdev' function to replace implementations in /lib/upgrade/platform.sh. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/files/lib/upgrade/common.sh23
1 files changed, 22 insertions, 1 deletions
diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index af1182cb16..7e83379082 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -165,6 +165,23 @@ part_magic_fat() {
[ "$magic" = "FAT" ] || [ "$magic_fat32" = "FAT32" ]
}
+fitblk_get_bootdev() {
+ [ -e /sys/firmware/devicetree/base/chosen/rootdisk ] || return
+
+ local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)"
+ local handle bootdev
+ for handle in /sys/class/block/*/of_node/phandle /sys/class/block/*/device/of_node/phandle; do
+ [ ! -e "$handle" ] && continue
+ if [ "$rootdisk" = "$(cat $handle)" ]; then
+ bootdev="${handle%/of_node/phandle}"
+ bootdev="${bootdev%/device}"
+ bootdev="${bootdev#/sys/class/block/}"
+ echo "$bootdev"
+ break
+ fi
+ done
+}
+
export_bootdevice() {
local cmdline uuid blockdev uevent line class
local MAJOR MINOR DEVNAME DEVTYPE
@@ -196,7 +213,11 @@ export_bootdevice() {
done
;;
/dev/*)
- uevent="/sys/class/block/${rootpart##*/}/../uevent"
+ if [ "$rootpart" = "/dev/fit0" ]; then
+ uevent="/sys/class/block/$(fitblk_get_bootdev)/uevent"
+ else
+ uevent="/sys/class/block/${rootpart##*/}/../uevent"
+ fi
;;
0x[a-f0-9][a-f0-9][a-f0-9] | 0x[a-f0-9][a-f0-9][a-f0-9][a-f0-9] | \
[a-f0-9][a-f0-9][a-f0-9] | [a-f0-9][a-f0-9][a-f0-9][a-f0-9])