bootmode-fota: Load the modules when it's fota mode 81/319981/2 accepted/tizen/unified/20241108.064656 accepted/tizen/unified/x/20241218.032428 accepted/tizen/unified/x/asan/20241224.004146
authorJaehoon Chung <jh80.chung@samsung.com>
Wed, 6 Nov 2024 04:30:03 +0000 (13:30 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Wed, 6 Nov 2024 08:43:54 +0000 (17:43 +0900)
dm-bow was separated to module instead of builtin kernel drvier.
fota mode needs to create checkpoint with dm-bow.
Otherwise error will be occurred.
To avoid unexpected behavior, load the modules in initrd.

[Error] Failure to create checkpoint for /dev/mmcblk0p3

Change-Id: I723b5b585a3fd44a5a15013584fc1f20c23a1c0d
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
src/bootmode-fota/40-fota.list.in
src/bootmode-fota/fota-init.sh

index 8ad567b58e1b83b28397ecd0d0e8196c2c8a813a..68bb00d8649b91ae4f32b10260c017ec867ace41 100644 (file)
@@ -1,4 +1,7 @@
 # ---- Target contents ----------------------------------------------------- #
+DIRECTORIES="
+/usr/lib/modules
+"
 MVWITHLIBS="
 @INITRD_RECOVERY_LIBEXEC_DIR@/minireboot
 "
@@ -37,10 +40,12 @@ WITHLIBS="
 /usr/bin/readlink
 /usr/bin/tail
 /usr/bin/stat
+/usr/bin/xargs
 /usr/sbin/dmsetup
 /usr/sbin/bow-restore
 /usr/sbin/fstrim
 /usr/sbin/parse-dynparts
+/usr/sbin/modprobe
 "
 
 # LinkFileName:Target
index 038a6345c20f0b2dc973f5b7ca428a917a28a1e0..ef8200237bb2207c879913b0c647819b9177ff84 100755 (executable)
@@ -5,6 +5,7 @@ WITH_USR_PART=
 
 FAKE_ROOT=/run/upgrade-sysroot
 HAL_MNT=hal
+MODULES_INITRD_MNT=/usr/lib/modules
 
 SYNC="/bin/sync"
 REBOOT="/sbin/reboot"
@@ -17,6 +18,7 @@ MOUNT="/bin/mount"
 GREP="/bin/grep"
 BLKID="/usr/sbin/blkid"
 
+
 #------------------------------------------------
 #      do_reboot
 #------------------------------------------------
@@ -73,6 +75,15 @@ get_partition_id() {
         PART_HAL=`/sbin/blkid -L hal`
     fi
 
+    if [ x$MODULFS = "x" ]
+    then
+        PART_MODULES=`/sbin/blkid -t PARTLABEL=module${P_SUFFIX} -o device -l`
+    fi
+    if [ x$PART_MODULES = "x" ]
+    then
+        PART_MODULES=`/sbin/blkid -L modules`
+    fi
+
     PART_USER=$("$BLKID" --match-token PARTLABEL=user -o device -l || "$BLKID" --match-token LABEL=user -o device -l)
 
     return 0
@@ -144,6 +155,45 @@ function mount_datafs()
     return 0
 }
 
+load_kernel_modules()
+{
+    echo "Load kernel modules"
+
+    for conf in $(compgen -G $MODULES_INITRD_MNT"/modules-load.d/*.conf")
+    do
+        echo "Read module conf: $conf"
+        while read module
+        do
+            module=$(echo "$module" | /bin/xargs)            # trim white space
+            if [ "$module" = "" ]; then continue; fi         # skip blank line
+            if [ "${module:0:1}" = "#" ]; then continue; fi  # skip # commented line
+
+            echo "Loading module: $module"
+            /sbin/modprobe $module &
+        done < $conf
+    done
+
+    wait # wait all background jobs
+}
+
+#------------------------------------------------
+#       mount_modulesfs
+#------------------------------------------------
+mount_modules()
+{
+    if [ "z${PART_MODULES}" = "z" ]; then
+        # No modules partition
+        return 2
+    fi
+
+    if ! "$MOUNT" -o ro "${PART_MODULES}" "${MODULES_INITRD_MNT}"; then
+           return 1
+    fi
+
+    load_kernel_modules
+    return 0
+}
+
 #------------------------------------------------
 #       mount_partitions
 #------------------------------------------------
@@ -151,6 +201,7 @@ mount_partitions() {
     get_partition_id &&
     mount_rootfs &&
     mount_hal &&
+    mount_modules &&
     "$MOUNT" -t proc none ${FAKE_ROOT}/proc &&
     "$MOUNT" -t sysfs none ${FAKE_ROOT}/sys &&
     "$MOUNT" -t devtmpfs devtmpfs ${FAKE_ROOT}/dev &&