mediatek: split base-files into subtargets
[openwrt/staging/chunkeey.git] / target / linux / mediatek / mt7623 / base-files / lib / upgrade / platform.sh
1 platform_do_upgrade() {
2 local board=$(board_name)
3
4 case "$board" in
5 unielec,u7623-02-emmc-512m)
6 #Keep the persisten random mac address (if it exists)
7 mkdir -p /tmp/recovery
8 mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
9 [ -f "/tmp/recovery/mac_addr" ] && \
10 mv -f /tmp/recovery/mac_addr /tmp/
11 umount /tmp/recovery
12
13 #1310720 is the offset in bytes from the start of eMMC and to
14 #the location of the kernel (2560 512 byte sectors)
15 get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync
16
17 mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery
18 [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery
19 sync
20 umount /tmp/recovery
21 ;;
22 *)
23 default_do_upgrade "$1"
24 ;;
25 esac
26 }
27
28 PART_NAME=firmware
29
30 platform_check_image() {
31 local board=$(board_name)
32 local magic="$(get_magic_long "$1")"
33
34 [ "$#" -gt 1 ] && return 1
35
36 case "$board" in
37 bananapi,bpi-r2|\
38 unielec,u7623-02-emmc-512m)
39 [ "$magic" != "27051956" ] && {
40 echo "Invalid image type."
41 return 1
42 }
43 return 0
44 ;;
45 *)
46 echo "Sysupgrade is not supported on your board yet."
47 return 1
48 ;;
49 esac
50
51 return 0
52 }
53
54 platform_copy_config_emmc() {
55 mkdir -p /recovery
56 mount -o rw,noatime /dev/mmcblk0p1 /recovery
57 cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE"
58 sync
59 umount /recovery
60 }
61
62 platform_copy_config() {
63 case "$(board_name)" in
64 unielec,u7623-02-emmc-512m)
65 platform_copy_config_emmc
66 ;;
67 esac
68 }