From 3d17f794f087a626cbb0a8d7c77d2b86facc68c0 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Mon, 8 Apr 2024 19:22:55 +0300 Subject: [PATCH] base-files: add caldata_from_file_ubifs function On some devices, the caldata is provided in a file on ubifs. Add a function to extract it. Signed-off-by: Stijn Tintel --- .../base-files/files/lib/functions/caldata.sh | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh index f0fc907aef..2f9f804d77 100644 --- a/package/base-files/files/lib/functions/caldata.sh +++ b/package/base-files/files/lib/functions/caldata.sh @@ -91,6 +91,37 @@ caldata_from_file() { caldata_die "failed to extract calibration data from $source" } +caldata_from_file_ubifs() { + local ubipart=$1 + local ubivol=$2 + local source=$3 + local offset=$4 + local count=$(($5)) + local target=$6 + local dir="/tmp/caldata" + local ubi + local ubidev + + . /lib/upgrade/nand.sh + + [ -n "$target" ] || target=/lib/firmware/$FIRMWARE + + ubidev=$(nand_attach_ubi "$ubipart") + ubi=$(nand_find_volume "$ubidev" "$ubivol") + + [ -n "$ubi" ] || caldata_die "no UBI volume $ubivol found on $ubipart partition" + + mkdir -p "$dir" || caldata_die "failed to create temporary directory" + + grep -q "$dir" /proc/mounts || { + mount -t ubifs "${ubidev}:${ubivol}" "$dir" || caldata_die "failed to mount caldata ubifs" + } + + caldata_from_file "${dir}/${source}" "$offset" "$count" "$target" + + umount "$dir" +} + caldata_sysfsload_from_file() { local source=$1 local offset=$(($2)) -- 2.30.2