aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mvebu/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/mvebu/base-files')
-rw-r--r--target/linux/mvebu/base-files/etc/crontabs/root1
-rw-r--r--target/linux/mvebu/base-files/etc/diag.sh32
-rwxr-xr-xtarget/linux/mvebu/base-files/etc/init.d/linksys_recovery20
-rw-r--r--target/linux/mvebu/base-files/etc/uci-defaults/01_leds37
-rw-r--r--target/linux/mvebu/base-files/etc/uci-defaults/02_network46
-rw-r--r--target/linux/mvebu/base-files/etc/uci-defaults/03_wireless39
-rwxr-xr-xtarget/linux/mvebu/base-files/lib/mvebu.sh73
-rw-r--r--target/linux/mvebu/base-files/lib/preinit/06_set_iface_mac26
-rw-r--r--target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg36
-rw-r--r--target/linux/mvebu/base-files/lib/upgrade/linksys.sh86
-rwxr-xr-xtarget/linux/mvebu/base-files/lib/upgrade/platform.sh50
-rwxr-xr-xtarget/linux/mvebu/base-files/sbin/fan_ctrl.sh28
12 files changed, 474 insertions, 0 deletions
diff --git a/target/linux/mvebu/base-files/etc/crontabs/root b/target/linux/mvebu/base-files/etc/crontabs/root
new file mode 100644
index 0000000..e692f57
--- /dev/null
+++ b/target/linux/mvebu/base-files/etc/crontabs/root
@@ -0,0 +1 @@
+*/5 * * * * /sbin/fan_ctrl.sh
diff --git a/target/linux/mvebu/base-files/etc/diag.sh b/target/linux/mvebu/base-files/etc/diag.sh
new file mode 100644
index 0000000..6534ac3
--- /dev/null
+++ b/target/linux/mvebu/base-files/etc/diag.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Copyright (C) 2014 OpenWrt.org
+
+. /lib/functions/leds.sh
+. /lib/mvebu.sh
+
+get_status_led() {
+ case $(mvebu_board_name) in
+ armada-xp-linksys-mamba)
+ status_led="mamba:white:power"
+ ;;
+ esac
+}
+
+set_state() {
+ get_status_led
+
+ case "$1" in
+ preinit)
+ status_led_blink_preinit
+ ;;
+ failsafe)
+ status_led_blink_failsafe
+ ;;
+ preinit_regular)
+ status_led_blink_preinit_regular
+ ;;
+ done)
+ status_led_on
+ ;;
+ esac
+}
diff --git a/target/linux/mvebu/base-files/etc/init.d/linksys_recovery b/target/linux/mvebu/base-files/etc/init.d/linksys_recovery
new file mode 100755
index 0000000..d9cae7b
--- /dev/null
+++ b/target/linux/mvebu/base-files/etc/init.d/linksys_recovery
@@ -0,0 +1,20 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2015 OpenWrt.org
+
+START=97
+boot() {
+. /lib/functions.sh
+. /lib/mvebu.sh
+
+case $(mvebu_board_name) in
+ armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba)
+ # make sure auto_recovery in uboot is always on
+ AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`"
+ if [ "$AUTO_RECOVERY_ENA" != "yes" ] ; then
+ fw_setenv auto_recovery yes
+ fi
+ # reset the boot counter
+ mtd resetbc s_env
+ ;;
+esac
+}
diff --git a/target/linux/mvebu/base-files/etc/uci-defaults/01_leds b/target/linux/mvebu/base-files/etc/uci-defaults/01_leds
new file mode 100644
index 0000000..612f949
--- /dev/null
+++ b/target/linux/mvebu/base-files/etc/uci-defaults/01_leds
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+
+. /lib/functions/uci-defaults.sh
+. /lib/mvebu.sh
+
+board=$(mvebu_board_name)
+
+case "$board" in
+armada-385-linksys-caiman)
+ ucidef_set_led_netdev "wan" "WAN" "pca963x:caiman:white:wan" "eth0"
+ ucidef_set_led_usbdev "usb2" "USB2" "pca963x:caiman:white:usb2" "1-1"
+ ucidef_set_led_usbdev "usb3" "USB3" "pca963x:caiman:white:usb3_1" "2-1"
+ ;;
+armada-385-linksys-cobra)
+ ucidef_set_led_netdev "wan" "WAN" "pca963x:cobra:white:wan" "eth0"
+ ucidef_set_led_usbdev "usb2" "USB2" "pca963x:cobra:white:usb2" "1-1"
+ ucidef_set_led_usbdev "usb3" "USB3" "pca963x:cobra:white:usb3_1" "2-1"
+ ;;
+armada-385-linksys-shelby)
+ ucidef_set_led_netdev "wan" "WAN" "pca963x:shelby:white:wan" "eth0"
+ ucidef_set_led_usbdev "usb2" "USB2" "pca963x:shelby:white:usb2" "1-1"
+ ucidef_set_led_usbdev "usb3" "USB3" "pca963x:shelby:white:usb3_1" "2-1"
+ ;;
+armada-xp-linksys-mamba)
+ ucidef_set_led_netdev "wan" "WAN" "mamba:white:wan" "eth1"
+ ucidef_set_led_usbdev "usb2" "USB2" "mamba:white:usb2" "1-1"
+ ucidef_set_led_usbdev "usb3" "USB3" "mamba:white:usb3_1" "2-2"
+ ;;
+
+esac
+
+ucidef_commit_leds
+
+exit 0
diff --git a/target/linux/mvebu/base-files/etc/uci-defaults/02_network b/target/linux/mvebu/base-files/etc/uci-defaults/02_network
new file mode 100644
index 0000000..d1da59f
--- /dev/null
+++ b/target/linux/mvebu/base-files/etc/uci-defaults/02_network
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright (C) 2014-2015 OpenWrt.org
+#
+
+[ -e /etc/config/network ] && exit 0
+
+touch /etc/config/network
+
+. /lib/functions/uci-defaults.sh
+. /lib/mvebu.sh
+
+ucidef_set_interface_loopback
+
+board=$(mvebu_board_name)
+
+case "$board" in
+armada-385-linksys-caiman)
+ ucidef_set_interfaces_lan_wan "eth1" "eth0"
+ ;;
+armada-385-linksys-cobra)
+ ucidef_set_interfaces_lan_wan "eth1" "eth0"
+ ;;
+armada-385-linksys-shelby)
+ ucidef_set_interfaces_lan_wan "eth1" "eth0"
+ ;;
+armada-xp-linksys-mamba)
+ ucidef_set_interfaces_lan_wan "eth0" "eth1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5"
+ ucidef_add_switch_vlan "switch0" "2" "4 6"
+ ;;
+armada-385-db-ap)
+ ucidef_set_interfaces_lan_wan "eth0 eth1" "eth2"
+ ;;
+armada-xp-gp)
+ ucidef_set_interface_lan "eth0 eth1 eth2 eth3"
+ ;;
+*)
+ ucidef_set_interface_lan "eth0"
+ ;;
+esac
+
+uci commit network
+
+exit 0
diff --git a/target/linux/mvebu/base-files/etc/uci-defaults/03_wireless b/target/linux/mvebu/base-files/etc/uci-defaults/03_wireless
new file mode 100644
index 0000000..fcf43ee
--- /dev/null
+++ b/target/linux/mvebu/base-files/etc/uci-defaults/03_wireless
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+
+[ ! -e /etc/config/wireless ] && exit 0
+
+. /lib/mvebu.sh
+
+board=$(mvebu_board_name)
+
+case "$board" in
+armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba)
+ SKU=$(strings /dev/mtd3|sed -ne 's/^cert_region=//p')
+ case "$SKU" in
+ AP)
+ REGD=CN
+ ;;
+ AU)
+ REGD=AU
+ ;;
+ CA)
+ REGD=CA
+ ;;
+ EU)
+ REGD=DE
+ ;;
+ US)
+ REGD=US
+ ;;
+ esac
+ uci get wireless.radio0.country || uci set wireless.radio0.country=$REGD
+ uci get wireless.radio1.country || uci set wireless.radio1.country=$REGD
+ ;;
+esac
+
+uci commit wireless
+
+exit 0
diff --git a/target/linux/mvebu/base-files/lib/mvebu.sh b/target/linux/mvebu/base-files/lib/mvebu.sh
new file mode 100755
index 0000000..09ebff3
--- /dev/null
+++ b/target/linux/mvebu/base-files/lib/mvebu.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# Copyright (C) 2013-2015 OpenWrt.org
+#
+
+MVEBU_BOARD_NAME=
+MVEBU_MODEL=
+
+mvebu_board_detect() {
+ local machine
+ local name
+
+ machine=$(cat /proc/device-tree/model)
+
+ case "$machine" in
+ *"Marvell Armada 370 Evaluation Board")
+ name="armada-370-db"
+ ;;
+ *"Globalscale Mirabox")
+ name="mirabox"
+ ;;
+ *"Marvell Armada 370 Reference Design")
+ name="armada-370-rd"
+ ;;
+ *"Marvell Armada XP Evaluation Board")
+ name="armada-xp-db"
+ ;;
+ *"PlatHome OpenBlocks AX3-4 board")
+ name="openblocks-ax3-4"
+ ;;
+ *"Marvell Armada XP GP Board")
+ name="armada-xp-gp"
+ ;;
+ *"Linksys WRT1200AC")
+ name="armada-385-linksys-caiman"
+ ;;
+ *"Linksys WRT1900AC")
+ name="armada-xp-linksys-mamba"
+ ;;
+ *"Linksys WRT1900ACv2")
+ name="armada-385-linksys-cobra"
+ ;;
+ *"Linksys WRT1900ACS")
+ name="armada-385-linksys-shelby"
+ ;;
+ *"Marvell Armada 385 Access Point Development Board")
+ name="armada-385-db-ap"
+ ;;
+ *"Marvell Armada XP Development Board DB-MV784MP-GP")
+ name="armada-xp-gp"
+ ;;
+ esac
+
+ [ -z "$name" ] && name="unknown"
+
+ [ -z "$MVEBU_BOARD_NAME" ] && MVEBU_BOARD_NAME="$name"
+ [ -z "$MVEBU_MODEL" ] && MVEBU_MODEL="$machine"
+
+ [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+
+ echo "$MVEBU_BOARD_NAME" > /tmp/sysinfo/board_name
+ echo "$MVEBU_MODEL" > /tmp/sysinfo/model
+}
+
+mvebu_board_name() {
+ local name
+
+ [ -f /tmp/sysinfo/board_name ] || mvebu_board_detect
+ [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
+ [ -z "$name" ] && name="unknown"
+
+ echo "$name"
+}
diff --git a/target/linux/mvebu/base-files/lib/preinit/06_set_iface_mac b/target/linux/mvebu/base-files/lib/preinit/06_set_iface_mac
new file mode 100644
index 0000000..876c08b
--- /dev/null
+++ b/target/linux/mvebu/base-files/lib/preinit/06_set_iface_mac
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2014-2015 OpenWrt.org
+#
+
+preinit_set_mac_address() {
+ local mac
+
+ . /lib/functions.sh
+ . /lib/mvebu.sh
+
+ case $(mvebu_board_name) in
+ armada-xp-linksys-mamba)
+ mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
+ ifconfig eth0 hw ether $mac 2>/dev/null
+ ifconfig eth1 hw ether $mac 2>/dev/null
+ ;;
+ armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby)
+ mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
+ mac_wan=$(macaddr_setbit_la "$mac")
+ ifconfig eth1 hw ether $mac 2>/dev/null
+ ifconfig eth0 hw ether $mac_wan 2>/dev/null
+ ;;
+ esac
+}
+
+boot_hook_add preinit_main preinit_set_mac_address
diff --git a/target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg b/target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg
new file mode 100644
index 0000000..a54226f
--- /dev/null
+++ b/target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+
+preinit_mount_syscfg() {
+
+ . /lib/functions.sh
+ . /lib/mvebu.sh
+
+ case $(mvebu_board_name) in
+ armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba)
+ needs_recovery=0
+ ubiattach -m 8 || needs_recovery=1
+ if [ $needs_recovery -eq 1 ]
+ then
+ echo "ubifs syscfg partition is damaged, reformatting"
+ ubidetach -m 8
+ ubiformat -y -O 2048 -q /dev/mtd8
+ ubiattach -m 8
+ ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
+ fi
+ mkdir /tmp/syscfg
+ mount -t ubifs ubi1:syscfg /tmp/syscfg
+ [ -f /tmp/syscfg/sysupgrade.tgz ] && {
+ echo "- config restore -"
+ cd /
+ mv /tmp/syscfg/sysupgrade.tgz /tmp
+ tar xzf /tmp/sysupgrade.tgz
+ rm -f /tmp/sysupgrade.tgz
+ sync
+ }
+ ;;
+ esac
+}
+
+boot_hook_add preinit_main preinit_mount_syscfg
diff --git a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
new file mode 100644
index 0000000..fc40333
--- /dev/null
+++ b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2014-2015 OpenWrt.org
+#
+
+linksys_get_target_firmware() {
+ cur_boot_part=`/usr/sbin/fw_printenv -n boot_part`
+ target_firmware=""
+ if [ "$cur_boot_part" = "1" ]
+ then
+ # current primary boot - update alt boot
+ target_firmware="kernel2"
+ fw_setenv boot_part 2
+ fw_setenv bootcmd "run altnandboot"
+ elif [ "$cur_boot_part" = "2" ]
+ then
+ # current alt boot - update primary boot
+ target_firmware="kernel1"
+ fw_setenv boot_part 1
+ fw_setenv bootcmd "run nandboot"
+ fi
+
+ # re-enable recovery so we get back if the new firmware is broken
+ fw_setenv auto_recovery yes
+
+ echo "$target_firmware"
+}
+
+linksys_get_root_magic() {
+ (get_image "$@" | dd skip=786432 bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null
+}
+
+platform_do_upgrade_linksys() {
+ local magic_long="$(get_magic_long "$1")"
+
+ mkdir -p /var/lock
+ local part_label="$(linksys_get_target_firmware)"
+ touch /var/lock/fw_printenv.lock
+
+ if [ ! -n "$part_label" ]
+ then
+ echo "cannot find target partition"
+ exit 1
+ fi
+
+ local target_mtd=$(find_mtd_part $part_label)
+
+ [ "$magic_long" = "73797375" ] && {
+ CI_KERNPART="$part_label"
+ if [ "$part_label" = "kernel1" ]
+ then
+ CI_UBIPART="rootfs1"
+ else
+ CI_UBIPART="rootfs2"
+ fi
+
+ nand_upgrade_tar "$1"
+ }
+ [ "$magic_long" = "27051956" ] && {
+ # check firmwares' rootfs types
+ local target_mtd=$(find_mtd_part $part_label)
+ local oldroot="$(linksys_get_root_magic $target_mtd)"
+ local newroot="$(linksys_get_root_magic "$1")"
+
+ if [ "$newroot" = "55424923" -a "$oldroot" = "55424923" ]
+ # we're upgrading from a firmware with UBI to one with UBI
+ then
+ # erase everything to be safe
+ mtd erase $part_label
+ get_image "$1" | mtd -n write - $part_label
+ else
+ get_image "$1" | mtd write - $part_label
+ fi
+ }
+}
+
+linksys_preupgrade() {
+ export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/sbin/fw_printenv /usr/sbin/fw_setenv"
+ export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /bin/mkdir /bin/touch"
+ export RAMFS_COPY_DATA="${RAMFS_COPY_DATA} /etc/fw_env.config /var/lock/fw_printenv.lock"
+
+ [ -f /tmp/sysupgrade.tgz ] && {
+ cp /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz
+ }
+}
+
+append sysupgrade_pre_upgrade linksys_preupgrade
diff --git a/target/linux/mvebu/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/base-files/lib/upgrade/platform.sh
new file mode 100755
index 0000000..2f699a7
--- /dev/null
+++ b/target/linux/mvebu/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+
+. /lib/mvebu.sh
+
+RAMFS_COPY_DATA=/lib/mvebu.sh
+
+platform_check_image() {
+ local board=$(mvebu_board_name)
+ local magic_long="$(get_magic_long "$1")"
+
+ [ "$#" -gt 1 ] && return 1
+
+ case "$board" in
+ armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba)
+ [ "$magic_long" != "27051956" -a "$magic_long" != "73797375" ] && {
+ echo "Invalid image type."
+ return 1
+ }
+ return 0;
+ ;;
+ esac
+
+ echo "Sysupgrade is not yet supported on $board."
+ return 1
+}
+
+platform_do_upgrade() {
+ local board=$(mvebu_board_name)
+
+ case "$board" in
+ armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba)
+ platform_do_upgrade_linksys "$ARGV"
+ ;;
+ *)
+ default_do_upgrade "$ARGV"
+ ;;
+ esac
+}
+
+disable_watchdog() {
+ killall watchdog
+ ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
+ echo 'Could not disable watchdog'
+ return 1
+ }
+}
+
+append sysupgrade_pre_upgrade disable_watchdog
diff --git a/target/linux/mvebu/base-files/sbin/fan_ctrl.sh b/target/linux/mvebu/base-files/sbin/fan_ctrl.sh
new file mode 100755
index 0000000..06e4621
--- /dev/null
+++ b/target/linux/mvebu/base-files/sbin/fan_ctrl.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+CPU_TEMP=`cut -c1-2 /sys/class/hwmon/hwmon2/temp1_input`
+DDR_TEMP=`cut -c1-2 /sys/class/hwmon/hwmon1/temp1_input`
+WIFI_TEMP=`cut -c1-2 /sys/class/hwmon/hwmon1/temp2_input`
+
+CPU_LOW=85
+CPU_HIGH=95
+DDR_LOW=65
+DDR_HIGH=75
+WIFI_LOW=100
+WIFI_HIGH=115
+
+if [ -d /sys/devices/pwm_fan ];then
+ FAN_CTRL=/sys/devices/pwm_fan/hwmon/hwmon0/pwm1
+elif [ -d /sys/devices/platform/pwm_fan ];then
+ FAN_CTRL=/sys/devices/platform/pwm_fan/hwmon/hwmon0/pwm1
+else
+ exit 0
+fi
+
+if [ "$CPU_TEMP" -ge "$CPU_HIGH" -o "$DDR_TEMP" -ge "$DDR_HIGH" -o "$WIFI_TEMP" -ge "$WIFI_HIGH" ];then
+ echo "255" > $FAN_CTRL
+elif [ "$CPU_TEMP" -ge "$CPU_LOW" -o "$DDR_TEMP" -ge "$DDR_LOW" -o "$WIFI_TEMP" -ge "$WIFI_LOW" ];then
+ echo "100" > $FAN_CTRL
+else
+ echo "0" > $FAN_CTRL
+fi