From: Lukas Stockner Date: Sat, 2 May 2026 17:31:43 +0000 (+0200) Subject: base-files: support rootfs_data on its own partition X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf770bc4e3eb150b9496314992d8baed97067848;p=thirdparty%2Fopenwrt.git base-files: support rootfs_data on its own partition 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 Link: https://github.com/openwrt/openwrt/pull/20738 Signed-off-by: Paul Spooren --- diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh index 22f9cce42a5..e4a255b9c0e 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -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" - } diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index 8bd2084f6b5..80fbfb24c84 100644 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -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|\ diff --git a/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh index a30f4bc1e22..10078eec9a9 100755 --- a/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh +++ b/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh @@ -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|\ diff --git a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh index a5a4dc5bbb7..13ccc3986ec 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh @@ -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|\ diff --git a/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh b/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh index 9bece63345b..f4963e1b3ba 100644 --- a/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh +++ b/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh @@ -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)