aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/mt7621
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/ramips/mt7621')
-rwxr-xr-xtarget/linux/ramips/mt7621/base-files/etc/board.d/02_network10
-rw-r--r--target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh55
-rwxr-xr-xtarget/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh4
3 files changed, 65 insertions, 4 deletions
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
index 84fc283f4f..ffe5793a6e 100755
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -72,6 +72,7 @@ ramips_setup_interfaces()
elecom,wrc-1900gst|\
elecom,wrc-2533gst|\
iodata,wn-ax1167gr|\
+ iodata,wn-dx1167r|\
iodata,wn-gx300gr|\
iodata,wnpr2600g|\
iptime,a8004t)
@@ -222,6 +223,11 @@ ramips_setup_macs()
xiaoyu,xy-c5)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
;;
+ iodata,wn-dx1167r|\
+ xiaomi,mir3g-v2)
+ wan_mac=$(mtd_get_mac_binary factory 0xe006)
+ label_mac=$wan_mac
+ ;;
iodata,wnpr2600g)
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
label_mac=$wan_mac
@@ -266,10 +272,6 @@ ramips_setup_macs()
lan_mac=$(mtd_get_mac_binary factory 0xe006)
label_mac=$lan_mac
;;
- xiaomi,mir3g-v2)
- wan_mac=$(mtd_get_mac_binary factory 0xe006)
- label_mac=$wan_mac
- ;;
zbtlink,zbt-we1326)
wan_mac=$(mtd_get_mac_binary factory 0xe006)
label_mac=$(mtd_get_mac_binary factory 0x4)
diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh
new file mode 100644
index 0000000000..d7a3477f0a
--- /dev/null
+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2019 OpenWrt.org
+#
+
+. /lib/functions.sh
+
+iodata_mstc_prepare_fail() {
+ echo "failed to check and prepare the environment, rebooting..."
+ umount -a
+ reboot -f
+}
+
+# I-O DATA devices manufactured by MSTC (MitraStar Technology Corp.)
+# have two important flags:
+# - bootnum: switch between two os images
+# use 1st image in OpenWrt
+# - debugflag: enable/disable debug
+# users can interrupt Z-Loader for recovering the device if enabled
+iodata_mstc_upgrade_prepare() {
+ local persist_mtd="$(find_mtd_part persist)"
+ local factory_mtd="$(find_mtd_part factory)"
+
+ if [ -z "$persist_mtd" -o -z "$factory_mtd" ]; then
+ echo 'cannot find mtd partition(s), "factory" or "persist"'
+ iodata_mstc_prepare_fail
+ fi
+
+ local bootnum=$(hexdump -s 4 -n 1 -e '"%x"' ${persist_mtd})
+ local debugflag=$(hexdump -s 65141 -n 1 -e '"%x"' ${factory_mtd})
+
+ if [ "$bootnum" != "1" -a "$bootnum" != "2" ]; then
+ echo "failed to get bootnum, please check the value at 0x4 in ${persist_mtd}"
+ iodata_mstc_prepare_fail
+ fi
+ if [ "$debugflag" != "0" -a "$debugflag" != "1" ]; then
+ echo "failed to get debugflag, please check the value at 0xFE75 in ${factory_mtd}"
+ iodata_mstc_prepare_fail
+ fi
+ echo "current: bootnum => ${bootnum}, debugflag => ${debugflag}"
+
+ if [ "$bootnum" = "2" ]; then
+ if ! (echo -ne "\x01" | dd bs=1 count=1 seek=4 conv=notrunc of=${persist_mtd} 2>/dev/null); then
+ echo "failed to set bootnum"
+ iodata_mstc_prepare_fail
+ fi
+ echo "### switch to 1st os-image on next boot ###"
+ fi
+ if [ "$debugflag" = "0" ]; then
+ if ! (echo -ne "\x01" | dd bs=1 count=1 seek=65141 conv=notrunc of=${factory_mtd} 2>/dev/null); then
+ echo "failed to set debugflag"
+ iodata_mstc_prepare_fail
+ fi
+ echo "### enable debug ###"
+ fi
+}
diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
index d74aba3bfe..e27f9df387 100755
--- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
@@ -53,6 +53,10 @@ platform_do_upgrade() {
xiaomi,mir3p)
nand_do_upgrade "$1"
;;
+ iodata,wn-dx1167r)
+ iodata_mstc_upgrade_prepare
+ nand_do_upgrade "$1"
+ ;;
ubiquiti,edgerouterx|\
ubiquiti,edgerouterx-sfp)
platform_upgrade_ubnt_erx "$1"