Initial commit
This commit is contained in:
56
target/linux/ipq806x/base-files/etc/board.d/01_leds
Executable file
56
target/linux/ipq806x/base-files/etc/board.d/01_leds
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
boardname="${board##*,}"
|
||||
|
||||
case "$board" in
|
||||
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" "0x1e"
|
||||
;;
|
||||
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_netdev "wan" "WAN" "${boardname}:white:wan" "eth0"
|
||||
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_wlan "wlan2g" "WLAN2G" "${boardname}:amber:wifi2g" "phy1tpt"
|
||||
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:amber:wifi5g" "phy0tpt"
|
||||
ucidef_set_led_netdev "wan" "WAN" "${boardname}:white:internet" "eth1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
59
target/linux/ipq806x/base-files/etc/board.d/02_network
Executable file
59
target/linux/ipq806x/base-files/etc/board.d/02_network
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/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
|
||||
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"
|
||||
;;
|
||||
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
|
||||
44
target/linux/ipq806x/base-files/etc/diag.sh
Executable file
44
target/linux/ipq806x/base-files/etc/diag.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2016 Henryk Heisig hyniu@o2.pl
|
||||
|
||||
. /lib/functions/leds.sh
|
||||
|
||||
boot="$(get_dt_led boot)"
|
||||
failsafe="$(get_dt_led failsafe)"
|
||||
running="$(get_dt_led running)"
|
||||
upgrade="$(get_dt_led upgrade)"
|
||||
|
||||
set_state() {
|
||||
status_led="$boot"
|
||||
|
||||
case "$1" in
|
||||
preinit)
|
||||
status_led_blink_preinit
|
||||
;;
|
||||
failsafe)
|
||||
status_led_off
|
||||
[ -n "$running" ] && {
|
||||
status_led="$running"
|
||||
status_led_off
|
||||
}
|
||||
status_led="$failsafe"
|
||||
status_led_blink_failsafe
|
||||
;;
|
||||
preinit_regular)
|
||||
status_led_blink_preinit_regular
|
||||
;;
|
||||
upgrade)
|
||||
[ -n "$running" ] && {
|
||||
status_led="$upgrade"
|
||||
status_led_blink_preinit_regular
|
||||
}
|
||||
;;
|
||||
done)
|
||||
status_led_off
|
||||
[ -n "$running" ] && {
|
||||
status_led="$running"
|
||||
status_led_on
|
||||
}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
|
||||
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() {
|
||||
local mac=$1
|
||||
|
||||
[ -z "$mac" ] && return
|
||||
|
||||
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
|
||||
}
|
||||
|
||||
[ -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
|
||||
linksys,ea8500)
|
||||
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
ath10kcal_extract "art" 4096 12064
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
ath10kcal_extract "art" 4096 12064
|
||||
;;
|
||||
tplink,c2600)
|
||||
ath10kcal_extract "radio" 4096 12064
|
||||
# ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
|
||||
;;
|
||||
nec,wg2600hp |\
|
||||
tplink,vr2600v)
|
||||
ath10kcal_extract "ART" 4096 12064
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
ath10kcal_extract "0:ART" 4096 12064
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"ath10k/pre-cal-pci-0001:01:00.0.bin")
|
||||
case $board in
|
||||
linksys,ea8500)
|
||||
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
ath10kcal_extract "art" 20480 12064
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
ath10kcal_extract "art" 20480 12064
|
||||
;;
|
||||
tplink,c2600)
|
||||
ath10kcal_extract "radio" 20480 12064
|
||||
# ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2)
|
||||
;;
|
||||
nec,wg2600hp |\
|
||||
tplink,vr2600v)
|
||||
ath10kcal_extract "ART" 20480 12064
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
ath10kcal_extract "0:ART" 20480 12064
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/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
|
||||
linksys,ea8500)
|
||||
echo $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
nec,wg2600hp)
|
||||
echo $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) $((1 - $PHYNBR)) ) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
netgear,d7800 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800)
|
||||
echo $(macaddr_add $(mtd_get_mac_binary art 6) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
tplink,c2600)
|
||||
echo $(macaddr_add $(mtd_get_mac_binary default-mac 8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
echo $(macaddr_add $(mtd_get_mac_binary default-mac 0) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
echo $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) $((1 - $PHYNBR)) ) > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
19
target/linux/ipq806x/base-files/etc/init.d/linksys_recovery
Executable file
19
target/linux/ipq806x/base-files/etc/init.d/linksys_recovery
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
|
||||
START=97
|
||||
boot() {
|
||||
. /lib/functions.sh
|
||||
|
||||
case $(board_name) in
|
||||
linksys,ea8500)
|
||||
# make sure auto_recovery in uboot is always on
|
||||
AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`"
|
||||
if [ "$AUTO_RECOVERY_ENA" != "yes" ] ; then
|
||||
fw_setenv auto_recovery yes
|
||||
fi
|
||||
# reset the boot counter
|
||||
mtd resetbc s_env
|
||||
;;
|
||||
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
|
||||
101
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
Normal file
101
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
Normal file
@@ -0,0 +1,101 @@
|
||||
#
|
||||
# Copyright (C) 2014-2015 OpenWrt.org
|
||||
#
|
||||
|
||||
linksys_get_target_firmware() {
|
||||
cur_boot_part=`/usr/sbin/fw_printenv -n boot_part`
|
||||
target_firmware=""
|
||||
if [ "$cur_boot_part" = "1" ]
|
||||
then
|
||||
# current primary boot - update alt boot
|
||||
target_firmware="kernel2"
|
||||
fw_setenv boot_part 2
|
||||
#In EA8500 bootcmd is always "bootipq", so don't change
|
||||
#fw_setenv bootcmd "run altnandboot"
|
||||
elif [ "$cur_boot_part" = "2" ]
|
||||
then
|
||||
# current alt boot - update primary boot
|
||||
target_firmware="kernel1"
|
||||
fw_setenv boot_part 1
|
||||
#In EA8500 bootcmd is always "bootipq", so don't change
|
||||
#fw_setenv bootcmd "run nandboot"
|
||||
fi
|
||||
|
||||
# re-enable recovery so we get back if the new firmware is broken
|
||||
fw_setenv auto_recovery yes
|
||||
|
||||
echo "$target_firmware"
|
||||
}
|
||||
|
||||
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
|
||||
compex,wpq864|\
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800 |\
|
||||
qcom,ipq8064-ap148 |\
|
||||
zyxel,nbg6817)
|
||||
nand_do_upgrade "$ARGV"
|
||||
;;
|
||||
linksys,ea8500)
|
||||
platform_do_upgrade_linksys "$ARGV"
|
||||
;;
|
||||
tplink,c2600)
|
||||
PART_NAME="os-image:rootfs"
|
||||
MTD_CONFIG_ARGS="-s 0x200000"
|
||||
default_do_upgrade "$ARGV"
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
PART_NAME="kernel:rootfs"
|
||||
MTD_CONFIG_ARGS="-s 0x200000"
|
||||
default_do_upgrade "$ARGV"
|
||||
;;
|
||||
nec,wg2600hp |\
|
||||
*)
|
||||
default_do_upgrade "$ARGV"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_nand_pre_upgrade() {
|
||||
case "$(board_name)" in
|
||||
zyxel,nbg6817)
|
||||
zyxel_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
blink_led() {
|
||||
. /etc/diag.sh; set_state upgrade
|
||||
}
|
||||
|
||||
append sysupgrade_pre_upgrade blink_led
|
||||
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 /tmp/sysupgrade.tgz /tmp/new_root/
|
||||
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