Initial commit
This commit is contained in:
132
target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
Normal file
132
target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
. /lib/functions/leds.sh
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
board_config_update
|
||||
|
||||
case $board in
|
||||
asus,rt-n56u-b1)
|
||||
ucidef_set_led_netdev "lan" "LAN link" "blue:lan" "br-lan"
|
||||
ucidef_set_led_netdev "wan" "WAN link" "blue:wan" "wan"
|
||||
;;
|
||||
cudy,wr2100)
|
||||
ucidef_set_led_netdev "lan1" "lan1" "green:lan1" "lan1"
|
||||
ucidef_set_led_netdev "lan2" "lan2" "green:lan2" "lan2"
|
||||
ucidef_set_led_netdev "lan3" "lan3" "green:lan3" "lan3"
|
||||
ucidef_set_led_netdev "lan4" "lan4" "green:lan4" "lan4"
|
||||
ucidef_set_led_netdev "wan" "wan" "green:wan" "wan"
|
||||
;;
|
||||
d-team,newifi-d2)
|
||||
ucidef_set_led_netdev "internet" "internet" "amber:internet" "wan"
|
||||
ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "blue:wlan2g" "wlan0"
|
||||
ucidef_set_led_netdev "wlan5g" "WiFi 5GHz" "blue:wlan5g" "wlan1"
|
||||
;;
|
||||
d-team,pbr-m1|\
|
||||
gehua,ghl-r-001|\
|
||||
jcg,y2|\
|
||||
xzwifi,creativebox-v1)
|
||||
ucidef_set_led_netdev "internet" "internet" "blue:internet" "wan"
|
||||
;;
|
||||
dlink,dir-1960-a1|\
|
||||
dlink,dir-2640-a1|\
|
||||
dlink,dir-2660-a1)
|
||||
ucidef_set_led_netdev "wan" "wan" "white:net" "wan"
|
||||
;;
|
||||
dlink,dir-853-a3)
|
||||
ucidef_set_led_netdev "wan" "wan" "blue:net" "wan"
|
||||
;;
|
||||
dlink,dir-853-r1)
|
||||
ucidef_set_led_netdev "internet" "internet" "blue:net" "wan"
|
||||
;;
|
||||
dlink,dir-860l-b1|\
|
||||
dlink,dir-867-a1|\
|
||||
dlink,dir-878-a1|\
|
||||
dlink,dir-882-a1|\
|
||||
dlink,dir-882-r1)
|
||||
ucidef_set_led_netdev "wan" "wan" "green:net" "wan"
|
||||
;;
|
||||
gnubee,gb-pc1|\
|
||||
gnubee,gb-pc2)
|
||||
ucidef_set_led_netdev "lan1" "lan1" "green:lan1" "lan1"
|
||||
ucidef_set_led_netdev "lan2" "lan2" "green:lan2" "lan2"
|
||||
;;
|
||||
linksys,e5600)
|
||||
ucidef_set_led_netdev "wan" "wan link" "blue:wan" "wan" "link"
|
||||
;;
|
||||
linksys,ea7300-v1|\
|
||||
linksys,ea7300-v2|\
|
||||
linksys,ea7500-v2|\
|
||||
linksys,ea8100-v1|\
|
||||
linksys,ea8100-v2)
|
||||
ucidef_set_led_netdev "lan1" "lan1 link" "green:lan1" "lan1" "link"
|
||||
ucidef_set_led_netdev "lan2" "lan2 link" "green:lan2" "lan2" "link"
|
||||
ucidef_set_led_netdev "lan3" "lan3 link" "green:lan3" "lan3" "link"
|
||||
ucidef_set_led_netdev "lan4" "lan4 link" "green:lan4" "lan4" "link"
|
||||
ucidef_set_led_netdev "wan" "wan link" "green:wan" "wan" "link"
|
||||
;;
|
||||
mikrotik,routerboard-760igs)
|
||||
ucidef_set_led_netdev "sfp" "SFP" "blue:sfp" "sfp"
|
||||
;;
|
||||
mikrotik,routerboard-m11g)
|
||||
ucidef_set_rssimon "wlan0" "200000" "1"
|
||||
ucidef_set_led_rssi "rssilow" "RSSILOW" "green:rssi0" "wlan0" "1" "100"
|
||||
ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:rssi1" "wlan0" "20" "100"
|
||||
ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssi2" "wlan0" "40" "100"
|
||||
ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssi3" "wlan0" "60" "100"
|
||||
ucidef_set_led_rssi "rssiveryhigh" "RSSIVERYHIGH" "green:rssi4" "wlan0" "80" "100"
|
||||
;;
|
||||
mtc,wr1201)
|
||||
ucidef_set_led_netdev "eth_link" "LAN link" "green:eth_link" "br-lan"
|
||||
;;
|
||||
netgear,r6220|\
|
||||
netgear,r6260|\
|
||||
netgear,r6350|\
|
||||
netgear,r6850|\
|
||||
netgear,wac124|\
|
||||
netgear,wndr3700-v5)
|
||||
ucidef_set_led_netdev "wan" "wan" "green:wan" "wan"
|
||||
;;
|
||||
netgear,r6700-v2|\
|
||||
netgear,r6800|\
|
||||
netgear,r6900-v2|\
|
||||
netgear,r7200|\
|
||||
netgear,r7450)
|
||||
ucidef_set_led_netdev "wan" "WAN" "white:wan" "wan"
|
||||
ucidef_set_led_netdev "lan1" "LAN1" "white:lan1" "lan1"
|
||||
ucidef_set_led_netdev "lan2" "LAN2" "white:lan2" "lan2"
|
||||
ucidef_set_led_netdev "lan3" "LAN3" "white:lan3" "lan3"
|
||||
ucidef_set_led_netdev "lan4" "LAN4" "white:lan4" "lan4"
|
||||
;;
|
||||
tplink,archer-a6-v3|\
|
||||
tplink,archer-c6-v3|\
|
||||
tplink,archer-c6u-v1)
|
||||
ucidef_set_led_netdev "lan" "LAN" "green:lan" "br-lan"
|
||||
ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan"
|
||||
;;
|
||||
tplink,re350-v1)
|
||||
ucidef_set_led_netdev "wifi2g" "Wifi 2.4G" "blue:wifi2G" "wlan0"
|
||||
ucidef_set_led_netdev "wifi5g" "Wifi 5G" "blue:wifi5G" "wlan1"
|
||||
ucidef_set_led_netdev "eth_act" "LAN act" "green:eth_act" "lan" "tx rx"
|
||||
ucidef_set_led_netdev "eth_link" "LAN link" "green:eth_link" "lan" "link"
|
||||
;;
|
||||
tplink,re500-v1|\
|
||||
tplink,re650-v1)
|
||||
ucidef_set_led_netdev "eth_act" "LAN act" "green:eth_act" "lan" "tx rx"
|
||||
ucidef_set_led_netdev "eth_link" "LAN link" "green:eth_link" "lan" "link"
|
||||
;;
|
||||
xiaomi,mi-router-ac2100)
|
||||
ucidef_set_led_netdev "wan-blue" "WAN (blue)" "blue:wan" "wan"
|
||||
;;
|
||||
xiaomi,redmi-router-ac2100)
|
||||
ucidef_set_led_netdev "wan" "wan" "white:wan" "wan"
|
||||
;;
|
||||
youhua,wr1200js)
|
||||
ucidef_set_led_netdev "internet" "INTERNET" "green:wan" "wan"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
176
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
Normal file
176
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
Normal file
@@ -0,0 +1,176 @@
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/uci-defaults.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
ramips_setup_interfaces()
|
||||
{
|
||||
local board="$1"
|
||||
|
||||
case $board in
|
||||
ampedwireless,ally-00x19k|\
|
||||
edimax,re23s|\
|
||||
mikrotik,routerboard-m11g|\
|
||||
netgear,ex6150|\
|
||||
sercomm,na502|\
|
||||
thunder,timecloud|\
|
||||
tplink,re350-v1|\
|
||||
tplink,re500-v1|\
|
||||
tplink,re650-v1|\
|
||||
ubnt,unifi-6-lite|\
|
||||
ubnt,unifi-nanohd)
|
||||
ucidef_set_interface_lan "lan"
|
||||
;;
|
||||
ampedwireless,ally-r1900k|\
|
||||
gehua,ghl-r-001|\
|
||||
hiwifi,hc5962|\
|
||||
xiaomi,mi-router-3-pro|\
|
||||
xiaomi,mi-router-ac2100|\
|
||||
xiaomi,redmi-router-ac2100)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
|
||||
;;
|
||||
asiarf,ap7621-001|\
|
||||
winstars,ws-wn583a6)
|
||||
ucidef_set_interfaces_lan_wan "lan" "wan"
|
||||
;;
|
||||
asiarf,ap7621-nv1|\
|
||||
glinet,gl-mt1300|\
|
||||
jcg,q20|\
|
||||
lenovo,newifi-d1|\
|
||||
mikrotik,routerboard-m33g|\
|
||||
xiaomi,mi-router-3g|\
|
||||
xiaomi,mi-router-3g-v2|\
|
||||
xiaomi,mi-router-4|\
|
||||
xiaomi,mi-router-4a-gigabit)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2" "wan"
|
||||
;;
|
||||
gnubee,gb-pc1|\
|
||||
gnubee,gb-pc2)
|
||||
ucidef_set_interface_lan "lan1 lan2"
|
||||
;;
|
||||
linksys,re6500|\
|
||||
netgear,wac104)
|
||||
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
|
||||
;;
|
||||
mikrotik,routerboard-750gr3)
|
||||
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
|
||||
;;
|
||||
mikrotik,routerboard-760igs)
|
||||
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan sfp"
|
||||
;;
|
||||
tplink,eap235-wall-v1)
|
||||
ucidef_set_interface_lan "lan0 lan1 lan2 lan3"
|
||||
;;
|
||||
ubnt,edgerouter-x)
|
||||
ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4" "eth0"
|
||||
;;
|
||||
ubnt,edgerouter-x-sfp)
|
||||
ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
|
||||
;;
|
||||
ubnt,usw-flex)
|
||||
ucidef_set_interface_lan "lan1 lan2 lan3 lan4 lan5"
|
||||
;;
|
||||
zyxel,nr7101)
|
||||
ucidef_set_interfaces_lan_wan "lan" "wan"
|
||||
;;
|
||||
zyxel,wap6805)
|
||||
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
|
||||
ucidef_set_interface "qtn" ifname "eth1" protocol "static" ipaddr "1.1.1.1" netmask "255.255.255.0"
|
||||
;;
|
||||
*)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
ramips_setup_macs()
|
||||
{
|
||||
local board="$1"
|
||||
local lan_mac=""
|
||||
local wan_mac=""
|
||||
local label_mac=""
|
||||
|
||||
case $board in
|
||||
ampedwireless,ally-00x19k)
|
||||
lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
|
||||
label_mac=$lan_mac
|
||||
;;
|
||||
ampedwireless,ally-r1900k)
|
||||
lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
|
||||
wan_mac=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address)
|
||||
label_mac=$lan_mac
|
||||
;;
|
||||
asus,rt-ac65p|\
|
||||
asus,rt-ac85p)
|
||||
wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
|
||||
label_mac=$(mtd_get_mac_binary factory 0x4)
|
||||
;;
|
||||
buffalo,wsr-1166dhp)
|
||||
local index="$(find_mtd_index "board_data")"
|
||||
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
|
||||
lan_mac=$wan_mac
|
||||
;;
|
||||
dlink,dir-860l-b1)
|
||||
lan_mac=$(mtd_get_mac_ascii factory lanmac)
|
||||
wan_mac=$(mtd_get_mac_ascii factory wanmac)
|
||||
;;
|
||||
edimax,ra21s|\
|
||||
edimax,rg21s)
|
||||
lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
|
||||
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
|
||||
;;
|
||||
elecom,wrc-2533ghbk-i)
|
||||
lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
|
||||
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
|
||||
label_mac=$wan_mac
|
||||
;;
|
||||
hiwifi,hc5962)
|
||||
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
||||
label_mac=$lan_mac
|
||||
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
|
||||
wan_mac=$(macaddr_add "$lan_mac" 1)
|
||||
;;
|
||||
iodata,wnpr2600g)
|
||||
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
|
||||
label_mac=$wan_mac
|
||||
;;
|
||||
jcg,y2|\
|
||||
wavlink,wl-wn531a6|\
|
||||
winstars,ws-wn583a6|\
|
||||
zbtlink,zbt-we1326|\
|
||||
zbtlink,zbt-wg3526-16m|\
|
||||
zbtlink,zbt-wg3526-32m)
|
||||
label_mac=$(mtd_get_mac_binary factory 0x4)
|
||||
;;
|
||||
linksys,e5600|\
|
||||
linksys,ea7300-v1|\
|
||||
linksys,ea7300-v2|\
|
||||
linksys,ea7500-v2|\
|
||||
linksys,ea8100-v1|\
|
||||
linksys,ea8100-v2)
|
||||
lan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
wan_mac=$lan_mac
|
||||
label_mac=$lan_mac
|
||||
;;
|
||||
mikrotik,routerboard-750gr3|\
|
||||
mikrotik,routerboard-760igs|\
|
||||
mikrotik,routerboard-m11g|\
|
||||
mikrotik,routerboard-m33g)
|
||||
label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
|
||||
wan_mac=$label_mac
|
||||
lan_mac=$(macaddr_add $label_mac 1)
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
|
||||
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
|
||||
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
|
||||
}
|
||||
|
||||
board_config_update
|
||||
board=$(board_name)
|
||||
ramips_setup_interfaces $board
|
||||
ramips_setup_macs $board
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
mikrotik,routerboard-760igs)
|
||||
ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "497"
|
||||
;;
|
||||
telco-electronics,x1)
|
||||
ucidef_add_gpio_switch "modem_reset" "Modem Reset" "496"
|
||||
;;
|
||||
ubnt,edgerouter-x)
|
||||
ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "480"
|
||||
;;
|
||||
ubnt,edgerouter-x-sfp)
|
||||
ucidef_add_gpio_switch "poe_power_port0" "PoE Power Port0" "400"
|
||||
ucidef_add_gpio_switch "poe_power_port1" "PoE Power Port1" "401"
|
||||
ucidef_add_gpio_switch "poe_power_port2" "PoE Power Port2" "402"
|
||||
ucidef_add_gpio_switch "poe_power_port3" "PoE Power Port3" "403"
|
||||
ucidef_add_gpio_switch "poe_power_port4" "PoE Power Port4" "404"
|
||||
;;
|
||||
zyxel,nr7101)
|
||||
ucidef_add_gpio_switch "lte_reset" "Reset LTE/5G modem" "483"
|
||||
;;
|
||||
zyxel,wap6805)
|
||||
ucidef_add_gpio_switch "qtn_power" "Quantenna Module Power" "496" "1"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright (C) 2020 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
case "$(board_name)" in
|
||||
*)
|
||||
ucidef_set_compat_version "1.1"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,42 @@
|
||||
[ "$ACTION" == "add" ] || exit 0
|
||||
|
||||
PHYNBR=${DEVPATH##*/phy}
|
||||
|
||||
[ -n $PHYNBR ] || exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
dlink,dir-853-a3)
|
||||
[ "$PHYNBR" = "0" ] && \
|
||||
macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \
|
||||
> /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
dlink,dir-853-r1)
|
||||
if [ "$PHYNBR" = "0" ]; then
|
||||
base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" -1)
|
||||
macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress
|
||||
fi
|
||||
;;
|
||||
glinet,gl-mt1300)
|
||||
[ "$PHYNBR" = "1" ] && \
|
||||
macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
jcg,q20)
|
||||
[ "$PHYNBR" = "1" ] && \
|
||||
macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
linksys,e5600|\
|
||||
linksys,ea7300-v1|\
|
||||
linksys,ea7300-v2|\
|
||||
linksys,ea7500-v2|\
|
||||
linksys,ea8100-v1|\
|
||||
linksys,ea8100-v2)
|
||||
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
esac
|
||||
28
target/linux/ramips/mt7621/base-files/etc/init.d/bootcount
Executable file
28
target/linux/ramips/mt7621/base-files/etc/init.d/bootcount
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
boot() {
|
||||
case $(board_name) in
|
||||
alfa-network,quad-e4g)
|
||||
[ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\
|
||||
echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s -
|
||||
;;
|
||||
linksys,e5600|\
|
||||
linksys,ea7300-v1|\
|
||||
linksys,ea7300-v2|\
|
||||
linksys,ea7500-v2|\
|
||||
linksys,ea8100-v1|\
|
||||
linksys,ea8100-v2)
|
||||
mtd resetbc s_env || true
|
||||
;;
|
||||
samknows,whitebox-v8)
|
||||
fw_setenv bootcount 0
|
||||
;;
|
||||
zyxel,nr7101)
|
||||
[ $(printf %d $(fw_printenv -n DebugFlag)) -gt 0 ] || fw_setenv DebugFlag 0x1
|
||||
[ $(printf %d $(fw_printenv -n Image1Stable)) -gt 0 ] || fw_setenv Image1Stable 1
|
||||
[ $(printf %d $(fw_printenv -n Image1Try)) -gt 0 ] && fw_setenv Image1Try 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
19
target/linux/ramips/mt7621/base-files/etc/init.d/set-irq-affinity
Executable file
19
target/linux/ramips/mt7621/base-files/etc/init.d/set-irq-affinity
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
start() {
|
||||
if grep -q 'processor.*: 2' /proc/cpuinfo; then
|
||||
mask=4
|
||||
elif grep -q 'processor.*: 1' /proc/cpuinfo; then
|
||||
mask=2
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
for irq in $(grep "mt76..e" /proc/interrupts | cut -d: -f1 | sed 's, *,,')
|
||||
do
|
||||
echo "$mask" > "/proc/irq/$irq/smp_affinity"
|
||||
[ $mask = 4 ] && mask=8
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
uci -q get network.globals.packet_steering > /dev/null || {
|
||||
uci set network.globals='globals'
|
||||
uci set network.globals.packet_steering=1
|
||||
uci commit network
|
||||
}
|
||||
64
target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh
Normal file
64
target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# parameters:
|
||||
# - $1: the offset of "debugflag"
|
||||
iodata_mstc_upgrade_prepare() {
|
||||
local persist_mtd="$(find_mtd_part persist)"
|
||||
local factory_mtd="$(find_mtd_part factory)"
|
||||
local dflag_offset="$1"
|
||||
|
||||
if [ -z "$dflag_offset" ]; then
|
||||
echo 'no debugflag offset provided'
|
||||
iodata_mstc_prepare_fail
|
||||
fi
|
||||
|
||||
if [ -z "$persist_mtd" ] || [ -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 $((dflag_offset)) -n 1 -e '"%x"' ${factory_mtd})
|
||||
|
||||
if [ "$bootnum" != "1" ] && [ "$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" ] && [ "$debugflag" != "1" ]; then
|
||||
echo "failed to get debugflag, please check the value at ${dflag_offset} 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=$((dflag_offset)) conv=notrunc of=${factory_mtd} 2>/dev/null); then
|
||||
echo "failed to set debugflag"
|
||||
iodata_mstc_prepare_fail
|
||||
fi
|
||||
echo "### enable debug ###"
|
||||
fi
|
||||
}
|
||||
122
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
Executable file
122
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
Executable file
@@ -0,0 +1,122 @@
|
||||
#
|
||||
# Copyright (C) 2010 OpenWrt.org
|
||||
#
|
||||
|
||||
PART_NAME=firmware
|
||||
REQUIRE_IMAGE_METADATA=1
|
||||
|
||||
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||
|
||||
platform_check_image() {
|
||||
return 0
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
local board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
alfa-network,quad-e4g)
|
||||
[ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\
|
||||
[ -n "$(find_mtd_part backup)" ] && {
|
||||
PART_NAME=backup
|
||||
if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then
|
||||
fw_setenv bootactive 2 || exit 1
|
||||
else
|
||||
fw_setenv bootactive 1 || exit 1
|
||||
fi
|
||||
}
|
||||
;;
|
||||
ampedwireless,ally-00x19k|\
|
||||
ampedwireless,ally-r1900k)
|
||||
if [ "$(fw_printenv --lock / -n bootImage 2>/dev/null)" != "0" ]; then
|
||||
fw_setenv --lock / bootImage 0 || exit 1
|
||||
fi
|
||||
;;
|
||||
mikrotik,routerboard-750gr3|\
|
||||
mikrotik,routerboard-760igs|\
|
||||
mikrotik,routerboard-m11g|\
|
||||
mikrotik,routerboard-m33g)
|
||||
[ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
|
||||
;;
|
||||
asus,rt-ac65p|\
|
||||
asus,rt-ac85p)
|
||||
echo "Backing up firmware"
|
||||
dd if=/dev/mtd4 bs=1024 count=4096 > /tmp/backup_firmware.bin
|
||||
dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
|
||||
mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$board" in
|
||||
ampedwireless,ally-00x19k|\
|
||||
ampedwireless,ally-r1900k|\
|
||||
asus,rt-ac65p|\
|
||||
asus,rt-ac85p|\
|
||||
dlink,dir-1960-a1|\
|
||||
dlink,dir-2640-a1|\
|
||||
dlink,dir-2660-a1|\
|
||||
dlink,dir-853-a3|\
|
||||
hiwifi,hc5962|\
|
||||
jcg,q20|\
|
||||
linksys,e5600|\
|
||||
linksys,ea7300-v1|\
|
||||
linksys,ea7300-v2|\
|
||||
linksys,ea7500-v2|\
|
||||
linksys,ea8100-v1|\
|
||||
linksys,ea8100-v2|\
|
||||
netgear,r6220|\
|
||||
netgear,r6260|\
|
||||
netgear,r6350|\
|
||||
netgear,r6700-v2|\
|
||||
netgear,r6800|\
|
||||
netgear,r6850|\
|
||||
netgear,r6900-v2|\
|
||||
netgear,r7200|\
|
||||
netgear,r7450|\
|
||||
netgear,wac104|\
|
||||
netgear,wac124|\
|
||||
netis,wf2881|\
|
||||
sercomm,na502|\
|
||||
xiaomi,mi-router-3g|\
|
||||
xiaomi,mi-router-3-pro|\
|
||||
xiaomi,mi-router-4|\
|
||||
xiaomi,mi-router-ac2100|\
|
||||
xiaomi,redmi-router-ac2100)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
iodata,wn-ax1167gr2|\
|
||||
iodata,wn-ax2033gr|\
|
||||
iodata,wn-dx1167r|\
|
||||
iodata,wn-dx2033gr)
|
||||
iodata_mstc_upgrade_prepare "0xfe75"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
iodata,wn-dx1200gr)
|
||||
iodata_mstc_upgrade_prepare "0x1fe75"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
ubnt,edgerouter-x|\
|
||||
ubnt,edgerouter-x-sfp)
|
||||
platform_upgrade_ubnt_erx "$1"
|
||||
;;
|
||||
zyxel,nr7101)
|
||||
fw_setenv CheckBypass 0
|
||||
fw_setenv Image1Stable 0
|
||||
CI_KERNPART="Kernel"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,wap6805)
|
||||
local kernel2_mtd="$(find_mtd_part Kernel2)"
|
||||
[ "$(hexdump -n 4 -e '"%x"' $kernel2_mtd)" = "56190527" ] &&\
|
||||
[ "$(hexdump -n 4 -s 104 -e '"%x"' $kernel2_mtd)" != "0" ] &&\
|
||||
dd bs=4 count=1 seek=26 conv=notrunc if=/dev/zero of=$kernel2_mtd 2>/dev/null &&\
|
||||
echo "Kernel2 sequence number was reset to 0"
|
||||
CI_KERNPART="Kernel"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
78
target/linux/ramips/mt7621/base-files/lib/upgrade/ubnt.sh
Normal file
78
target/linux/ramips/mt7621/base-files/lib/upgrade/ubnt.sh
Normal file
@@ -0,0 +1,78 @@
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
#Note: this code also uses some functions from nand.sh, but it is expected to be run by nand.sh, so we are not
|
||||
#sourcing it explicitly here
|
||||
|
||||
UBNT_ERX_KERNEL_INDEX_OFFSET=160
|
||||
|
||||
ubnt_get_target_kernel() {
|
||||
local factory_mtd=$1
|
||||
local current_kernel_index=$(hexdump -s $UBNT_ERX_KERNEL_INDEX_OFFSET -n 1 -e '/1 "%X "' ${factory_mtd})
|
||||
|
||||
if [ $current_kernel_index == "0" ]; then
|
||||
echo 'kernel2'
|
||||
elif [ $current_kernel_index == "1" ]; then
|
||||
echo 'kernel1'
|
||||
fi
|
||||
}
|
||||
|
||||
ubnt_update_target_kernel() {
|
||||
local factory_mtd=$1
|
||||
local kernel_part=$2
|
||||
|
||||
local new_kernel_index
|
||||
if [ $kernel_part == "kernel1" ]; then
|
||||
new_kernel_index="\x00"
|
||||
elif [ $kernel_part == "kernel2" ]; then
|
||||
new_kernel_index="\x01"
|
||||
else
|
||||
echo 'Unknown kernel image index' >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! (echo -e $new_kernel_index | dd of=${factory_mtd} bs=1 count=1 seek=$UBNT_ERX_KERNEL_INDEX_OFFSET); then
|
||||
echo 'Failed to update kernel bootup index' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
platform_upgrade_ubnt_erx() {
|
||||
local factory_mtd=$(find_mtd_part factory)
|
||||
if [ -z "$factory_mtd" ]; then
|
||||
echo "cannot find factory partition" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local kernel_part="$(ubnt_get_target_kernel ${factory_mtd})"
|
||||
if [ -z "$kernel_part" ]; then
|
||||
echo "cannot find factory partition" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# This is a global defined in nand.sh, sets partition kernel will be flashed into
|
||||
CI_KERNPART=${kernel_part}
|
||||
|
||||
#Remove volume possibly left over from stock firmware
|
||||
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||
if [ -z "$ubidev" ]; then
|
||||
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
|
||||
if [ -z "$mtdnum" ]; then
|
||||
echo "cannot find ubi mtd partition $CI_UBIPART" >&2
|
||||
exit 1
|
||||
fi
|
||||
ubiattach -m "$mtdnum"
|
||||
sync
|
||||
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||
fi
|
||||
if [ -n "$ubidev" ]; then
|
||||
local troot_ubivol="$( nand_find_volume $ubidev troot )"
|
||||
[ -n "$troot_ubivol" ] && ubirmvol /dev/$ubidev -N troot || true
|
||||
fi
|
||||
|
||||
ubnt_update_target_kernel ${factory_mtd} ${kernel_part} || exit 1
|
||||
|
||||
nand_do_upgrade "$1"
|
||||
}
|
||||
80
target/linux/ramips/mt7621/base-files/sbin/fixup-mac-address
Executable file
80
target/linux/ramips/mt7621/base-files/sbin/fixup-mac-address
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
partname=""
|
||||
offset=""
|
||||
NEW_MAC=
|
||||
YES=
|
||||
|
||||
board=$(board_name)
|
||||
case $board in
|
||||
mqmaker,witi)
|
||||
partname=factory
|
||||
offset=$((0xe000))
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported board"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
??:??:??:??:??:??) NEW_MAC="$1";;
|
||||
-y) YES=1;;
|
||||
*)
|
||||
cat <<EOF
|
||||
Unknown option/argument '$1'
|
||||
Usage: $0 [-y] [<macaddr>]
|
||||
EOF
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
ask_bool() {
|
||||
local message="$1"
|
||||
local default="$((! ${2:-0}))"
|
||||
[ -n "$YES" ] && return 0
|
||||
echo -n "$message "
|
||||
read opt
|
||||
case "$opt" in
|
||||
y|Y) return 0;;
|
||||
n|N) return 1;;
|
||||
*) return $default;;
|
||||
esac
|
||||
}
|
||||
|
||||
convert_hex() {
|
||||
hexdump -e '/1 "%02x "'
|
||||
}
|
||||
|
||||
gen_mac() {
|
||||
dd if=/dev/urandom bs=6 count=1 2>/dev/null
|
||||
}
|
||||
|
||||
mac="$(mtd_get_mac_binary $partname $offset)"
|
||||
case "$mac" in
|
||||
00:00:00:00:00:00);;
|
||||
ff:ff:ff:ff:ff:ff);;
|
||||
*)
|
||||
echo "Current MAC address: $mac"
|
||||
ask_bool "Overwrite (y/N)?" 0 || exit
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$NEW_MAC" ]; then
|
||||
set -- $(echo "$NEW_MAC" | sed 's,:, ,g')
|
||||
else
|
||||
set -- $(gen_mac | convert_hex)
|
||||
set -- $(printf %02x $(( (0x$1 & 0xfe) | 0x02 ))) $2 $3 $4 $5 $6
|
||||
fi
|
||||
echo "New MAC address: $1:$2:$3:$4:$5:$6"
|
||||
ask_bool "Write to EEPROM (y/N)?" || exit
|
||||
|
||||
part=$(find_mtd_part "$partname")
|
||||
[ -n "$part" ] || exit
|
||||
echo -ne "\x$1\x$2\x$3\x$4\x$5\x$6" | dd of=$part conv=notrunc bs=1 count=6 seek=$offset 2>/dev/null
|
||||
echo "Done"
|
||||
Reference in New Issue
Block a user