-nand_restore_config() {
- sync
- local ubidev=$( nand_find_ubi $CI_UBIPART )
- local ubivol="$( nand_find_volume $ubidev rootfs_data )"
- [ ! "$ubivol" ] &&
- ubivol="$( nand_find_volume $ubidev rootfs )"
- mkdir /tmp/new_root
- if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then
- echo "mounting ubifs $ubivol failed"
- rmdir /tmp/new_root
- return 1
- fi
- mv "$1" "/tmp/new_root/sysupgrade.tgz"
- umount /tmp/new_root
- sync
- rmdir /tmp/new_root
-}
-
-nand_upgrade_ubinized() {
- local upgrade_image="$1"
- local conf_tar="$2"
- local save_config="$3"
- local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
- if [ ! "$mtdnum" ]; then
- echo "cannot find mtd device $CI_UBIPART"
- return 1;
- fi
- local mtddev="/dev/mtd${mtdnum}"
- ubidetach -p "${mtddev}" || true
- sync
- ubiformat "${mtddev}" -y -f "$upgrade_image"
- ubiattach -p "${mtddev}"
- sync
- if [ -f "$conf_tar" -a "$save_config" -eq 1 ]; then
- nand_restore_config "$conf_tar"
- fi
- return 0;