aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/upgrade
diff options
context:
space:
mode:
authorINAGAKI Hiroshi <musashino.open@gmail.com>2019-01-01 09:15:34 +0900
committerChristian Lamparter <chunkeey@gmail.com>2019-01-01 16:38:20 +0100
commit7e9b93fb1b9d1f04df905b77d79ef8a182b2fb83 (patch)
treee6685deb40efde5b4185f8a75693864c12e0d88d /package/base-files/files/lib/upgrade
parent250f5ec1397b795e7bdf27dc616842f1ed5cf2ee (diff)
downloadupstream-7e9b93fb1b9d1f04df905b77d79ef8a182b2fb83.tar.gz
upstream-7e9b93fb1b9d1f04df905b77d79ef8a182b2fb83.tar.bz2
upstream-7e9b93fb1b9d1f04df905b77d79ef8a182b2fb83.zip
base-files: allow non-standard rootfs volume name in UBI in sysupgrade
This commit allows to use non-standard UBI volume name as the rootfs volume in sysupgrade. ex.: The U-Boot on Buffalo WXR-2533DHP checks existence and checksum of "ubi_rootfs" volume when booting, so this name is required. OpenWrt currently provides several patches: 490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch 491-ubi-auto-create-ubiblock-device-for-rootfs.patch 492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch to facilitate ubi rootfs automount. However the upstream kernel also supports the means of booting from a fully custom ubi partition name and ubi volume name via bootargs/kernel's cmdline parameters: ubi.mtd=mtd_partition_name ubi.block=rootfs_volume_name root=/dev/ubiblock$X_$Y For more information and examples visit the wiki over at linux-mtd: <http://www.linux-mtd.infradead.org/faq/ubifs.html> <http://www.linux-mtd.infradead.org/doc/ubi.html> Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com> Signed-off-by: Christian Lamparter <chunkeey@gmail.com> [reworded commit]
Diffstat (limited to 'package/base-files/files/lib/upgrade')
-rw-r--r--package/base-files/files/lib/upgrade/nand.sh15
1 files changed, 9 insertions, 6 deletions
diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
index 42f488c118..99916a4e96 100644
--- a/package/base-files/files/lib/upgrade/nand.sh
+++ b/package/base-files/files/lib/upgrade/nand.sh
@@ -10,6 +10,9 @@ CI_KERNPART="${CI_KERNPART:-kernel}"
# 'ubi' partition on NAND contains UBI
CI_UBIPART="${CI_UBIPART:-ubi}"
+# 'rootfs' partition on NAND contains the rootfs
+CI_ROOTPART="${CI_ROOTPART:-rootfs}"
+
ubi_mknod() {
local dir="$1"
local dev="/dev/$(basename $dir)"
@@ -99,7 +102,7 @@ nand_restore_config() {
local ubidev=$( nand_find_ubi $CI_UBIPART )
local ubivol="$( nand_find_volume $ubidev rootfs_data )"
[ ! "$ubivol" ] &&
- ubivol="$( nand_find_volume $ubidev rootfs )"
+ ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )"
mkdir /tmp/new_root
if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then
echo "mounting ubifs $ubivol failed"
@@ -143,7 +146,7 @@ nand_upgrade_prepare_ubi() {
fi
local kern_ubivol="$( nand_find_volume $ubidev $CI_KERNPART )"
- local root_ubivol="$( nand_find_volume $ubidev rootfs )"
+ local root_ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )"
local data_ubivol="$( nand_find_volume $ubidev rootfs_data )"
# remove ubiblock device of rootfs
@@ -158,7 +161,7 @@ nand_upgrade_prepare_ubi() {
# kill volumes
[ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_KERNPART || true
- [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs || true
+ [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_ROOTPART || true
[ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true
# update kernel
@@ -176,7 +179,7 @@ nand_upgrade_prepare_ubi() {
else
root_size_param="-s $rootfs_length"
fi
- if ! ubimkvol /dev/$ubidev -N rootfs $root_size_param; then
+ if ! ubimkvol /dev/$ubidev -N $CI_ROOTPART $root_size_param; then
echo "cannot create rootfs volume"
return 1;
fi
@@ -233,7 +236,7 @@ nand_upgrade_ubifs() {
nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0"
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
- local root_ubivol="$(nand_find_volume $ubidev rootfs)"
+ local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)"
ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1
nand_do_upgrade_success
@@ -268,7 +271,7 @@ nand_upgrade_tar() {
ubiupdatevol /dev/$kern_ubivol -s $kernel_length -
}
- local root_ubivol="$(nand_find_volume $ubidev rootfs)"
+ local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)"
tar xf $tar_file ${board_dir}/root -O | \
ubiupdatevol /dev/$root_ubivol -s $rootfs_length -