]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
base-files: support rootfs_data on its own partition
authorLukas Stockner <lukas@lukasstockner.de>
Sat, 2 May 2026 17:31:43 +0000 (19:31 +0200)
committerTest Dev <dev@example.org>
Tue, 16 Jun 2026 11:45:44 +0000 (13:45 +0200)
The current code assumes that the rootfs_data UBI volume is on the same MTD
partition as the rootfs.
Unfortunately, this does not work on the Aruba AP-325 (and variants), since
the bootloader enforces a particular UBI volume layout.

Therefore, this adds a separate variable to set the rootfs_data partition,
and updates all existing devices with a non-default rootfs partition to also
specify the new variable.

Signed-off-by: Lukas Stockner <lukas@lukasstockner.de>
Link: https://github.com/openwrt/openwrt/pull/20738
Signed-off-by: Test Dev <dev@example.org>
package/base-files/files/lib/upgrade/nand.sh
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh
target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh

index 22f9cce42a5b79047effa2f66cc62200a0bb8766..e4a255b9c0ec53e75020c97b007e82d2491e1b5a 100644 (file)
@@ -7,8 +7,9 @@
 CI_KERNPART="${CI_KERNPART:-kernel}"
 
 # 'ubi' partition on NAND contains UBI
-# There are also CI_KERN_UBIPART and CI_ROOT_UBIPART if kernel
-# and rootfs are on separated UBIs.
+# If individual UBI volumes are on different partitions,
+# they can be set with CI_KERN_UBIPART, CI_ROOT_UBIPART and/or
+# CI_DATA_UBIPART.
 CI_UBIPART="${CI_UBIPART:-ubi}"
 
 # 'rootfs' UBI volume on NAND contains the rootfs
@@ -77,9 +78,10 @@ identify_if_gzip() {
 }
 
 nand_restore_config() {
-       local ubidev=$( nand_find_ubi "${CI_ROOT_UBIPART:-$CI_UBIPART}" )
+       local ubidev=$( nand_find_ubi "${CI_DATA_UBIPART:-$CI_UBIPART}" )
        local ubivol="$( nand_find_volume $ubidev rootfs_data )"
        if [ ! "$ubivol" ]; then
+               local ubidev=$( nand_find_ubi "${CI_ROOT_UBIPART:-$CI_UBIPART}" )
                ubivol="$( nand_find_volume $ubidev "$CI_ROOTPART" )"
                if [ ! "$ubivol" ]; then
                        echo "cannot find ubifs data volume"
@@ -188,23 +190,21 @@ nand_upgrade_prepare_ubi() {
        local has_env="${4:-0}"
        local kern_ubidev
        local root_ubidev
+       local data_ubidev
 
        [ -n "$rootfs_length" -o -n "$kernel_length" ] || return 1
 
-       if [ -n "$CI_KERN_UBIPART" -a -n "$CI_ROOT_UBIPART" ]; then
-               kern_ubidev="$( nand_attach_ubi "$CI_KERN_UBIPART" "$has_env" )"
-               [ -n "$kern_ubidev" ] || return 1
-               root_ubidev="$( nand_attach_ubi "$CI_ROOT_UBIPART" )"
-               [ -n "$root_ubidev" ] || return 1
-       else
-               kern_ubidev="$( nand_attach_ubi "$CI_UBIPART" "$has_env" )"
-               [ -n "$kern_ubidev" ] || return 1
-               root_ubidev="$kern_ubidev"
-       fi
+       # Attach UBI partitions (might be identical, but nand_attach_ubi handles that)
+       kern_ubidev="$( nand_attach_ubi "${CI_KERN_UBIPART:-$CI_UBIPART}" "$has_env" )"
+       [ -n "$kern_ubidev" ] || return 1
+       root_ubidev="$( nand_attach_ubi "${CI_ROOT_UBIPART:-$CI_UBIPART}" )"
+       [ -n "$root_ubidev" ] || return 1
+       data_ubidev="$( nand_attach_ubi "${CI_DATA_UBIPART:-$CI_UBIPART}" )"
+       [ -n "$data_ubidev" ] || return 1
 
        local kern_ubivol="$( nand_find_volume $kern_ubidev "$CI_KERNPART" )"
        local root_ubivol="$( nand_find_volume $root_ubidev "$CI_ROOTPART" )"
-       local data_ubivol="$( nand_find_volume $root_ubidev rootfs_data )"
+       local data_ubivol="$( nand_find_volume $data_ubidev rootfs_data )"
        [ "$root_ubivol" = "$kern_ubivol" ] && root_ubivol=
 
        # remove ubiblocks
@@ -215,7 +215,7 @@ nand_upgrade_prepare_ubi() {
        # kill volumes
        [ "$kern_ubivol" ] && ubirmvol /dev/$kern_ubidev -N "$CI_KERNPART" || :
        [ "$root_ubivol" ] && ubirmvol /dev/$root_ubidev -N "$CI_ROOTPART" || :
-       [ "$data_ubivol" ] && ubirmvol /dev/$root_ubidev -N rootfs_data || :
+       [ "$data_ubivol" ] && ubirmvol /dev/$data_ubidev -N rootfs_data || :
 
        # create provisioning vol
        if [ "${UPGRADE_OPT_ADD_PROVISIONING:-0}" -gt 0 ]; then
@@ -255,8 +255,8 @@ nand_upgrade_prepare_ubi() {
                if [ -n "$rootfs_data_max" ]; then
                        rootfs_data_size_param="-s $rootfs_data_max"
                fi
-               if ! ubimkvol /dev/$root_ubidev -N rootfs_data $rootfs_data_size_param; then
-                       if ! ubimkvol /dev/$root_ubidev -N rootfs_data -m; then
+               if ! ubimkvol /dev/$data_ubidev -N rootfs_data $rootfs_data_size_param; then
+                       if ! ubimkvol /dev/$data_ubidev -N rootfs_data -m; then
                                echo "cannot initialize rootfs_data volume"
                                return 1
                        fi
@@ -288,8 +288,8 @@ nand_upgrade_ubifs() {
 
        nand_upgrade_prepare_ubi "$ubifs_length" "ubifs" "" "" || return 1
 
-       local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
-       local root_ubivol="$(nand_find_volume $ubidev "$CI_ROOTPART")"
+       local root_ubidev="$( nand_find_ubi "${CI_ROOT_UBIPART:-$CI_UBIPART}" )"
+       local root_ubivol="$(nand_find_volume $root_ubidev "$CI_ROOTPART")"
        $cmd < "$ubifs_file" | ubiupdatevol /dev/$root_ubivol -s "$ubifs_length" -
 }
 
@@ -302,7 +302,7 @@ nand_upgrade_fit() {
 
        nand_upgrade_prepare_ubi "" "" "$fit_length" "1" || return 1
 
-       local fit_ubidev="$(nand_find_ubi "$CI_UBIPART")"
+       local fit_ubidev="$(nand_find_ubi "${CI_KERN_UBIPART:-$CI_UBIPART}")"
        local fit_ubivol="$(nand_find_volume $fit_ubidev "$CI_KERNPART")"
        $cmd < "$fit_file" | ubiupdatevol /dev/$fit_ubivol -s "$fit_length" -
 }
index 8bd2084f6b5a33056082c438de26a4fca6f17611..80fbfb24c84755ec715d831703aa3093bd3bdaa6 100644 (file)
@@ -228,6 +228,7 @@ platform_do_upgrade() {
        xiaomi,redmi-router-ax6000-stock)
                CI_KERN_UBIPART="ubi_kernel"
                CI_ROOT_UBIPART="ubi"
+               CI_DATA_UBIPART="ubi"
                nand_do_upgrade "$1"
                ;;
        buffalo,wsr-6000ax8|\
index a30f4bc1e22ca3ebc7ac1437d259e7fdb9473f7a..10078eec9a94730cf3a7c04072f108cef1fca0eb 100755 (executable)
@@ -29,6 +29,7 @@ platform_do_upgrade() {
                CI_KERNPART=boot
                CI_KERN_UBIPART=ubi_kernel
                CI_ROOT_UBIPART=ubi
+               CI_DATA_UBIPART=ubi
                nand_do_upgrade "$1"
                ;;
        buffalo,ls421de|\
index a5a4dc5bbb7d5bc25b8819101e64d6849893e5b5..13ccc3986ec8ca5fa02d047cc4b9925992e6f2e3 100644 (file)
@@ -229,6 +229,7 @@ platform_do_upgrade() {
                # Kernel and rootfs are placed in 2 different UBI
                CI_KERN_UBIPART="ubi_kernel"
                CI_ROOT_UBIPART="rootfs"
+               CI_DATA_UBIPART="rootfs"
                nand_do_upgrade "$1"
                ;;
        yuncore,ax830|\
index 9bece63345b8dc9850cdfa1c3e947bc476547e43..f4963e1b3bac8d41756848b0413fa1e2bd6b642c 100644 (file)
@@ -200,6 +200,7 @@ platform_do_upgrade() {
        buffalo,wxr-5950ax12)
                CI_KERN_UBIPART="rootfs"
                CI_ROOT_UBIPART="user_property"
+               CI_DATA_UBIPART="user_property"
                buffalo_upgrade_prepare
                nand_do_flash_file "$1" || nand_do_upgrade_failed
                nand_do_restore_config || nand_do_upgrade_failed
@@ -258,6 +259,7 @@ platform_do_upgrade() {
                # Kernel and rootfs are placed in 2 different UBI
                CI_KERN_UBIPART="ubi_kernel"
                CI_ROOT_UBIPART="rootfs"
+               CI_DATA_UBIPART="rootfs"
                nand_do_upgrade "$1"
                ;;
        spectrum,sax1v1k)
@@ -302,6 +304,7 @@ platform_do_upgrade() {
        zte,mf269)
                CI_KERN_UBIPART="ubi_kernel"
                CI_ROOT_UBIPART="rootfs"
+               CI_DATA_UBIPART="rootfs"
                nand_do_upgrade "$1"
                ;;
        zyxel,nbg7815)