bcm63xx: add NETGEAR DGND3700v2 support
[openwrt/openwrt.git] / target / linux / bcm63xx / base-files / lib / upgrade / platform.sh
1 PART_NAME=linux
2 REQUIRE_IMAGE_METADATA=0
3
4 platform_check_image() {
5 [ "$#" -gt 1 ] && return 1
6
7 case "$(board_name)" in
8 comtrend,vr-3032u|\
9 netgear,dgnd3700-v2)
10 # NAND sysupgrade
11 return 0
12 ;;
13 esac
14
15 case "$(get_magic_word "$1")" in
16 3600|3700|3800)
17 # CFE tag versions
18 return 0
19 ;;
20 *)
21 echo "Invalid image type. Please use only .bin files"
22 return 1
23 ;;
24 esac
25 }
26
27 cfe_jffs2_upgrade_tar() {
28 local tar_file="$1"
29 local kernel_mtd="$(find_mtd_index $CI_KERNPART)"
30
31 if [ -z "$kernel_mtd" ]; then
32 echo "$CI_KERNPART partition not found"
33 return 1
34 fi
35
36 local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
37 board_dir=${board_dir%/}
38
39 local kernel_length=$(tar xf $tar_file ${board_dir}/kernel -O | wc -c 2> /dev/null)
40 local rootfs_length=$(tar xf $tar_file ${board_dir}/root -O | wc -c 2> /dev/null)
41
42 if [ "$kernel_length" = 0 ]; then
43 echo "kernel cannot be empty"
44 return 1
45 fi
46
47 flash_erase -j /dev/mtd${kernel_mtd} 0 0
48 tar xf $tar_file ${board_dir}/kernel -O | nandwrite /dev/mtd${kernel_mtd} -
49
50 local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)"
51
52 nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "0" "0"
53
54 local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
55
56 local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)"
57 tar xf $tar_file ${board_dir}/root -O | \
58 ubiupdatevol /dev/$root_ubivol -s $rootfs_length -
59
60 nand_do_upgrade_success
61 }
62
63 platform_do_upgrade() {
64 case "$(board_name)" in
65 comtrend,vr-3032u|\
66 netgear,dgnd3700-v2)
67 REQUIRE_IMAGE_METADATA=1
68 cfe_jffs2_upgrade_tar "$1"
69 ;;
70 *)
71 default_do_upgrade "$1"
72 ;;
73 esac
74 }