2 # Copyright (C) 2014 OpenWrt.org
5 platform_get_rootfs
() {
8 if read cmdline
< /proc
/cmdline
; then
11 rootfsdev
="${cmdline##*root=}"
12 rootfsdev
="${rootfsdev%% *}"
20 platform_copy_config
() {
21 case "$(board_name)" in
23 mount
-t vfat
/dev
/sda1
/mnt
24 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
28 mount
-t vfat
/dev
/mmcblk1p1
/mnt
29 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
33 mount
-t vfat
/dev
/mmcblk0p1
/mnt
34 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
46 local board_dir
=$
(tar tf
"$tar_file" |
grep -m 1 '^sysupgrade-.*/$')
47 board_dir
=${board_dir%/}
48 [ -n "$board_dir" ] ||
return 1
52 if [ $board = "itus,shield-router" ]; then
53 # mmcblk1p1 (fat) contains all ELF-bin images for the Shield
54 mount
/dev
/mmcblk1p1
/boot
56 echo "flashing Itus Kernel to /boot/$kernel (/dev/mmblk1p1)"
57 tar -Oxf $tar_file "$board_dir/kernel" > /boot
/$kernel
59 mount
-t vfat
/dev
/$kernel /boot
61 [ -f /boot
/vmlinux
.64 -a ! -L /boot
/vmlinux
.64 ] && {
62 mv /boot
/vmlinux
.64 /boot
/vmlinux
.64.previous
63 mv /boot
/vmlinux
.64.md5
/boot
/vmlinux
.64.md5.previous
66 echo "flashing kernel to /dev/$kernel"
67 tar xf
$tar_file $board_dir/kernel
-O > /boot
/vmlinux
.64
68 md5sum /boot
/vmlinux
.64 | cut
-f1 -d " " > /boot
/vmlinux
.64.md5
71 echo "flashing rootfs to ${rootfs}"
72 tar xf
$tar_file $board_dir/root
-O |
dd of
="${rootfs}" bs
=4096
78 platform_do_upgrade
() {
80 local board
=$
(board_name
)
81 local rootfs
="$(platform_get_rootfs)"
84 [ -b "${rootfs}" ] ||
return 1
94 kernel
=ItusrouterImage
100 platform_do_flash
$tar_file $board $kernel $rootfs
105 platform_check_image
() {
106 local board
=$
(board_name
)
109 local board_dir
=$
(tar tf
"$tar_file" |
grep -m 1 '^sysupgrade-.*/$')
110 board_dir
=${board_dir%/}
111 [ -n "$board_dir" ] ||
return 1
116 itus
,shield-router | \
118 local kernel_length
=$
(tar xf
$tar_file $board_dir/kernel
-O |
wc -c 2> /dev
/null
)
119 local rootfs_length
=$
(tar xf
$tar_file $board_dir/root
-O |
wc -c 2> /dev
/null
)
120 [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
121 echo "The upgrade image is corrupt."
128 echo "Sysupgrade is not yet supported on $board."