X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=target%2Flinux%2Focteon%2Fbase-files%2Flib%2Fupgrade%2Fplatform.sh;h=0e4ca3762982368e5c53d5b8e1559cf154741a21;hb=4bd9d331e5854e8325fd3b7a5f14e355a6a3c66d;hp=11399a2629ec09b8d11742c8261caf7f03696f85;hpb=28a9d9853bdfc01735eefe3588bb7f63a8d6c8db;p=openwrt%2Fstaging%2Flynxis.git diff --git a/target/linux/octeon/base-files/lib/upgrade/platform.sh b/target/linux/octeon/base-files/lib/upgrade/platform.sh index 11399a2629..0e4ca37629 100755 --- a/target/linux/octeon/base-files/lib/upgrade/platform.sh +++ b/target/linux/octeon/base-files/lib/upgrade/platform.sh @@ -2,8 +2,6 @@ # Copyright (C) 2014 OpenWrt.org # -. /lib/functions/octeon.sh - platform_get_rootfs() { local rootfsdev @@ -23,48 +21,74 @@ platform_get_rootfs() { fi } +platform_copy_config() { + case "$(board_name)" in + erlite) + mount -t vfat /dev/sda1 /mnt + cp -af "$CONF_TAR" /mnt/ + umount /mnt + ;; + esac +} + +platform_do_flash() { + local tar_file=$1 + local board=$2 + local kernel=$3 + local rootfs=$4 + + mkdir -p /boot + mount -t vfat /dev/$kernel /boot + + [ -f /boot/vmlinux.64 -a ! -L /boot/vmlinux.64 ] && { + mv /boot/vmlinux.64 /boot/vmlinux.64.previous + mv /boot/vmlinux.64.md5 /boot/vmlinux.64.md5.previous + } + + echo "flashing kernel to /dev/$kernel" + tar xf $tar_file sysupgrade-$board/kernel -O > /boot/vmlinux.64 + md5sum /boot/vmlinux.64 | cut -f1 -d " " > /boot/vmlinux.64.md5 + echo "flashing rootfs to ${rootfs}" + tar xf $tar_file sysupgrade-$board/root -O | dd of="${rootfs}" bs=4096 + sync + umount /boot +} + platform_do_upgrade() { - local board=$(octeon_board_name) + local tar_file="$1" + local board=$(board_name) local rootfs="$(platform_get_rootfs)" + local kernel= - [ -d "${rootfs}" ] || return 1 - + [ -b "${rootfs}" ] || return 1 case "$board" in + er) + kernel=mmcblk0p1 + ;; erlite) - local tar_file="$1" - local kernel_length=`(tar xf $tar_file sysupgrade-erlite/kernel -O | wc -c) 2> /dev/null` - local rootfs_length=`(tar xf $tar_file sysupgrade-erlite/root -O | wc -c) 2> /dev/null` - - [ -f /boot/vmlinux.64 -a ! -L /boot/vmlinux.64 ] && { - mv /boot/vmlinux.64 /boot/vmlinux.64.previous - mv /boot/vmlinux.64.md5 /boot/vmlinux.64.md5.previous - } - - mkdir -p /boot - mount -t vfat /dev/sda1 /boot - tar xf $tar_file sysupgrade-erlite/kernel -O > /boot/vmlinux.64 - md5sum /boot/vmlinux.64 | cut -f1 -d " " > /boot/vmlinux.64.md5 - tar xf $tar_file sysupgrade-erlite/root -O | dd of="${rootfs}" bs=4096 - sync - umount /mnt - return 0 + kernel=sda1 ;; + *) + return 1 esac - return 1 + platform_do_flash $tar_file $board $kernel $rootfs + + return 0 } platform_check_image() { - local board=$(octeon_board_name) + local board=$(board_name) case "$board" in + er | \ erlite) local tar_file="$1" - local kernel_length=`(tar xf $tar_file sysupgrade-erlite/kernel -O | wc -c) 2> /dev/null` - local rootfs_length=`(tar xf $tar_file sysupgrade-erlite/root -O | wc -c) 2> /dev/null` + local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null` + local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null` [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && { - echo "The upgarde image is corrupt." + echo "The upgrade image is corrupt." return 1 } return 0