mediatek: mt7622: fix sysupgrade on MMC on BPi-R64
[openwrt/openwrt.git] / target / linux / mediatek / mt7622 / base-files / lib / upgrade / platform.sh
1 REQUIRE_IMAGE_METADATA=1
2
3 platform_do_upgrade() {
4 local board=$(board_name)
5 local file_type=$(identify $1)
6
7 case "$board" in
8 bananapi,bpi-r64)
9 local rootdev="$(cmdline_get_var root)"
10 rootdev="${rootdev##*/}"
11 rootdev="${rootdev%p[0-9]*}"
12 case "$rootdev" in
13 mmc*)
14 CI_ROOTDEV="$rootdev"
15 CI_KERNPART="production"
16 emmc_do_upgrade "$1"
17 ;;
18 *)
19 CI_KERNPART="fit"
20 nand_do_upgrade "$1"
21 ;;
22 esac
23 ;;
24 buffalo,wsr-2533dhp2)
25 local magic="$(get_magic_long "$1")"
26
27 # use "mtd write" if the magic is "DHP2 (0x44485032)"
28 # or "DHP3 (0x44485033)"
29 if [ "$magic" = "44485032" -o "$magic" = "44485033" ]; then
30 buffalo_upgrade_ubinized "$1"
31 else
32 CI_KERNPART="firmware"
33 nand_do_upgrade "$1"
34 fi
35 ;;
36 elecom,wrc-x3200gst3|\
37 mediatek,mt7622-rfb1-ubi|\
38 totolink,a8000ru|\
39 xiaomi,redmi-router-ax6s)
40 nand_do_upgrade "$1"
41 ;;
42 linksys,e8450-ubi)
43 CI_KERNPART="fit"
44 nand_do_upgrade "$1"
45 ;;
46 linksys,e8450)
47 if grep -q mtdparts=slave /proc/cmdline; then
48 PART_NAME=firmware2
49 else
50 PART_NAME=firmware1
51 fi
52 default_do_upgrade "$1"
53 ;;
54 *)
55 default_do_upgrade "$1"
56 ;;
57 esac
58 }
59
60 PART_NAME=firmware
61
62 platform_check_image() {
63 local board=$(board_name)
64 local magic="$(get_magic_long "$1")"
65
66 [ "$#" -gt 1 ] && return 1
67
68 case "$board" in
69 buffalo,wsr-2533dhp2)
70 buffalo_check_image "$board" "$magic" "$1" || return 1
71 ;;
72 elecom,wrc-x3200gst3|\
73 mediatek,mt7622-rfb1-ubi|\
74 totolink,a8000ru|\
75 xiaomi,redmi-router-ax6s)
76 nand_do_platform_check "$board" "$1"
77 ;;
78 *)
79 [ "$magic" != "d00dfeed" ] && {
80 echo "Invalid image type."
81 return 1
82 }
83 return 0
84 ;;
85 esac
86
87 return 0
88 }
89
90 platform_copy_config() {
91 case "$(board_name)" in
92 bananapi,bpi-r64)
93 export_bootdevice
94 export_partdevice rootdev 0
95 if echo $rootdev | grep -q mmc; then
96 emmc_copy_config
97 fi
98 ;;
99 esac
100 }