Initial commit
This commit is contained in:
70
target/linux/ipq806x/base-files/etc/board.d/01_leds
Normal file
70
target/linux/ipq806x/base-files/etc/board.d/01_leds
Normal file
@@ -0,0 +1,70 @@
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
buffalo,wxr-2533dhp)
|
||||
ucidef_set_led_wlan "wlan" "WLAN" "white:wireless" "phy0tpt"
|
||||
ucidef_set_led_switch "wan" "WAN" "white:internet" "switch0" "0x20"
|
||||
;;
|
||||
compex,wpq864)
|
||||
ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "pcie-usb" "PCIe USB" "green:usb-pcie" "usb3-port1"
|
||||
;;
|
||||
edgecore,ecw5410)
|
||||
ucidef_set_led_wlan "wlan2g" "WLAN2G" "green:wlan2g" "phy1tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "WLAN5G" "green:wlan5g" "phy0tpt"
|
||||
;;
|
||||
nec,wg2600hp)
|
||||
ucidef_set_led_wlan "wlan2g" "WLAN2G" "green:wlan2g" "phy1tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "WLAN5G" "green:wlan5g" "phy0tpt"
|
||||
ucidef_set_led_switch "wan" "WAN" "green:active" "switch0" "0x2"
|
||||
;;
|
||||
nec,wg2600hp3)
|
||||
ucidef_set_led_switch "wan" "WAN" "green:active" "switch0" "0x2"
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "white:usb1" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "white:usb2" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "wan" "WAN" "white:wan" "switch0" "0x20"
|
||||
ucidef_set_led_ide "esata" "eSATA" "white:esata"
|
||||
;;
|
||||
tplink,ad7200)
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "blue:usb1" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "blue:usb3" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x02"
|
||||
ucidef_set_led_switch "lan" "lan" "blue:lan" "switch0" "0x3c"
|
||||
ucidef_set_led_wlan "wlan2g" "wlan2g" "blue:wlan2g" "phy2tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "wlan5g" "blue:wlan5g" "phy1tpt"
|
||||
ucidef_set_led_netdev "wlan60g" "wlan60g" "blue:wlan60g" "wlan0"
|
||||
;;
|
||||
tplink,c2600)
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "white:usb_2" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "white:usb_4" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "wan" "wan" "white:wan" "switch0" "0x20"
|
||||
ucidef_set_led_switch "lan" "lan" "white:lan" "switch0" "0x1e"
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
ucidef_set_led_usbport "usb" "USB" "white:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "lan" "lan" "white:lan" "switch0" "0x1e"
|
||||
ucidef_set_led_wlan "wlan2g" "WLAN2G" "white:wlan2g" "phy0tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "WLAN5G" "white:wlan5g" "phy1tpt"
|
||||
ucidef_set_led_switch "wan" "wan" "white:wan" "switch0" "0x20"
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
ucidef_set_led_netdev "wan" "WAN" "white:internet" "eth1"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
98
target/linux/ipq806x/base-files/etc/board.d/02_network
Normal file
98
target/linux/ipq806x/base-files/etc/board.d/02_network
Normal file
@@ -0,0 +1,98 @@
|
||||
#
|
||||
# Copyright (c) 2015 The Linux Foundation. All rights reserved.
|
||||
# Copyright (c) 2011-2015 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
askey,rt4230w-rev6 |\
|
||||
asrock,g10 |\
|
||||
nec,wg2600hp)
|
||||
ucidef_add_switch "switch0" \
|
||||
"2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@eth0"
|
||||
;;
|
||||
buffalo,wxr-2533dhp |\
|
||||
compex,wpq864 |\
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
qcom,ipq8064-ap148 |\
|
||||
tplink,vr2600v)
|
||||
ucidef_add_switch "switch0" \
|
||||
"1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"
|
||||
;;
|
||||
edgecore,ecw5410)
|
||||
ucidef_set_interfaces_lan_wan "eth1" "eth0"
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
ucidef_set_interface_macaddr "lan" "$(mtd_get_mac_binary "0:art" 0x6)"
|
||||
ucidef_set_interface_macaddr "wan" "$(mtd_get_mac_binary "0:art" 0x0)"
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
ucidef_set_interface_macaddr "lan" "$(mtd_get_mac_binary "0:ART" 0x6)"
|
||||
ucidef_set_interface_macaddr "wan" "$(mtd_get_mac_binary "0:ART" 0x0)"
|
||||
fi
|
||||
;;
|
||||
linksys,ea7500-v1)
|
||||
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
ucidef_add_switch "switch0" \
|
||||
"2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6@eth1" "1:wan" "0@eth0"
|
||||
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
|
||||
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
|
||||
;;
|
||||
linksys,ea8500)
|
||||
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
ucidef_add_switch "switch0" \
|
||||
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
|
||||
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
|
||||
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
|
||||
;;
|
||||
nec,wg2600hp3)
|
||||
ucidef_add_switch "switch0" \
|
||||
"2:lan" "3:lan" "4:lan" "5:lan" "0@eth1" "1:wan" "6@eth0"
|
||||
;;
|
||||
netgear,r7800 |\
|
||||
tplink,c2600)
|
||||
ucidef_add_switch "switch0" \
|
||||
"1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "6@eth1" "5:wan" "0@eth0"
|
||||
;;
|
||||
qcom,ipq8064-ap161)
|
||||
ucidef_set_interface_lan "eth1 eth2"
|
||||
ucidef_add_switch "switch0" \
|
||||
"0:lan" "1:lan" "2:lan" "3u@eth1" "6:wan" "4u@eth0"
|
||||
;;
|
||||
qcom,ipq8064-db149)
|
||||
ucidef_set_interface_lan "eth1 eth2 eth3"
|
||||
ucidef_add_switch "switch0" \
|
||||
"1:lan" "2:lan" "3:lan" "4:lan" "6u@eth1" "5:wan" "0u@eth0"
|
||||
;;
|
||||
tplink,ad7200)
|
||||
ucidef_add_switch "switch0" \
|
||||
"2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6@eth1" "1:wan" "0@eth0"
|
||||
;;
|
||||
ubnt,unifi-ac-hd)
|
||||
ucidef_set_interface_lan "eth0 eth1"
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
hw_mac_addr=$(mtd_get_mac_ascii 0:appsblenv ethaddr)
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
[ -n "$hw_mac_addr" ] || \
|
||||
hw_mac_addr=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
|
||||
ucidef_add_switch "switch0" \
|
||||
"1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"
|
||||
ucidef_set_interface_macaddr "lan" "$(macaddr_add $hw_mac_addr 2)"
|
||||
ucidef_set_interface_macaddr "wan" "$(macaddr_add $hw_mac_addr 3)"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported hardware. Network interfaces not intialized"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,141 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -e /lib/firmware/$FIRMWARE ] && exit 0
|
||||
|
||||
. /lib/functions/caldata.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$FIRMWARE" in
|
||||
"ath10k/pre-cal-pci-0000:01:00.0.bin")
|
||||
case $board in
|
||||
askey,rt4230w-rev6)
|
||||
caldata_extract "0:ART" 0x1000 0x2f20
|
||||
;;
|
||||
asrock,g10)
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
caldata_extract "0:art" 0x1000 0x2f20
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
caldata_extract "0:ART" 0x1000 0x2f20
|
||||
fi
|
||||
;;
|
||||
buffalo,wxr-2533dhp)
|
||||
caldata_extract "ART" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e)
|
||||
;;
|
||||
edgecore,ecw5410)
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
caldata_extract "0:art" 0x1000 0x2f20
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
caldata_extract "0:ART" 0x1000 0x2f20
|
||||
fi
|
||||
;;
|
||||
linksys,ea7500-v1 |\
|
||||
linksys,ea8500)
|
||||
caldata_extract "art" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 1)
|
||||
;;
|
||||
nec,wg2600hp |\
|
||||
nec,wg2600hp3)
|
||||
caldata_extract "ART" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_binary PRODUCTDATA 0x12)
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
caldata_extract "art" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) 1)
|
||||
;;
|
||||
tplink,ad7200 |\
|
||||
tplink,c2600)
|
||||
caldata_extract "radio" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1)
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
caldata_extract "ART" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1)
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
caldata_extract "0:art" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:appsblenv ethaddr) 1)
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
caldata_extract "0:ART" 0x1000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) 1)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"ath10k/pre-cal-pci-0001:01:00.0.bin")
|
||||
case $board in
|
||||
askey,rt4230w-rev6)
|
||||
caldata_extract "0:ART" 0x5000 0x2f20
|
||||
;;
|
||||
asrock,g10)
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
caldata_extract "0:art" 0x5000 0x2f20
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
caldata_extract "0:ART" 0x5000 0x2f20
|
||||
fi
|
||||
;;
|
||||
buffalo,wxr-2533dhp)
|
||||
caldata_extract "ART" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_binary ART 0x18)
|
||||
;;
|
||||
linksys,ea7500-v1 |\
|
||||
linksys,ea8500)
|
||||
caldata_extract "art" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 2)
|
||||
;;
|
||||
nec,wg2600hp |\
|
||||
nec,wg2600hp3)
|
||||
caldata_extract "ART" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_binary PRODUCTDATA 0xc)
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
caldata_extract "art" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) 2)
|
||||
;;
|
||||
tplink,ad7200 |\
|
||||
tplink,c2600)
|
||||
caldata_extract "radio" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x8)
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
caldata_extract "ART" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x0)
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
caldata_extract "0:art" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_ascii 0:appsblenv ethaddr)
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
caldata_extract "0:ART" 0x5000 0x2f20
|
||||
ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"ath10k/pre-cal-pci-0002:01:00.0.bin")
|
||||
case $board in
|
||||
edgecore,ecw5410)
|
||||
if [ -b "$(find_mtd_part 0:art)" ]; then
|
||||
caldata_extract "0:art" 0x5000 0x2f20
|
||||
else
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
caldata_extract "0:ART" 0x5000 0x2f20
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/ash
|
||||
|
||||
[ "$ACTION" == "add" ] || exit 0
|
||||
|
||||
PHYNBR=${DEVPATH##*/phy}
|
||||
|
||||
[ -n $PHYNBR ] || exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
ubnt,unifi-ac-hd)
|
||||
macaddr_add $(mtd_get_mac_binary EEPROM 0x6) $(($PHYNBR + 1)) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
esac
|
||||
|
||||
OPATH=${DEVPATH##/devices/platform/}
|
||||
OPATH=${OPATH%%/ieee*}
|
||||
|
||||
# 10 radios is enough for anyone!
|
||||
for i in $(seq 0 9);
|
||||
do
|
||||
BUS=$(uci get wireless.@wifi-device[$i].path)
|
||||
if [ "$BUS " == "$OPATH " ]
|
||||
then
|
||||
PHYNAME=${DEVPATH##*ieee80211/}
|
||||
NPHYNAME=$(uci get wireless.@wifi-device[$i].phyname)
|
||||
if [ "$NPHYNAME " != " " ]
|
||||
then
|
||||
if [ "$PHYNAME " != "$NPHYNAME " ]
|
||||
then
|
||||
iw $PHYNAME set name $NPHYNAME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
28
target/linux/ipq806x/base-files/etc/init.d/bootcount
Executable file
28
target/linux/ipq806x/base-files/etc/init.d/bootcount
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
. "$IPKG_INSTROOT/lib/upgrade/asrock.sh"
|
||||
|
||||
boot() {
|
||||
case $(board_name) in
|
||||
asrock,g10)
|
||||
asrock_bootconfig_mangle "bootcheck" && reboot
|
||||
;;
|
||||
edgecore,ecw5410)
|
||||
fw_setenv bootcount 0
|
||||
;;
|
||||
linksys,ea7500-v1 |\
|
||||
linksys,ea8500)
|
||||
mtd resetbc s_env || true
|
||||
;;
|
||||
esac
|
||||
|
||||
echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
|
||||
echo 800000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
|
||||
echo 20 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
||||
echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
|
||||
|
||||
sysctl -w vm.min_free_kbytes=65536
|
||||
sysctl -w net.netfilter.nf_conntrack_max=32768
|
||||
}
|
||||
17
target/linux/ipq806x/base-files/etc/init.d/cpufreq
Executable file
17
target/linux/ipq806x/base-files/etc/init.d/cpufreq
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=15
|
||||
|
||||
boot() {
|
||||
local governor
|
||||
|
||||
governor=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor)
|
||||
|
||||
if [ "$governor" = "ondemand" ]; then
|
||||
# Effective only with ondemand
|
||||
echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
|
||||
echo 600000 > /sys/devices/system/cpu/cpufreq/policy1/scaling_min_freq
|
||||
echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
|
||||
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
||||
fi
|
||||
}
|
||||
4
target/linux/ipq806x/base-files/etc/inittab
Normal file
4
target/linux/ipq806x/base-files/etc/inittab
Normal file
@@ -0,0 +1,4 @@
|
||||
# Copyright (c) 2013 The Linux Foundation. All rights reserved.
|
||||
::sysinit:/etc/init.d/rcS S boot
|
||||
::shutdown:/etc/init.d/rcS K shutdown
|
||||
ttyMSM0::askfirst:/usr/libexec/login.sh
|
||||
@@ -0,0 +1,7 @@
|
||||
. /lib/functions/migrations.sh
|
||||
|
||||
remove_devicename_leds
|
||||
|
||||
migrations_apply system
|
||||
|
||||
exit 0
|
||||
13
target/linux/ipq806x/base-files/lib/preinit/04_reorder_eth
Normal file
13
target/linux/ipq806x/base-files/lib/preinit/04_reorder_eth
Normal file
@@ -0,0 +1,13 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
preinit_reorder_eth() {
|
||||
case $(board_name) in
|
||||
ubnt,unifi-ac-hd)
|
||||
ip link set eth0 name ethtmp
|
||||
ip link set eth1 name eth0
|
||||
ip link set ethtmp name eth1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_reorder_eth
|
||||
@@ -0,0 +1,14 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
preinit_set_mac_address() {
|
||||
case $(board_name) in
|
||||
asrock,g10)
|
||||
lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
|
||||
wan_mac=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address)
|
||||
ip link set dev eth0 address "${lan_mac}"
|
||||
ip link set dev eth1 address "${wan_mac}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_set_mac_address
|
||||
56
target/linux/ipq806x/base-files/lib/upgrade/asrock.sh
Normal file
56
target/linux/ipq806x/base-files/lib/upgrade/asrock.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
asrock_bootconfig_mangle() {
|
||||
local mtdnum="$(find_mtd_index 0:bootconfig)"
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
[ -n "$mtdnum" ] || mtdnum="$(find_mtd_index 0:BOOTCONFIG)"
|
||||
|
||||
if [ -z "$mtdnum" ]; then
|
||||
echo "cannot find bootconfig mtd partition"
|
||||
return 1
|
||||
fi
|
||||
dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k
|
||||
|
||||
local partition_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)"
|
||||
local upgrade_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)"
|
||||
|
||||
if [ $1 = "bootcheck" ]; then
|
||||
if [ ! -s $upgrade_byte ]; then
|
||||
dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k
|
||||
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4
|
||||
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
elif [ $1 = "sysupgrade" ]; then
|
||||
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4
|
||||
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56
|
||||
fi
|
||||
|
||||
if [ -s $partition_byte ]; then
|
||||
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52
|
||||
else
|
||||
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52
|
||||
fi
|
||||
|
||||
mtd write /tmp/mtd$mtdnum /dev/mtd$mtdnum
|
||||
return 0
|
||||
}
|
||||
|
||||
asrock_upgrade_prepare() {
|
||||
local ubidev="$( nand_find_ubi ubi )"
|
||||
|
||||
#Set upgrade flag. If something goes wrong, router will boot with
|
||||
#factory firmware.
|
||||
asrock_bootconfig_mangle 'sysupgrade'
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "cannot find bootconfig mtd partition"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Just delete these partitions if present and use
|
||||
# OpenWrt's standard names for those.
|
||||
ubirmvol /dev/$ubidev -N ubi_rootfs &> /dev/null || true
|
||||
ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true
|
||||
}
|
||||
44
target/linux/ipq806x/base-files/lib/upgrade/buffalo.sh
Normal file
44
target/linux/ipq806x/base-files/lib/upgrade/buffalo.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (C) 2018 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
# The mtd partition 'ubi' and 'rootfs_1' on NAND flash are os-image
|
||||
# partitions. These partitions are called as "Bank1/Bank2" in U-Boot
|
||||
# on WXR-2533DHP, and they are checked conditions when booting.
|
||||
# Then, U-Boot checks kernel and rootfs volumes in ubi, but U-Boot
|
||||
# needs "ubi_rootfs" as rootfs volume name. And, U-Boot checks the
|
||||
# checksum at the end of rootfs (ubi_rootfs).
|
||||
# When U-Boot writes os-image into the Bank, only kernel, rootfs
|
||||
# (ubi_rootfs) and rootfs_data (ubi_rootfs_data) volumes are wrote
|
||||
# into the Bank. (not full ubi image)
|
||||
#
|
||||
# == U-Boot Behaviors ==
|
||||
# - Bank1/Bank2 images are good, images are different
|
||||
# -> writes os-image to Bank1 from Bank2
|
||||
# (this behavior is used to firmware upgrade in stock firmware)
|
||||
# - Bank1 image is broken (or checksum error)
|
||||
# -> writes os-image to Bank1 from Bank2
|
||||
# - Bank2 image is broken (or checksum error)
|
||||
# -> writes os-image to Bank2 from Bank1
|
||||
# - Bank1/Bank2 images are broken (or checksum error)
|
||||
# -> start tftp
|
||||
|
||||
buffalo_upgrade_prepare_ubi() {
|
||||
local ubidev="$( nand_find_ubi ubi )"
|
||||
local mtdnum2="$( find_mtd_index rootfs_1 )"
|
||||
|
||||
if [ ! "$mtdnum2" ]; then
|
||||
echo "cannot find second ubi mtd partition rootfs_1"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ubidev2="$( nand_find_ubi rootfs_1 )"
|
||||
if [ ! "$ubidev2" ] && [ -n "$mtdnum2" ]; then
|
||||
ubiattach -m "$mtdnum2"
|
||||
ubidev2="$( nand_find_ubi rootfs_1 )"
|
||||
fi
|
||||
|
||||
ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true
|
||||
ubirmvol /dev/$ubidev2 -N kernel &> /dev/null || true
|
||||
}
|
||||
118
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
Normal file
118
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
Normal file
@@ -0,0 +1,118 @@
|
||||
#
|
||||
# Copyright (C) 2014-2015 OpenWrt.org
|
||||
#
|
||||
|
||||
linksys_get_target_firmware() {
|
||||
|
||||
local cur_boot_part mtd_ubi0
|
||||
|
||||
cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part)
|
||||
if [ -z "${cur_boot_part}" ] ; then
|
||||
mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num)
|
||||
case $(egrep ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in
|
||||
kernel1|rootfs1)
|
||||
cur_boot_part=1
|
||||
;;
|
||||
kernel2|rootfs2)
|
||||
cur_boot_part=2
|
||||
;;
|
||||
esac
|
||||
>&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \
|
||||
"${cur_boot_part}" "${mtd_ubi0}"
|
||||
fi
|
||||
|
||||
case $cur_boot_part in
|
||||
1)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 2
|
||||
auto_recovery yes
|
||||
EOF
|
||||
printf "kernel2"
|
||||
return
|
||||
;;
|
||||
2)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 1
|
||||
auto_recovery yes
|
||||
EOF
|
||||
printf "kernel1"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
# remove "squashfs" vol (in case we are flashing over a stock image, which is also UBI)
|
||||
|
||||
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
|
||||
if [ ! "$mtdnum" ]; then
|
||||
echo "cannot find ubi mtd partition $CI_UBIPART"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||
if [ ! "$ubidev" ]; then
|
||||
ubiattach -m "$mtdnum"
|
||||
sync
|
||||
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||
fi
|
||||
|
||||
if [ "$ubidev" ]; then
|
||||
|
||||
local squash_ubivol="$( nand_find_volume $ubidev squashfs )"
|
||||
|
||||
# kill volume
|
||||
[ "$squash_ubivol" ] && ubirmvol /dev/$ubidev -N squashfs || true
|
||||
fi
|
||||
|
||||
|
||||
# complete std upgrade
|
||||
nand_upgrade_tar "$1"
|
||||
}
|
||||
[ "$magic_long" = "27051956" ] && {
|
||||
# check firmwares' rootfs types
|
||||
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
|
||||
}
|
||||
}
|
||||
65
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Normal file
65
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Normal file
@@ -0,0 +1,65 @@
|
||||
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() {
|
||||
case "$(board_name)" in
|
||||
askey,rt4230w-rev6 |\
|
||||
compex,wpq864|\
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800 |\
|
||||
qcom,ipq8064-ap148 |\
|
||||
qcom,ipq8064-ap161)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
asrock,g10)
|
||||
asrock_upgrade_prepare
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
buffalo,wxr-2533dhp)
|
||||
buffalo_upgrade_prepare_ubi
|
||||
CI_ROOTPART="ubi_rootfs"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
edgecore,ecw5410)
|
||||
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
|
||||
if [ "$part" = "rootfs1" ]; then
|
||||
fw_setenv active 2 || exit 1
|
||||
CI_UBIPART="rootfs2"
|
||||
else
|
||||
fw_setenv active 1 || exit 1
|
||||
CI_UBIPART="rootfs1"
|
||||
fi
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
linksys,ea7500-v1 |\
|
||||
linksys,ea8500)
|
||||
platform_do_upgrade_linksys "$1"
|
||||
;;
|
||||
tplink,ad7200 |\
|
||||
tplink,c2600)
|
||||
PART_NAME="os-image:rootfs"
|
||||
MTD_CONFIG_ARGS="-s 0x200000"
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
PART_NAME="kernel:rootfs"
|
||||
MTD_CONFIG_ARGS="-s 0x200000"
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
zyxel_do_upgrade "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
127
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
Normal file
127
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
Normal file
@@ -0,0 +1,127 @@
|
||||
#
|
||||
# Copyright (C) 2016 lede-project.org
|
||||
#
|
||||
|
||||
zyxel_get_rootfs() {
|
||||
local rootfsdev
|
||||
|
||||
if read cmdline < /proc/cmdline; then
|
||||
case "$cmdline" in
|
||||
*root=*)
|
||||
rootfsdev="${cmdline##*root=}"
|
||||
rootfsdev="${rootfsdev%% *}"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${rootfsdev}"
|
||||
fi
|
||||
}
|
||||
|
||||
zyxel_do_flash() {
|
||||
local tar_file=$1
|
||||
local kernel=$2
|
||||
local rootfs=$3
|
||||
local dualflagmtd=$4
|
||||
|
||||
# keep sure its unbound
|
||||
losetup --detach-all || {
|
||||
echo Failed to detach all loop devices. Skip this try.
|
||||
reboot -f
|
||||
}
|
||||
|
||||
# use the first found directory in the tar archive
|
||||
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
echo "flashing kernel to $kernel"
|
||||
tar xf $tar_file ${board_dir}/kernel -O >$kernel
|
||||
|
||||
echo "flashing rootfs to ${rootfs}"
|
||||
tar xf $tar_file ${board_dir}/root -O >"${rootfs}"
|
||||
|
||||
# a padded rootfs is needed for overlay fs creation
|
||||
local offset=$(tar xf $tar_file ${board_dir}/root -O | wc -c)
|
||||
[ $offset -lt 65536 ] && {
|
||||
echo Wrong size for rootfs: $offset
|
||||
sleep 10
|
||||
reboot -f
|
||||
}
|
||||
|
||||
# Mount loop for rootfs_data
|
||||
local loopdev="$(losetup -f)"
|
||||
losetup -o $offset $loopdev $rootfs || {
|
||||
echo "Failed to mount looped rootfs_data."
|
||||
sleep 10
|
||||
reboot -f
|
||||
}
|
||||
|
||||
echo "Format new rootfs_data at position ${offset}."
|
||||
mkfs.ext4 -F -L rootfs_data $loopdev
|
||||
mkdir /tmp/new_root
|
||||
mount -t ext4 $loopdev /tmp/new_root && {
|
||||
echo "Saving config to rootfs_data at position ${offset}."
|
||||
cp -v "$UPGRADE_BACKUP" "/tmp/new_root/$BACKUP_FILE"
|
||||
umount /tmp/new_root
|
||||
}
|
||||
|
||||
# flashing successful, toggle the dualflag
|
||||
case "$rootfs" in
|
||||
"/dev/mmcblk0p5")
|
||||
printf "\xff" >$dualflagmtd
|
||||
;;
|
||||
"/dev/mmcblk0p8")
|
||||
printf "\x01" >$dualflagmtd
|
||||
;;
|
||||
esac
|
||||
|
||||
# Cleanup
|
||||
losetup -d $loopdev >/dev/null 2>&1
|
||||
sync
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
|
||||
zyxel_do_upgrade() {
|
||||
local tar_file="$1"
|
||||
local board=$(board_name)
|
||||
local rootfs="$(zyxel_get_rootfs)"
|
||||
local kernel=
|
||||
|
||||
[ -b "${rootfs}" ] || return 1
|
||||
case "$board" in
|
||||
zyxel,nbg6817)
|
||||
local dualflagmtd="$(find_mtd_part 0:dual_flag)"
|
||||
# XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
|
||||
[ -b $dualflagmtd ] || \
|
||||
dualflagmtd="$(find_mtd_part 0:DUAL_FLAG)"
|
||||
[ -b $dualflagmtd ] || return 1
|
||||
|
||||
case "$rootfs" in
|
||||
"/dev/mmcblk0p5")
|
||||
# booted from the primary partition set
|
||||
# write to the alternative set
|
||||
kernel="/dev/mmcblk0p7"
|
||||
rootfs="/dev/mmcblk0p8"
|
||||
;;
|
||||
"/dev/mmcblk0p8")
|
||||
# booted from the alternative partition set
|
||||
# write to the primary set
|
||||
kernel="/dev/mmcblk0p4"
|
||||
rootfs="/dev/mmcblk0p5"
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
|
||||
|
||||
nand_do_upgrade "$1"
|
||||
|
||||
return 0
|
||||
}
|
||||
15
target/linux/ipq806x/base-files/sbin/asrock_g10_back_to_factory
Executable file
15
target/linux/ipq806x/base-files/sbin/asrock_g10_back_to_factory
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/upgrade/asrock.sh
|
||||
|
||||
case $(board_name) in
|
||||
asrock,g10)
|
||||
asrock_bootconfig_mangle "factory"
|
||||
if [ $? -eq 0 ]; then
|
||||
reboot
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported hardware."
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user