cd49c0da36ea62443d1367a403655ae1b08929dc
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 case "$(board_name)" in
27 mount
-t vfat
/dev
/sda1
/mnt
28 cp -af "$CONF_TAR" /mnt
/
41 mount
-t vfat
/dev
/$kernel /boot
43 [ -f /boot
/vmlinux
.64 -a ! -L /boot
/vmlinux
.64 ] && {
44 mv /boot
/vmlinux
.64 /boot
/vmlinux
.64.previous
45 mv /boot
/vmlinux
.64.md5
/boot
/vmlinux
.64.md5.previous
48 echo "flashing kernel to /dev/$kernel"
49 tar xf
$tar_file sysupgrade-
$board/kernel
-O > /boot
/vmlinux
.64
50 md5sum /boot
/vmlinux
.64 | cut
-f1 -d " " > /boot
/vmlinux
.64.md5
51 echo "flashing rootfs to ${rootfs}"
52 tar xf
$tar_file sysupgrade-
$board/root
-O |
dd of
="${rootfs}" bs
=4096
57 platform_do_upgrade
() {
59 local board
=$
(board_name
)
60 local rootfs
="$(platform_get_rootfs)"
63 [ -b "${rootfs}" ] ||
return 1
75 platform_do_flash
$tar_file $board $kernel $rootfs
81 platform_check_image
() {
82 local board
=$
(board_name
)
88 local kernel_length
=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
89 local rootfs_length
=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
90 [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
91 echo "The upgarde image is corrupt."
98 echo "Sysupgrade is not yet supported on $board."