2 # Copyright (C) 2014 OpenWrt.org
5 platform_get_rootfs() {
8 if read cmdline < /proc/cmdline; then
11 rootfsdev="${cmdline##*block2mtd=}"
12 rootfsdev="${rootfsdev%%,*}"
15 rootfsdev="${cmdline##*root=}"
16 rootfsdev="${rootfsdev%% *}"
24 platform_copy_config() {
25 local board="$(cat /tmp/sysinfo/board_name)"
29 mount -t vfat /dev/sda1 /mnt
30 cp -af "$CONF_TAR" /mnt/
43 mount -t vfat /dev/$kernel /boot
45 [ -f /boot/vmlinux.64 -a ! -L /boot/vmlinux.64 ] && {
46 mv /boot/vmlinux.64 /boot/vmlinux.64.previous
47 mv /boot/vmlinux.64.md5 /boot/vmlinux.64.md5.previous
50 echo "flashing kernel to /dev/$kernel"
51 tar xf $tar_file sysupgrade-$board/kernel -O > /boot/vmlinux.64
52 md5sum /boot/vmlinux.64 | cut -f1 -d " " > /boot/vmlinux.64.md5
53 echo "flashing rootfs to ${rootfs}"
54 tar xf $tar_file sysupgrade-$board/root -O | dd of="${rootfs}" bs=4096
59 platform_do_upgrade() {
61 local board=$(cat /tmp/sysinfo/board_name)
62 local rootfs="$(platform_get_rootfs)"
65 [ -b "${rootfs}" ] || return 1
77 platform_do_flash $tar_file $board $kernel $rootfs
83 platform_check_image() {
84 local board=$(cat /tmp/sysinfo/board_name)
90 local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
91 local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
92 [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
93 echo "The upgarde image is corrupt."
100 echo "Sysupgrade is not yet supported on $board."