1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00
This commit is contained in:
suyuan 2020-12-24 11:22:37 +08:00
parent 960a300922
commit 0b30b295de
17 changed files with 228 additions and 5328 deletions

View file

@ -7,12 +7,6 @@ preinit_set_mac_address() {
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)
@ -21,7 +15,8 @@ preinit_set_mac_address() {
base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth1 address $(macaddr_add "${base_mac}" +1)
;;
linksys,ea8300)
linksys,ea8300|\
linksys,mr8300)
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)

View file

@ -8,11 +8,13 @@ set_preinit_iface() {
ezviz,cs-w3-wd1200g-eup| \
glinet,gl-b1300| \
linksys,ea8300| \
linksys,mr8300| \
meraki,mr33| \
zyxel,nbg6617)
ifname=eth0
;;
*)
devolo,magic-2-wifi-next)
ifname=eth1
;;
esac
}

View file

@ -119,4 +119,4 @@ platform_do_upgrade_linksys() {
get_image "$1" | mtd write - "$part_label"
fi
}
}
}

View file

@ -4,141 +4,28 @@ REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
ubi_kill_if_exist() {
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
local c_ubivol="$( nand_find_volume $ubidev $1 )"
umount -f /dev/$c_ubivol 2>/dev/null
[ "$c_ubivol" ] && ubirmvol /dev/$ubidev -N $1 || true
echo "Partition $1 removed."
}
# 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"
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
local kernel_length=`(tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null`
local rootfs_length=`(tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null`
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
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() {
case "$(board_name)" in
asus,rt-ac58u)
CI_UBIPART="UBI_DEV"
local ubidev=$(nand_find_ubi $CI_UBIPART)
local asus_root=$(nand_find_volume $ubidev jffs2)
[ -n "$asus_root" ] || return 0
cat << EOF
jffs2 partition is still present.
There's probably no space left
to install the filesystem.
You need to delete the jffs2 partition first:
# ubirmvol /dev/ubi0 --name=jffs2
Once this is done. Retry.
EOF
return 1
;;
esac
return 0;
}
@ -170,7 +57,6 @@ zyxel_do_upgrade() {
platform_do_upgrade() {
case "$(board_name)" in
pangu,l1000 |\
8dev,jalapeno |\
aruba,ap-303 |\
aruba,ap-303h |\
@ -178,8 +64,12 @@ platform_do_upgrade() {
avm,fritzbox-7530 |\
avm,fritzrepeater-1200 |\
avm,fritzrepeater-3000 |\
buffalo,wtr-m2133hp |\
cilab,meshpoint-one |\
edgecore,ecw5211 |\
edgecore,oap100 |\
engenius,eap2200 |\
luma,wrtq-329acn |\
mobipromo,cm520-79f |\
qxwlan,e2600ac-c2)
nand_do_upgrade "$1"
@ -199,29 +89,21 @@ platform_do_upgrade() {
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
asus,rt-acrh17|\
asus,rt-ac58u)
local magic=$(get_magic_long "$1")
CI_UBIPART="UBI_DEV"
CI_KERNPART="linux"
if [ "$magic" == "27051956" ]; then
echo "Got Asus factory image."
asus_nand_upgrade_factory 50409472 "$1"
else
asus_nand_upgrade_tar 20951040 "$1"
fi
nand_do_upgrade "$1"
;;
cellc,rtl30vw)
CI_UBIPART="ubifs"
askey_do_upgrade "$1"
;;
compex,wpj419|\
p2w,r619ac-128m|\
p2w,r619ac)
compex,wpj419)
nand_do_upgrade "$1"
;;
linksys,ea6350v3 |\
linksys,ea8300)
linksys,ea8300 |\
linksys,mr8300)
platform_do_upgrade_linksys "$1"
;;
meraki,mr33)
@ -229,9 +111,11 @@ platform_do_upgrade() {
nand_do_upgrade "$1"
;;
openmesh,a42 |\
openmesh,a62)
openmesh,a62 |\
plasmacloud,pa1200 |\
plasmacloud,pa2200)
PART_NAME="inactive"
platform_do_upgrade_openmesh "$1"
platform_do_upgrade_dualboot_datachk "$1"
;;
zyxel,nbg6617)
zyxel_do_upgrade "$1"