mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
修复下led还有ipq40xx的中断优化
This commit is contained in:
parent
6083c17a63
commit
85ca80be4a
9 changed files with 446 additions and 20 deletions
90
root/target/linux/ipq40xx/base-files/etc/board.d/01_leds
Normal file
90
root/target/linux/ipq40xx/base-files/etc/board.d/01_leds
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015 OpenWrt.org
|
||||||
|
#
|
||||||
|
|
||||||
|
. /lib/functions/uci-defaults.sh
|
||||||
|
|
||||||
|
board_config_update
|
||||||
|
|
||||||
|
board=$(board_name)
|
||||||
|
boardname="${board##*,}"
|
||||||
|
|
||||||
|
case "$board" in
|
||||||
|
alfa-network,ap120c-ac)
|
||||||
|
ucidef_set_led_netdev "wan" "WAN" "${boardname}:amber:wan" "eth1"
|
||||||
|
;;
|
||||||
|
asus,rt-ac58u)
|
||||||
|
ucidef_set_led_netdev "wan" "WAN" "${boardname}:blue:wan" "eth1"
|
||||||
|
ucidef_set_led_switch "lan" "LAN" "${boardname}:blue:lan" "switch0" "0x1e"
|
||||||
|
;;
|
||||||
|
asus,rt-acrh17)
|
||||||
|
ucidef_set_led_default "status" "STATUS" "${boardname}:blue:status" "1"
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2g" "phy1tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:blue:wlan5g" "phy0tpt"
|
||||||
|
ucidef_set_led_netdev "wan" "WAN" "${boardname}:blue:wan" "eth1"
|
||||||
|
ucidef_set_led_switch "lan1" "LAN1" "${boardname}:blue:lan1" "switch0" "0x02"
|
||||||
|
ucidef_set_led_switch "lan2" "LAN2" "${boardname}:blue:lan2" "switch0" "0x04"
|
||||||
|
ucidef_set_led_switch "lan3" "LAN3" "${boardname}:blue:lan3" "switch0" "0x08"
|
||||||
|
ucidef_set_led_switch "lan4" "LAN4" "${boardname}:blue:lan4" "switch0" "0x10"
|
||||||
|
;;
|
||||||
|
avm,fritzbox-4040)
|
||||||
|
ucidef_set_led_wlan "wlan" "WLAN" "fritz4040:green:wlan" "phy0tpt" "phy1tpt"
|
||||||
|
ucidef_set_led_netdev "wan" "WAN" "fritz4040:green:wan" "eth1"
|
||||||
|
ucidef_set_led_switch "lan" "LAN" "fritz4040:green:lan" "switch0" "0x1e"
|
||||||
|
;;
|
||||||
|
avm,fritzbox-7530 |\
|
||||||
|
glinet,gl-b1300)
|
||||||
|
ucidef_set_led_wlan "wlan" "WLAN" "${boardname}:green:wlan" "phy0tpt"
|
||||||
|
;;
|
||||||
|
engenius,eap1300)
|
||||||
|
ucidef_set_led_netdev "lan" "LAN" "${boardname}:blue:lan" "eth0"
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2g" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:yellow:wlan5g" "phy1tpt"
|
||||||
|
ucidef_set_led_default "mesh" "MESH" "${boardname}:blue:mesh" "0"
|
||||||
|
;;
|
||||||
|
engenius,eap2200)
|
||||||
|
ucidef_set_led_netdev "lan1" "LAN1" "${boardname}:blue:lan1" "eth0"
|
||||||
|
ucidef_set_led_netdev "lan2" "LAN2" "${boardname}:blue:lan2" "eth1"
|
||||||
|
;;
|
||||||
|
engenius,ens620ext)
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2G" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5G" "phy1tpt"
|
||||||
|
ucidef_set_led_netdev "lan1" "LAN1" "${boardname}:green:lan1" "eth0"
|
||||||
|
ucidef_set_led_netdev "lan2" "LAN2" "${boardname}:green:lan2" "eth1"
|
||||||
|
;;
|
||||||
|
mobipromo,cm520-79f)
|
||||||
|
ucidef_set_led_netdev "wan" "WAN" "${boardname}:blue:wan" "eth1"
|
||||||
|
ucidef_set_led_switch "lan1" "LAN1" "${boardname}:blue:lan1" "switch0" "0x10"
|
||||||
|
ucidef_set_led_switch "lan2" "LAN2" "${boardname}:blue:lan2" "switch0" "0x08"
|
||||||
|
;;
|
||||||
|
netgear,ex6100v2 |\
|
||||||
|
netgear,ex6150v2)
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "ex61x0v2:green:router" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "ex61x0v2:green:client" "phy1tpt"
|
||||||
|
;;
|
||||||
|
p2w,r619ac |\
|
||||||
|
p2w,r619ac-128m)
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "r619ac:blue:wlan2g" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "r619ac:blue:wlan5g" "phy1tpt"
|
||||||
|
;;
|
||||||
|
qxwlan,e2600ac-c1 |\
|
||||||
|
qxwlan,e2600ac-c2)
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN0" "e2600ac:green:wlan0" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN1" "e2600ac:green:wlan1" "phy1tpt"
|
||||||
|
;;
|
||||||
|
zyxel,nbg6617)
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2G" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5G" "phy1tpt"
|
||||||
|
;;
|
||||||
|
zyxel,wre6606)
|
||||||
|
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" "phy0tpt"
|
||||||
|
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5g" "phy1tpt"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
board_config_flush
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/functions/uci-defaults.sh
|
||||||
|
|
||||||
|
board_config_update
|
||||||
|
|
||||||
|
board=$(board_name)
|
||||||
|
|
||||||
|
case "$board" in
|
||||||
|
cellc,rtl30vw)
|
||||||
|
ucidef_add_gpio_switch "w_disable" "W_DISABLE mPCIE pin" "398" "1"
|
||||||
|
ucidef_add_gpio_switch "pmd_resin_n" "PMD_RESIN_N pin" "399" "1"
|
||||||
|
ucidef_add_gpio_switch "mcpie_vcc" "LTE power" "400" "0"
|
||||||
|
ucidef_add_gpio_switch "usb_vcc" "USB power" "401" "0"
|
||||||
|
;;
|
||||||
|
cilab,meshpoint-one)
|
||||||
|
ucidef_add_gpio_switch "poe_passtrough" "POE passtrough enable" "413" "1"
|
||||||
|
;;
|
||||||
|
compex,wpj428)
|
||||||
|
ucidef_add_gpio_switch "sim_card_select" "SIM card select" "3" "0"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
board_config_flush
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
[ -f /lib/adjust_network.sh ] && {
|
||||||
|
. /lib/adjust_network.sh
|
||||||
|
|
||||||
|
adjust_eth_queue
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2006-2011 OpenWrt.org
|
||||||
|
|
||||||
|
START=11
|
||||||
|
STOP=98
|
||||||
|
|
||||||
|
adjust_smp_affinity() {
|
||||||
|
test -f /lib/adjust_network.sh && {
|
||||||
|
. /lib/adjust_network.sh
|
||||||
|
|
||||||
|
adjust_eth_queue
|
||||||
|
adjust_edma_smp_affinity
|
||||||
|
adjust_radio_smp_affinity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
adjust_smp_affinity
|
||||||
|
}
|
16
root/target/linux/ipq40xx/base-files/etc/init.d/bootcount
Normal file
16
root/target/linux/ipq40xx/base-files/etc/init.d/bootcount
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=99
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
case $(board_name) in
|
||||||
|
alfa-network,ap120c-ac)
|
||||||
|
[ -n "$(fw_printenv bootcount changed 2>/dev/null)" ] &&\
|
||||||
|
echo -e "bootcount\nchanged\n" | /usr/sbin/fw_setenv -s -
|
||||||
|
;;
|
||||||
|
linksys,ea6350v3|\
|
||||||
|
linksys,ea8300)
|
||||||
|
mtd resetbc s_env || true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
89
root/target/linux/ipq40xx/base-files/lib/adjust_network.sh
Normal file
89
root/target/linux/ipq40xx/base-files/lib/adjust_network.sh
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# this scripts is used for adjust cpu's choice of interrupts.
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Adjust smp_affinity of edma
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
# Remark:
|
||||||
|
# execute only once on start-up.
|
||||||
|
################################################
|
||||||
|
adjust_edma_smp_affinity() {
|
||||||
|
grep -q edma_eth_ /proc/interrupts || return 0
|
||||||
|
local nr=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||||
|
local cpu=0
|
||||||
|
local tx_irq_num
|
||||||
|
|
||||||
|
for tx_num in `seq 0 1 15` ; do
|
||||||
|
cpu=`printf "%x" $((1<<((tx_num/4+0)%nr)))`
|
||||||
|
tx_irq_num=`grep -m1 edma_eth_tx$tx_num /proc/interrupts | cut -d ':' -f 1 | tail -n1 | tr -d ' '`
|
||||||
|
[ -n "$tx_irq_num" ] && echo $cpu > /proc/irq/$tx_irq_num/smp_affinity
|
||||||
|
done
|
||||||
|
|
||||||
|
for rx_num in `seq 0 1 7` ; do
|
||||||
|
cpu=`printf "%x" $((1<<((rx_num/2)%nr)))`
|
||||||
|
rx_irq_num=`grep -m1 edma_eth_rx$rx_num /proc/interrupts | cut -d ':' -f 1 | tail -n1 | tr -d ' '`
|
||||||
|
[ -n "$rx_irq_num" ] && echo $cpu > /proc/irq/$rx_irq_num/smp_affinity
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Adjust smp_affinity of ath10k for 2G and 5G
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
# Remark:
|
||||||
|
# execute only once on start-up.
|
||||||
|
################################################
|
||||||
|
adjust_radio_smp_affinity() {
|
||||||
|
local irqs="`grep -E 'ath10k' /proc/interrupts | cut -d ':' -f 1 | tr -d ' '`"
|
||||||
|
local nr=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||||
|
local idx=2
|
||||||
|
|
||||||
|
for irq in $irqs; do
|
||||||
|
cpu=`printf "%x" $((1<<((idx)%nr)))`
|
||||||
|
echo $cpu > /proc/irq/$irq/smp_affinity
|
||||||
|
idx=$((idx+1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Adjust queue of eth
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
# Remark:
|
||||||
|
# Each network reboot needs to be executed.
|
||||||
|
################################################
|
||||||
|
adjust_eth_queue() {
|
||||||
|
local nr=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||||
|
local idx=0
|
||||||
|
|
||||||
|
for epath in /sys/class/net/eth[0-9]*; do
|
||||||
|
test -e $epath || break
|
||||||
|
echo $epath | grep -q "\." && continue
|
||||||
|
eth=`basename $epath`
|
||||||
|
idx=0
|
||||||
|
for exps in /sys/class/net/$eth/queues/rx-[0-9]*/rps_cpus; do
|
||||||
|
test -e $exps || break
|
||||||
|
cpu=`printf "%x" $((1<<((idx+1)%nr)))`
|
||||||
|
idx=$((idx+1))
|
||||||
|
echo $cpu > $exps
|
||||||
|
echo 256 > `dirname $exps`/rps_flow_cnt
|
||||||
|
done
|
||||||
|
which ethtool >/dev/null 2>&1 && ethtool -K $eth gro off
|
||||||
|
done
|
||||||
|
|
||||||
|
echo 1024 > /proc/sys/net/core/rps_sock_flow_entries
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
preinit_set_mac_address() {
|
||||||
|
case $(board_name) in
|
||||||
|
asus,map-ac2200)
|
||||||
|
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
|
||||||
|
ip link set dev eth0 address $(macaddr_add "$base_mac" +1)
|
||||||
|
ip link set dev eth1 address $(macaddr_add "$base_mac" +3)
|
||||||
|
;;
|
||||||
|
asus,rt-acrh17|\
|
||||||
|
asus,rt-ac58u)
|
||||||
|
CI_UBIPART=UBI_DEV
|
||||||
|
base_mac=$(mtd_get_mac_binary_ubi Factory 4102)
|
||||||
|
ip link set dev eth0 address $(macaddr_add "$base_mac" +1)
|
||||||
|
;;
|
||||||
|
ezviz,cs-w3-wd1200g-eup)
|
||||||
|
ip link set dev eth0 address $(mtd_get_mac_binary "ART" 0x6)
|
||||||
|
ip link set dev eth1 address $(mtd_get_mac_binary "ART" 0x0)
|
||||||
|
;;
|
||||||
|
engenius,eap2200)
|
||||||
|
base_mac=$(cat /sys/class/net/eth0/address)
|
||||||
|
ip link set dev eth1 address $(macaddr_add "${base_mac}" +1)
|
||||||
|
;;
|
||||||
|
linksys,ea8300)
|
||||||
|
base_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||||
|
ip link set dev eth0 address "${base_mac}"
|
||||||
|
ip link set dev eth1 address $(macaddr_add "${base_mac}" 1)
|
||||||
|
;;
|
||||||
|
meraki,mr33)
|
||||||
|
mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
|
||||||
|
[ -n "$mac_lan" ] && ip link set dev eth0 address "$mac_lan"
|
||||||
|
;;
|
||||||
|
zyxel,nbg6617)
|
||||||
|
base_mac=$(cat /sys/class/net/eth0/address)
|
||||||
|
ip link set dev eth0 address $(macaddr_add "$base_mac" +2)
|
||||||
|
ip link set dev eth1 address $(macaddr_add "$base_mac" +3)
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
boot_hook_add preinit_main preinit_set_mac_address
|
|
@ -0,0 +1,20 @@
|
||||||
|
set_preinit_iface() {
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
case $(board_name) in
|
||||||
|
aruba,ap-303| \
|
||||||
|
asus,rt-ac58u| \
|
||||||
|
avm,fritzbox-4040| \
|
||||||
|
ezviz,cs-w3-wd1200g-eup| \
|
||||||
|
glinet,gl-b1300| \
|
||||||
|
linksys,ea8300| \
|
||||||
|
meraki,mr33| \
|
||||||
|
zyxel,nbg6617)
|
||||||
|
ifname=eth0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
boot_hook_add preinit_main set_preinit_iface
|
|
@ -4,28 +4,141 @@ REQUIRE_IMAGE_METADATA=1
|
||||||
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||||
|
|
||||||
platform_check_image() {
|
ubi_kill_if_exist() {
|
||||||
case "$(board_name)" in
|
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||||
asus,rt-ac58u)
|
local c_ubivol="$( nand_find_volume $ubidev $1 )"
|
||||||
CI_UBIPART="UBI_DEV"
|
umount -f /dev/$c_ubivol 2>/dev/null
|
||||||
local ubidev=$(nand_find_ubi $CI_UBIPART)
|
[ "$c_ubivol" ] && ubirmvol /dev/$ubidev -N $1 || true
|
||||||
local asus_root=$(nand_find_volume $ubidev jffs2)
|
echo "Partition $1 removed."
|
||||||
|
}
|
||||||
|
|
||||||
[ -n "$asus_root" ] || return 0
|
# idea from @981213
|
||||||
|
# Tar sysupgrade for ASUS RT-AC82U/RT-AC58U
|
||||||
|
# An ubi repartition is required due to the strange partition table created by Asus.
|
||||||
|
# We create all the factory partitions to make sure that the U-boot tftp recovery still works.
|
||||||
|
# The reserved kernel partition size should be enough to put the factory image in.
|
||||||
|
asus_nand_upgrade_tar() {
|
||||||
|
local kpart_size="$1"
|
||||||
|
local tar_file="$2"
|
||||||
|
|
||||||
cat << EOF
|
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||||
jffs2 partition is still present.
|
board_dir=${board_dir%/}
|
||||||
There's probably no space left
|
|
||||||
to install the filesystem.
|
|
||||||
|
|
||||||
You need to delete the jffs2 partition first:
|
local kernel_length=`(tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null`
|
||||||
# ubirmvol /dev/ubi0 --name=jffs2
|
local rootfs_length=`(tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null`
|
||||||
|
|
||||||
Once this is done. Retry.
|
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
|
||||||
EOF
|
if [ ! "$mtdnum" ]; then
|
||||||
|
echo "cannot find ubi mtd partition $CI_UBIPART"
|
||||||
return 1
|
return 1
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
|
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||||
|
if [ ! "$ubidev" ]; then
|
||||||
|
ubiattach -m "$mtdnum"
|
||||||
|
sync
|
||||||
|
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! "$ubidev" ]; then
|
||||||
|
echo "cannot find ubi device $CI_UBIPART"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local root_ubivol="$( nand_find_volume $ubidev rootfs )"
|
||||||
|
# remove ubiblock device of rootfs
|
||||||
|
local root_ubiblk="ubiblock${root_ubivol:3}"
|
||||||
|
if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then
|
||||||
|
echo "removing $root_ubiblk"
|
||||||
|
if ! ubiblock -r /dev/$root_ubivol; then
|
||||||
|
echo "cannot remove $root_ubiblk"
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
ubi_kill_if_exist rootfs_data
|
||||||
|
ubi_kill_if_exist rootfs
|
||||||
|
ubi_kill_if_exist jffs2
|
||||||
|
ubi_kill_if_exist linux2
|
||||||
|
ubi_kill_if_exist linux
|
||||||
|
|
||||||
|
ubimkvol /dev/$ubidev -N linux -s $kpart_size
|
||||||
|
ubimkvol /dev/$ubidev -N linux2 -s $kpart_size
|
||||||
|
ubimkvol /dev/$ubidev -N jffs2 -s 2539520
|
||||||
|
ubimkvol /dev/$ubidev -N rootfs -s $rootfs_length
|
||||||
|
ubimkvol /dev/$ubidev -N rootfs_data -m
|
||||||
|
|
||||||
|
local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)"
|
||||||
|
echo "Kernel at $kern_ubivol.Writing..."
|
||||||
|
tar xf $tar_file ${board_dir}/kernel -O | \
|
||||||
|
ubiupdatevol /dev/$kern_ubivol -s $kernel_length -
|
||||||
|
echo "Done."
|
||||||
|
|
||||||
|
local root_ubivol="$(nand_find_volume $ubidev rootfs)"
|
||||||
|
echo "Rootfs at $root_ubivol.Writing..."
|
||||||
|
tar xf $tar_file ${board_dir}/root -O | \
|
||||||
|
ubiupdatevol /dev/$root_ubivol -s $rootfs_length -
|
||||||
|
echo "Done."
|
||||||
|
|
||||||
|
nand_do_upgrade_success
|
||||||
|
}
|
||||||
|
|
||||||
|
# idea from @981213
|
||||||
|
# Factory image sysupgrade for ASUS RT-AC82U/RT-AC58U
|
||||||
|
# Delete all the partitions we created before, create "linux" partition and write factory image in.
|
||||||
|
# Skip the first 64bytes which is an uImage header to verify the firmware.
|
||||||
|
# The kernel partition size should be the original one.
|
||||||
|
asus_nand_upgrade_factory() {
|
||||||
|
local kpart_size="$1"
|
||||||
|
local fw_file="$2"
|
||||||
|
|
||||||
|
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
|
||||||
|
echo "cannot find ubi device $CI_UBIPART"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local root_ubivol="$( nand_find_volume $ubidev rootfs )"
|
||||||
|
# remove ubiblock device of rootfs
|
||||||
|
local root_ubiblk="ubiblock${root_ubivol:3}"
|
||||||
|
if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then
|
||||||
|
echo "removing $root_ubiblk"
|
||||||
|
if ! ubiblock -r /dev/$root_ubivol; then
|
||||||
|
echo "cannot remove $root_ubiblk"
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
ubi_kill_if_exist rootfs_data
|
||||||
|
ubi_kill_if_exist rootfs
|
||||||
|
ubi_kill_if_exist jffs2
|
||||||
|
ubi_kill_if_exist linux2
|
||||||
|
ubi_kill_if_exist linux
|
||||||
|
|
||||||
|
ubimkvol /dev/$ubidev -N linux -s $kpart_size
|
||||||
|
|
||||||
|
local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)"
|
||||||
|
echo "Asus linux at $kern_ubivol.Writing..."
|
||||||
|
ubiupdatevol /dev/$kern_ubivol --skip=64 $fw_file
|
||||||
|
echo "Done."
|
||||||
|
|
||||||
|
umount -a
|
||||||
|
reboot -f
|
||||||
|
}
|
||||||
|
|
||||||
|
platform_check_image() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +177,6 @@ platform_do_upgrade() {
|
||||||
avm,fritzbox-7530 |\
|
avm,fritzbox-7530 |\
|
||||||
avm,fritzrepeater-1200 |\
|
avm,fritzrepeater-1200 |\
|
||||||
avm,fritzrepeater-3000 |\
|
avm,fritzrepeater-3000 |\
|
||||||
buffalo,wtr-m2133hp |\
|
|
||||||
cilab,meshpoint-one |\
|
cilab,meshpoint-one |\
|
||||||
engenius,eap2200 |\
|
engenius,eap2200 |\
|
||||||
mobipromo,cm520-79f |\
|
mobipromo,cm520-79f |\
|
||||||
|
@ -86,10 +198,17 @@ platform_do_upgrade() {
|
||||||
CI_KERNPART="linux"
|
CI_KERNPART="linux"
|
||||||
nand_do_upgrade "$1"
|
nand_do_upgrade "$1"
|
||||||
;;
|
;;
|
||||||
|
asus,rt-acrh17|\
|
||||||
asus,rt-ac58u)
|
asus,rt-ac58u)
|
||||||
|
local magic=$(get_magic_long "$1")
|
||||||
CI_UBIPART="UBI_DEV"
|
CI_UBIPART="UBI_DEV"
|
||||||
CI_KERNPART="linux"
|
CI_KERNPART="linux"
|
||||||
nand_do_upgrade "$1"
|
if [ "$magic" == "27051956" ]; then
|
||||||
|
echo "Got Asus factory image."
|
||||||
|
asus_nand_upgrade_factory 50409472 "$1"
|
||||||
|
else
|
||||||
|
asus_nand_upgrade_tar 20951040 "$1"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
cellc,rtl30vw)
|
cellc,rtl30vw)
|
||||||
CI_UBIPART="ubifs"
|
CI_UBIPART="ubifs"
|
||||||
|
@ -120,4 +239,4 @@ platform_do_upgrade() {
|
||||||
default_do_upgrade "$1"
|
default_do_upgrade "$1"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue