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