Initial commit
This commit is contained in:
58
target/linux/ipq806x/base-files/etc/board.d/01_leds
Executable file
58
target/linux/ipq806x/base-files/etc/board.d/01_leds
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
boardname="${board##*,}"
|
||||
|
||||
case "$board" in
|
||||
buffalo,wxr-2533dhp)
|
||||
ucidef_set_led_wlan "wlan" "WLAN" "${boardname}:white:wireless" "phy0tpt"
|
||||
ucidef_set_led_switch "wan" "WAN" "${boardname}:white:internet" "switch0" "0x20"
|
||||
;;
|
||||
compex,wpq864)
|
||||
ucidef_set_led_usbport "usb" "USB" "wpq864:green:usb" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "pcie-usb" "PCIe USB" "wpq864:green:usb-pcie" "usb3-port1"
|
||||
;;
|
||||
nec,wg2600hp)
|
||||
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" "phy1tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5g" "phy0tpt"
|
||||
ucidef_set_led_switch "wan" "WAN" "${boardname}:green:active" "switch0" "0x2"
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "${boardname}:white:usb1" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "${boardname}:white:usb2" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "wan" "WAN" "${boardname}:white:wan" "switch0" "0x20"
|
||||
ucidef_set_led_ide "esata" "eSATA" "${boardname}:white:esata"
|
||||
;;
|
||||
tplink,c2600)
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "${boardname}:white:usb_2" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "${boardname}:white:usb_4" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "wan" "wan" "${boardname}:white:wan" "switch0" "0x20"
|
||||
ucidef_set_led_switch "lan" "lan" "${boardname}:white:lan" "switch0" "0x1e"
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
ucidef_set_led_usbport "usb" "USB" "${boardname}:white:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
|
||||
ucidef_set_led_switch "lan" "lan" "${boardname}:white:lan" "switch0" "0x1e"
|
||||
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:white:wlan2g" "phy0tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:white:wlan5g" "phy1tpt"
|
||||
ucidef_set_led_switch "wan" "wan" "${boardname}:white:wan" "switch0" "0x20"
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
ucidef_set_led_netdev "wan" "WAN" "${boardname}:white:internet" "eth1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
65
target/linux/ipq806x/base-files/etc/board.d/02_network
Executable file
65
target/linux/ipq806x/base-files/etc/board.d/02_network
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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
|
||||
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"
|
||||
;;
|
||||
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"
|
||||
;;
|
||||
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,wg2600hp)
|
||||
ucidef_add_switch "switch0" \
|
||||
"2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@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-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"
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
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,151 @@
|
||||
#!/bin/sh
|
||||
|
||||
# xor multiple hex values of the same length
|
||||
xor() {
|
||||
local val
|
||||
local ret="0x$1"
|
||||
local retlen=${#1}
|
||||
|
||||
shift
|
||||
while [ -n "$1" ]; do
|
||||
val="0x$1"
|
||||
ret=$((ret ^ val))
|
||||
shift
|
||||
done
|
||||
|
||||
printf "%0${retlen}x" "$ret"
|
||||
}
|
||||
|
||||
ath10kcal_die() {
|
||||
echo "ath10cal: " "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ath10kcal_from_file() {
|
||||
local source=$1
|
||||
local offset=$2
|
||||
local count=$3
|
||||
|
||||
dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
|
||||
ath10kcal_die "failed to extract calibration data from $source"
|
||||
}
|
||||
|
||||
ath10kcal_extract() {
|
||||
local part=$1
|
||||
local offset=$2
|
||||
local count=$3
|
||||
local mtd
|
||||
|
||||
mtd=$(find_mtd_chardev $part)
|
||||
[ -n "$mtd" ] || \
|
||||
ath10kcal_die "no mtd device found for partition $part"
|
||||
|
||||
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
|
||||
ath10kcal_die "failed to extract calibration data from $mtd"
|
||||
}
|
||||
|
||||
ath10kcal_patch_mac_crc() {
|
||||
local mac=$1
|
||||
local mac_offset=6
|
||||
local chksum_offset=2
|
||||
local xor_mac
|
||||
local xor_fw_mac
|
||||
local xor_fw_chksum
|
||||
|
||||
[ -z "$mac" ] && return
|
||||
|
||||
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
|
||||
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
|
||||
|
||||
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
|
||||
|
||||
xor_mac=${mac//:/}
|
||||
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
|
||||
|
||||
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
|
||||
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
|
||||
|
||||
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
|
||||
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
|
||||
}
|
||||
|
||||
[ -e /lib/firmware/$FIRMWARE ] && exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$FIRMWARE" in
|
||||
"ath10k/pre-cal-pci-0000:01:00.0.bin")
|
||||
case $board in
|
||||
buffalo,wxr-2533dhp)
|
||||
ath10kcal_extract "ART" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 30)
|
||||
;;
|
||||
linksys,ea8500)
|
||||
ath10kcal_extract "art" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
|
||||
;;
|
||||
nec,wg2600hp)
|
||||
ath10kcal_extract "ART" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) +1)
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
ath10kcal_extract "art" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +1)
|
||||
;;
|
||||
tplink,c2600)
|
||||
ath10kcal_extract "radio" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
ath10kcal_extract "ART" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0) -1)
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
ath10kcal_extract "0:ART" 4096 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"ath10k/pre-cal-pci-0001:01:00.0.bin")
|
||||
case $board in
|
||||
buffalo,wxr-2533dhp)
|
||||
ath10kcal_extract "ART" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 24)
|
||||
;;
|
||||
linksys,ea8500)
|
||||
ath10kcal_extract "art" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
|
||||
;;
|
||||
nec,wg2600hp)
|
||||
ath10kcal_extract "ART" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(mtd_get_mac_binary PRODUCTDATA 12)
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
ath10kcal_extract "art" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +2)
|
||||
;;
|
||||
tplink,c2600)
|
||||
ath10kcal_extract "radio" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 8)
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
ath10kcal_extract "ART" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0)
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
ath10kcal_extract "0:ART" 20480 12064
|
||||
ath10kcal_patch_mac_crc $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/ash
|
||||
|
||||
[ "$ACTION" == "add" ] || exit 0
|
||||
|
||||
PHYNBR=${DEVPATH##*/phy}
|
||||
|
||||
[ -n $PHYNBR ] || exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
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
|
||||
13
target/linux/ipq806x/base-files/etc/init.d/bootcount
Executable file
13
target/linux/ipq806x/base-files/etc/init.d/bootcount
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
start() {
|
||||
. /lib/functions.sh
|
||||
|
||||
case $(board_name) in
|
||||
linksys,ea8500)
|
||||
mtd resetbc s_env || true
|
||||
;;
|
||||
esac
|
||||
}
|
||||
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
|
||||
45
target/linux/ipq806x/base-files/lib/upgrade/buffalo.sh
Normal file
45
target/linux/ipq806x/base-files/lib/upgrade/buffalo.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# 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
|
||||
}
|
||||
}
|
||||
54
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Normal file
54
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
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
|
||||
buffalo,wxr-2533dhp)
|
||||
buffalo_upgrade_prepare_ubi
|
||||
CI_ROOTPART="ubi_rootfs"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
compex,wpq864|\
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800 |\
|
||||
qcom,ipq8064-ap148 |\
|
||||
qcom,ipq8064-ap161 |\
|
||||
zyxel,nbg6817)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
linksys,ea8500)
|
||||
platform_do_upgrade_linksys "$1"
|
||||
;;
|
||||
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"
|
||||
;;
|
||||
nec,wg2600hp |\
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_nand_pre_upgrade() {
|
||||
case "$(board_name)" in
|
||||
zyxel,nbg6817)
|
||||
zyxel_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
122
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
Normal file
122
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
Normal file
@@ -0,0 +1,122 @@
|
||||
#
|
||||
# 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)"
|
||||
[ -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
|
||||
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user