This PR adds support for netis NX31 router.
Specification
-------------
- SoC : MediaTek MT7981BA dual-core ARM Cortex-A53 1.3 GHz
- RAM : 256 MiB DDR3
- Flash : SPI-NAND 128 MiB (ESMT)
- WLAN : MediaTek MT7976CN dual-band WiFi 6
- 2.4 GHz : b/g/n/ax, MIMO 2x2
- 5 GHz : a/n/ac/ax, MIMO 2x2
- Ethernet : 10/100/1000 Mbps x3 (LAN, MediaTek MT7531AE)
10/100/1000 Mbps x1 (WAN, SoC internal phy)
- USB : No
- Buttons : Mesh, Reset
- LEDs : 1x Power (blue), unmanaged
1x Status (blue), gpio-controlled
1x WiFi 2.4 GHz (blue), gpio-controlled
1x WiFi 5 GHz (blue), gpio-controlled
3x LAN activity (blue), switch-controlled
1x WAN activity (blue), gpio-controlled
- Power : 12 VDC, 1 A
Installation
------------
1. Connect to the router using ssh (user: admin, pass: web interface
password)
2. Make mtd backup:
cat /dev/mtd0 | gzip -1 -c > /tmp/mtd0_spi0.0.bin.gz
cat /dev/mtd1 | gzip -1 -c > /tmp/mtd1_BL2.bin.gz
cat /dev/mtd2 | gzip -1 -c > /tmp/mtd2_u-boot-env.bin.gz
cat /dev/mtd3 | gzip -1 -c > /tmp/mtd3_Factory.bin.gz
cat /dev/mtd4 | gzip -1 -c > /tmp/mtd4_FIP.bin.gz
cat /dev/mtd5 | gzip -1 -c > /tmp/mtd5_ubi.bin.gz
3. Download mtd backup from the /tmp dir of the router to your PC using
scp protocol
4. Upload OpenWrt 'bl31-uboot.fip', 'preloader.bin' images to the /tmp
dir of the router using scp protocol
5. Write FIP and BL2 (replace bootloader):
mtd write /tmp/openwrt-mediatek-filogic-netis_nx31-bl31-uboot.fip FIP
mtd write /tmp/openwrt-mediatek-filogic-netis_nx31-preloader.bin BL2
6. Place OpenWrt
'openwrt-mediatek-filogic-netis_nx31-initramfs-recovery.itb' image on
the tftp server (IP: 192.168.1.254)
7. Erase 'ubi' partition and reboot the router:
mtd erase ubi
reboot
8. U-Boot automatically boot OpenWrt recovery image from tftp server to
the RAM
9. Upload OpenWrt 'sysupgrade.itb' image to the /tmp dir of the router
(IP: 192.168.1.1) using scp protocol
10. Connect to the router using ssh and run:
sysupgrade -n openwrt-mediatek-filogic-netis_nx31-squashfs-sysupgrade.itb
Return to stock
---------------
1. Unpack stock BL2 and FIP partitions backup
2. Upload stock BL2 and FIP partitions backup to the /tmp dir of the
router using scp protocol
3. Connect to the router using ssh and run:
apk update && apk add kmod-mtd-rw
insmod mtd-rw i_want_a_brick=1
mtd unlock BL2
mtd unlock FIP
4. Restore backup:
mtd write /tmp/mtd4_FIP.bin FIP
mtd write /tmp/mtd1_BL2.bin BL2
5. Erase ubi and reboot:
mtd erase ubi
reboot
6. Power off the router
7. Press Reset button and power on the router. Release the button after
~10 sec
8. Navigate to U-Boot recovery web server (http://192.168.1.1/) and
upload the OEM firmware
Recovery
--------
1. Place OpenWrt
'openwrt-mediatek-filogic-netis_nx31-initramfs-recovery.itb' image on
the tftp server (IP: 192.168.1.254)
2. Press “Reset” button and power on the router. After ~10 sec release
the button.
3. Use OpenWrt initramfs system for recovery
MAC addresses
-------------
+---------+-------------------+-----------+
| | MAC | Algorithm |
+---------+-------------------+-----------+
| LAN | dc:xx:xx:d1:xx:18 | label |
| WAN | dc:xx:xx:d1:xx:1a | label+2 |
| WLAN 2g | de:xx:xx:11:xx:19 | |
| WLAN 5g | de:xx:xx:71:xx:19 | |
+---------+-------------------+-----------+
The LAN MAC was found in 'Factory', 0x1fef20
The WAN MAC was found in 'Factory', 0x1fef26
The WLAN 2g/5g MAC prototype was found in 'Factory', 0x4
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/18324
(cherry picked from commit d8002cb627)
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/18438
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
253 lines
5.0 KiB
Bash
Executable File
253 lines
5.0 KiB
Bash
Executable File
REQUIRE_IMAGE_METADATA=1
|
|
RAMFS_COPY_BIN='fitblk'
|
|
|
|
asus_initial_setup()
|
|
{
|
|
# initialize UBI if it's running on initramfs
|
|
[ "$(rootfs_type)" = "tmpfs" ] || return 0
|
|
|
|
ubirmvol /dev/ubi0 -N rootfs
|
|
ubirmvol /dev/ubi0 -N rootfs_data
|
|
ubirmvol /dev/ubi0 -N jffs2
|
|
ubimkvol /dev/ubi0 -N jffs2 -s 0x3e000
|
|
}
|
|
|
|
xiaomi_initial_setup()
|
|
{
|
|
# initialize UBI and setup uboot-env if it's running on initramfs
|
|
[ "$(rootfs_type)" = "tmpfs" ] || return 0
|
|
|
|
local mtdnum="$( find_mtd_index ubi )"
|
|
if [ ! "$mtdnum" ]; then
|
|
echo "unable to find mtd partition ubi"
|
|
return 1
|
|
fi
|
|
|
|
local kern_mtdnum="$( find_mtd_index ubi_kernel )"
|
|
if [ ! "$kern_mtdnum" ]; then
|
|
echo "unable to find mtd partition ubi_kernel"
|
|
return 1
|
|
fi
|
|
|
|
ubidetach -m "$mtdnum"
|
|
ubiformat /dev/mtd$mtdnum -y
|
|
|
|
ubidetach -m "$kern_mtdnum"
|
|
ubiformat /dev/mtd$kern_mtdnum -y
|
|
|
|
if ! fw_printenv -n flag_try_sys2_failed &>/dev/null; then
|
|
echo "failed to access u-boot-env. skip env setup."
|
|
return 0
|
|
fi
|
|
|
|
fw_setenv -s - <<-EOF
|
|
boot_wait on
|
|
uart_en 1
|
|
flag_boot_rootfs 0
|
|
flag_last_success 1
|
|
flag_boot_success 1
|
|
flag_try_sys1_failed 8
|
|
flag_try_sys2_failed 8
|
|
EOF
|
|
|
|
local board=$(board_name)
|
|
case "$board" in
|
|
xiaomi,mi-router-ax3000t|\
|
|
xiaomi,mi-router-wr30u-stock)
|
|
fw_setenv mtdparts "nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),34816k(ubi),34816k(ubi1),32768k(overlay),12288k(data),256k(KF)"
|
|
;;
|
|
xiaomi,redmi-router-ax6000-stock)
|
|
fw_setenv mtdparts "nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),30720k(ubi),30720k(ubi1),51200k(overlay)"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
platform_do_upgrade() {
|
|
local board=$(board_name)
|
|
|
|
case "$board" in
|
|
abt,asr3000|\
|
|
bananapi,bpi-r3|\
|
|
bananapi,bpi-r3-mini|\
|
|
bananapi,bpi-r4|\
|
|
bananapi,bpi-r4-poe|\
|
|
cmcc,a10-ubootmod|\
|
|
cmcc,rax3000m|\
|
|
gatonetworks,gdsp|\
|
|
h3c,magic-nx30-pro|\
|
|
jcg,q30-pro|\
|
|
jdcloud,re-cp-03|\
|
|
mediatek,mt7981-rfb|\
|
|
mediatek,mt7988a-rfb|\
|
|
mercusys,mr90x-v1-ubi|\
|
|
netis,nx31|\
|
|
nokia,ea0326gmp|\
|
|
openwrt,one|\
|
|
netcore,n60|\
|
|
qihoo,360t7|\
|
|
routerich,ax3000-ubootmod|\
|
|
tplink,tl-xdr4288|\
|
|
tplink,tl-xdr6086|\
|
|
tplink,tl-xdr6088|\
|
|
tplink,tl-xtr8488|\
|
|
xiaomi,mi-router-ax3000t-ubootmod|\
|
|
xiaomi,redmi-router-ax6000-ubootmod|\
|
|
xiaomi,mi-router-wr30u-ubootmod|\
|
|
zyxel,ex5601-t0-ubootmod)
|
|
fit_do_upgrade "$1"
|
|
;;
|
|
acer,predator-w6|\
|
|
acer,predator-w6d|\
|
|
acer,vero-w6m|\
|
|
arcadyan,mozart|\
|
|
glinet,gl-mt2500|\
|
|
glinet,gl-mt6000|\
|
|
glinet,gl-x3000|\
|
|
glinet,gl-xe3000|\
|
|
smartrg,sdg-8612|\
|
|
smartrg,sdg-8614|\
|
|
smartrg,sdg-8622|\
|
|
smartrg,sdg-8632|\
|
|
smartrg,sdg-8733|\
|
|
smartrg,sdg-8733a|\
|
|
smartrg,sdg-8734)
|
|
CI_KERNPART="kernel"
|
|
CI_ROOTPART="rootfs"
|
|
emmc_do_upgrade "$1"
|
|
;;
|
|
asus,rt-ax59u|\
|
|
asus,tuf-ax4200|\
|
|
asus,tuf-ax6000)
|
|
CI_UBIPART="UBI_DEV"
|
|
CI_KERNPART="linux"
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
cudy,re3000-v1|\
|
|
cudy,wr3000-v1|\
|
|
yuncore,ax835)
|
|
default_do_upgrade "$1"
|
|
;;
|
|
dlink,aquila-pro-ai-m30-a1|\
|
|
dlink,aquila-pro-ai-m60-a1)
|
|
fw_setenv sw_tryactive 0
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
mercusys,mr90x-v1|\
|
|
tplink,re6000xd)
|
|
CI_UBIPART="ubi0"
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
ubnt,unifi-6-plus)
|
|
CI_KERNPART="kernel0"
|
|
EMMC_ROOT_DEV="$(cmdline_get_var root)"
|
|
emmc_do_upgrade "$1"
|
|
;;
|
|
unielec,u7981-01*)
|
|
local rootdev="$(cmdline_get_var root)"
|
|
rootdev="${rootdev##*/}"
|
|
rootdev="${rootdev%p[0-9]*}"
|
|
case "$rootdev" in
|
|
mmc*)
|
|
CI_ROOTDEV="$rootdev"
|
|
CI_KERNPART="kernel"
|
|
CI_ROOTPART="rootfs"
|
|
emmc_do_upgrade "$1"
|
|
;;
|
|
*)
|
|
CI_KERNPART="fit"
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
esac
|
|
;;
|
|
xiaomi,mi-router-ax3000t|\
|
|
xiaomi,mi-router-wr30u-stock|\
|
|
xiaomi,redmi-router-ax6000-stock)
|
|
CI_KERN_UBIPART=ubi_kernel
|
|
CI_ROOT_UBIPART=ubi
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
*)
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
PART_NAME=firmware
|
|
|
|
platform_check_image() {
|
|
local board=$(board_name)
|
|
local magic="$(get_magic_long "$1")"
|
|
|
|
[ "$#" -gt 1 ] && return 1
|
|
|
|
case "$board" in
|
|
bananapi,bpi-r3|\
|
|
bananapi,bpi-r3-mini|\
|
|
bananapi,bpi-r4|\
|
|
bananapi,bpi-r4-poe|\
|
|
cmcc,rax3000m)
|
|
[ "$magic" != "d00dfeed" ] && {
|
|
echo "Invalid image type."
|
|
return 1
|
|
}
|
|
return 0
|
|
;;
|
|
*)
|
|
nand_do_platform_check "$board" "$1"
|
|
return $?
|
|
;;
|
|
esac
|
|
|
|
return 0
|
|
}
|
|
|
|
platform_copy_config() {
|
|
case "$(board_name)" in
|
|
bananapi,bpi-r3|\
|
|
bananapi,bpi-r3-mini|\
|
|
bananapi,bpi-r4|\
|
|
bananapi,bpi-r4-poe|\
|
|
cmcc,rax3000m)
|
|
if [ "$CI_METHOD" = "emmc" ]; then
|
|
emmc_copy_config
|
|
fi
|
|
;;
|
|
acer,predator-w6|\
|
|
acer,predator-w6d|\
|
|
acer,vero-w6m|\
|
|
arcadyan,mozart|\
|
|
glinet,gl-mt2500|\
|
|
glinet,gl-mt6000|\
|
|
glinet,gl-x3000|\
|
|
glinet,gl-xe3000|\
|
|
jdcloud,re-cp-03|\
|
|
smartrg,sdg-8612|\
|
|
smartrg,sdg-8614|\
|
|
smartrg,sdg-8622|\
|
|
smartrg,sdg-8632|\
|
|
smartrg,sdg-8733|\
|
|
smartrg,sdg-8733a|\
|
|
smartrg,sdg-8734|\
|
|
ubnt,unifi-6-plus)
|
|
emmc_copy_config
|
|
;;
|
|
esac
|
|
}
|
|
|
|
platform_pre_upgrade() {
|
|
local board=$(board_name)
|
|
|
|
case "$board" in
|
|
asus,rt-ax59u|\
|
|
asus,tuf-ax4200|\
|
|
asus,tuf-ax6000)
|
|
asus_initial_setup
|
|
;;
|
|
xiaomi,mi-router-ax3000t|\
|
|
xiaomi,mi-router-wr30u-stock|\
|
|
xiaomi,redmi-router-ax6000-stock)
|
|
xiaomi_initial_setup
|
|
;;
|
|
esac
|
|
}
|