target: add pistachio
[openwrt/staging/lynxis/omap.git] / target / linux / pistachio / base-files / lib / upgrade / platform.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2017 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 . /lib/pistachio.sh
10
11 RAMFS_COPY_BIN="/usr/sbin/fw_printenv /usr/sbin/fw_setenv /bin/mkdir /bin/dmesg /bin/sed /bin/grep"
12 RAMFS_COPY_DATA="/etc/fw_env.config"
13 REQUIRE_IMAGE_METADATA=0
14
15 platform_check_image()
16 {
17 local board=$(pistachio_board_name)
18
19 nand_do_platform_check $board $1
20 return $?
21 }
22
23 platform_pre_upgrade() {
24 # TODO no need to switch to ramfs with dual partitions in
25 # fact we don't even want to reboot as part of seamless
26 # upgrades. Instead just upgrade opposite partition and mark
27 # the next reboot to boot from that partition. Could just call
28 # stage2 directly but need to refactor nand_upgrade_success
29 # for this to work.
30 # Also the nand functions don't allow url to be used
31 nand_do_upgrade $1
32 }
33
34 platform_nand_pre_upgrade() {
35 local board=$(pistachio_board_name)
36
37 case "$board" in
38 marduk)
39 local boot_partition=$(dmesg | grep "ubi0: attached.*" | sed "s/^.*\(firmware[0-1]\).*/\1/g")
40
41 echo "Current boot partiton $boot_partition (/dev/mtd$(find_mtd_index $boot_partition))"
42 mkdir -p /var/lock
43 if [ "$boot_partition" == "firmware0" ]; then
44 CI_UBIPART="firmware1"
45 fw_setenv boot_partition 1 || exit 1
46 else
47 CI_UBIPART="firmware0"
48 fw_setenv boot_partition 0 || exit 1
49 fi
50 echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))"
51 ;;
52 esac
53 }
54
55 blink_led() {
56 . /etc/diag.sh; set_state upgrade
57 }
58 append sysupgrade_pre_upgrade blink_led