base-files: recognize bootdevice on devices using fitblk

This commit is contained in:
coolsnowwolf 2024-07-02 13:14:41 +08:00
parent ea86509cd1
commit 319b46b4bd
3 changed files with 20 additions and 1 deletions

View File

@ -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,6 +213,7 @@ export_bootdevice() {
done
;;
/dev/*)
[ "$rootpart" = "/dev/fit0" ] && rootpart="$(fitblk_get_bootdev)"
uevent="/sys/class/block/${rootpart##*/}/../uevent"
;;
0x[a-f0-9][a-f0-9][a-f0-9] | 0x[a-f0-9][a-f0-9][a-f0-9][a-f0-9] | \

View File

@ -20,6 +20,7 @@ CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=
PKG_USE_MIPS16:=0
PKG_BUILD_FLAGS:=no-mips16
PKG_FLAGS:=nonshared

View File

@ -13,7 +13,7 @@ KERNEL_TESTING_PATCHVER:=6.6
include $(INCLUDE_DIR)/target.mk
DEFAULT_PACKAGES += \
kmod-leds-gpio kmod-gpio-button-hotplug \
kmod-leds-gpio kmod-gpio-button-hotplug fitblk \
autocore-arm htop wpad-openssl uboot-envtools
$(eval $(call BuildTarget))