2 # Copyright (C) 2011 OpenWrt.org
8 (get_image
"$1" |
dd bs
=4 count
=1 skip
="$2" |
hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev
/null
14 part
=$
(find_mtd_part u-boot
)
15 [ -z "$part" ] && return 1
17 dd if=$part bs
=4 count
=1 skip
=81728 2>/dev
/null |
hexdump -v -n 4 -e '1/1 "%02x"'
20 tplink_get_image_hwid
() {
21 get_image
"$@" |
dd bs
=4 count
=1 skip
=16 2>/dev
/null |
hexdump -v -n 4 -e '1/1 "%02x"'
24 tplink_get_image_boot_size
() {
25 get_image
"$@" |
dd bs
=4 count
=1 skip
=37 2>/dev
/null |
hexdump -v -n 4 -e '1/1 "%02x"'
28 platform_check_image
() {
29 local board
=$
(board_name
)
30 local magic
="$(get_magic_long "$1")"
32 [ "$#" -gt 1 ] && return 1
36 local init_magic
=$
(get_magic_long_at
"$1" "65536")
37 local root_magic
=$
(get_magic_long_at
"$1" "131072")
38 local kernel_magic
=$
(get_magic_long_at
"$1" "10551296")
40 [ "$magic" != "d00dfeed" ] && {
41 echo "Invalid dtb image type."
44 [ "$init_magic" != "27051956" ] && {
45 echo "Invalid initramfs image type."
48 [ "$root_magic" != "68737173" ] && {
49 echo "Invalid rootfs image type."
52 [ "$kernel_magic" != "27051956" ] && {
53 echo "Invalid kernel image type."
59 [ "$magic" != "01000000" ] && {
60 echo "Invalid image type."
67 hwid
=$
(tplink_get_hwid
)
68 imageid
=$
(tplink_get_image_hwid
"$1")
70 [ "$hwid" != "$imageid" ] && {
71 echo "Invalid image, hardware ID mismatch, hw:$hwid image:$imageid."
77 boot_size
=$
(tplink_get_image_boot_size
"$1")
78 [ "$boot_size" != "00000000" ] && {
79 echo "Invalid image, it contains a bootloader."
87 echo "Sysupgrade is not yet supported on $board."
91 platform_do_upgrade
() {
92 local board
=$
(board_name
)
96 default_do_upgrade
"$ARGV"
103 ( ps |
grep -v 'grep' |
grep '/dev/watchdog' ) && {
104 echo 'Could not disable watchdog'
109 append sysupgrade_pre_upgrade disable_watchdog