Commit Graph

33 Commits

Author SHA1 Message Date
David Bauer f0445746f6 mediatek: add support for ZyXEL NWA50AX Pro
Hardware
--------
CPU:    Mediatek MT7981
RAM:    512M DDR4
FLASH:  256M NAND
ETH:    MaxLinear GPY211 (2.5GbE N Base-T)
WiFi:   Mediatek MT7981 (2.4GHz 2T2R:2 5GHz 3T3R:2 802.11ax)
BTN:    1x Reset
LED:    1x Multi-Color

UART Console
------------
Available below the rubber cover next to the ethernet port.

Settings: 115200 8N1

Layout:

<12V> <LAN> GND-RX-TX-VCC

Logic-Level is 3V3. Don't connect VCC to your UART adapter!

Installation Web-UI
-------------------
Upload the Factory image using the devices Web-Interface.

As the device uses a dual-image partition layout, OpenWrt can only
installed on Slot A. This requires the current active image prior
flashing the device to be on Slot B.

In case this is not the case, OpenWrt will boot only one time, returning
to the ZyXEL firmware the second boot.

If this happens, first install a ZyXEL firmware upgrade of any version
and install OpenWrt after that.

Installation TFTP / Recovery
----------------------------
This installation routine is especially useful in case of a bricked
device.

Attach to the UART console header of the device. Interrupt the boot
procedure by pressing Enter.

The bootloader has a reduced command-set available from CLI, but more
commands can be executed by abusing the atns command.

Boot a OpenWrt initramfs image available on a TFTP server at
192.168.1.66. Rename the image to nwa50axpro-openwrt-initramfs.bin.

 $ atnf nwa50axpro-openwrt-initramfs.bin
 $ atna 192.168.1.88
 $ atns "192.168.1.66; tftpboot; setenv fdt_high 0xffffffffffffffff;
   bootm"

Upon booting, set the booted image to the correct slot:

 $ zyxel-bootconfig /dev/mtd9 get-status
 $ zyxel-bootconfig /dev/mtd9 set-image-status 0 valid
 $ zyxel-bootconfig /dev/mtd9 set-active-image 0

Copy the OpenWrt sysupgrade image to the device using scp.
Write the sysupgrade image to NAND using sysupgrade.

 $ sysupgrade -n image.bin

Signed-off-by: David Bauer <mail@david-bauer.net>
2023-07-21 20:28:13 +02:00
Chukun Pan e78d1a06c8 mediatek: filogic: add H3C Magic NX30 Pro support
Hardware specification:
  SoC: MediaTek MT7981B 2x A53
  Flash: W25N01GVZEIG 128MB
  RAM: NT5CB128M16JR-FL 256MB
  Ethernet: 4x 10/100/1000 Mbps
  Switch: MediaTek MT7531AE
  WiFi: MediaTek MT7976C
  Button: Reset, WPS
  Power: DC 12V 1A

Flash instructions:
  1. PC run command: "telnet 192.168.124.1 99"
     Username: H3C, password is the web login
     password of the router.
  2. Download preloader.bin and bl31-uboot.fip
  3. PC run command: "python3 -m http.server 80"
  4. Download files in the telnet window:
     "wget http://192.168.124.xx/xxx.bin"
     Replace xx with your PC's IP and
     the preloader.bin and bl31-uboot.fip.
  5. Flushing openwrt's uboot:
     "mtd write xxx-preloader.bin BL2"
     "mtd write xxx-bl31-uboot.fip FIP"
  6. Connect to the router via the Lan port,
     set a static ip of your PC.
     (ip 192.168.1.254, gateway 192.168.1.1)
  7. Download initramfs image, reboot router,
     waiting for tftp recovery to complete.
  8. After openwrt boots up, perform sysupgrade.

Note:
  1. The u-boot-env partition on mtd is empty,
     OEM stores their env on ubi:u-boot-env.
  2. Back up all mtd partitions before flashing.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
2023-07-01 15:13:08 +02:00
Mikhail Zhilkin e4fe3097ef mediatek: add support for Mercusys MR90X v1
This commit adds support for Mercusys MR90X(EU) v1 router.

Device specification
--------------------
SoC Type:   MediaTek MT7986BLA, Cortex-A53, 64-bit
RAM:        MediaTek MT7986BLA (512MB)
Flash:      SPI NAND GigaDevice GD5F1GQ5UEYIGY (128 MB)
Ethernet:   MediaTek MT7531AE + 2.5GbE MaxLinear GPY211C0VC (SLNW8)
Ethernet:   1x2.5Gbe (WAN/LAN 2.5Gbps), 3xGbE (WAN/LAN 1Gbps, LAN1, LAN2)
WLAN 2g:    MediaTek MT7975N, b/g/n/ax, MIMO 4x4
WLAN 5g:    MediaTek MT7975P(N), a/n/ac/ax, MIMO 4x4
LEDs:       1 orange and 1 green status LEDs, 4 green gpio-controlled
            LEDs on ethernet ports
Button:     1 (Reset)
USB ports:  No
Power:      12 VDC, 2 A
Connector:  Barrel
Bootloader: Main U-Boot - U-Boot 2022.01-rc4. Additionally, both UBI
            slots contain "seconduboot" (also U-Boot 2022.01-rc4)

Serial console (UART)
---------------------
                            V
+-------+-------+-------+-------+
| +3.3V |  GND  |  TX   |  RX   |
+---+---+-------+-------+-------+
    |
    +--- Don't connect

The R3 (TX line) and R6 (RX line) are absent on the PCB. You should
solder them or solder the jumpers.

Installation (UART)
-------------------
1. Place OpenWrt initramfs image on tftp server with IP 192.168.1.2
2. Attach UART, switch on the router and interrupt the boot process by
   pressing 'Ctrl-C'
3. Load and run OpenWrt initramfs image:
      tftpboot initramfs-kernel.bin
      bootm
4. Once inside OpenWrt, set / update env variables:
      fw_setenv baudrate 115200
      fw_setenv bootargs "ubi.mtd=ubi0 console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000 init=/etc/preinit"
      fw_setenv fdtcontroladdr 5ffc0e70
      fw_setenv ipaddr 192.168.1.1
      fw_setenv loadaddr 0x46000000
      fw_setenv mtdids "spi-nand0=spi-nand0"
      fw_setenv mtdparts "spi-nand0:2M(boot),1M(u-boot-env),50M(ubi0),50M(ubi1),8M(userconfig),4M(tp_data)"
      fw_setenv netmask 255.255.255.0
      fw_setenv serverip 192.168.1.2
      fw_setenv stderr serial@11002000
      fw_setenv stdin serial@11002000
      fw_setenv stdout serial@11002000
      fw_setenv tp_boot_idx 0
5. Run 'sysupgrade -n' with the sysupgrade OpenWrt image

Installation (without UART)
---------------------------
1.  Login as root via SSH (router IP, port 20001, password - your web
    interface password)
2.  Open for editing /etc/hotplug.d/iface/65-iptv (e.g., using WinSCP and
    SSH settings from the p.1)
3.  Add a newline after "#!/bin/sh":
       telnetd -l /bin/login.sh
4.  Save "65-iptv" file
5.  Toggle "IPTV/VLAN Enable" checkbox in the router web interface and
    save
6.  Make sure that telnetd is running:
       netstat -ltunp | grep 23
7.  Login via telnet to router IP, port 23 (no username and password are
    required)
8  Upload OpenWrt "initramfs-kernel.bin" to the "/tmp" folder of the
    router (e.g., using WinSCP and SSH settings from the p.1)
9.  Stock busybox doesn't contain ubiupdatevol command. Hence, we need to
    download and upload the full version of busybox to the router. For
    example, from here:
    https://github.com/xerta555/Busybox-Binaries/raw/master/busybox-arm64
    Upload busybox-arm64 to the /tmp dir of the router and run:
    in the telnet shell:
       cd /tmp
       chmod a+x busybox-arm64
10. Check "initramfs-kernel.bin" size:
       du -h initramfs-kernel.bin
11. Delete old and create new "kernel" volume with appropriate size
    (greater than "initramfs-kernel.bin" size):
       ubirmvol /dev/ubi0 -N kernel
       ubimkvol /dev/ubi0 -n 1 -N kernel -s 9MiB
12. Write OpenWrt "initramfs-kernel.bin" to the flash:
       ./busybox-arm64 ubiupdatevol /dev/ubi0_1 /tmp/initramfs-kernel.bin
13. u-boot-env can be empty so lets create it (or overwrite it if it
    already exists) with the necessary values:
       fw_setenv baudrate 115200
       fw_setenv bootargs "ubi.mtd=ubi0 console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000 init=/etc/preinit"
       fw_setenv fdtcontroladdr 5ffc0e70
       fw_setenv ipaddr 192.168.1.1
       fw_setenv loadaddr 0x46000000
       fw_setenv mtdids "spi-nand0=spi-nand0"
       fw_setenv mtdparts "spi-nand0:2M(boot),1M(u-boot-env),50M(ubi0),50M(ubi1),8M(userconfig),4M(tp_data)"
       fw_setenv netmask 255.255.255.0
       fw_setenv serverip 192.168.1.2
       fw_setenv stderr serial@11002000
       fw_setenv stdin serial@11002000
       fw_setenv stdout serial@11002000
       fw_setenv tp_boot_idx 0
14. Reboot to OpenWrt initramfs:
       reboot
15. Login as root via SSH (IP 192.168.1.1, port 22)
16. Upload OpenWrt sysupgrade.bin image to the /tmp dir of the router
17. Run sysupgrade:
       sysupgrade -n /tmp/sysupgrade.bin

Recovery
--------
1. Press Reset button and power on the router
2. Navigate to U-Boot recovery web server (http://192.168.1.1/) and
   upload the OEM firmware

Recovery (UART)
---------------
1. Place OpenWrt initramfs image on tftp server with IP 192.168.1.2
2. Attach UART, switch on the router and interrupt the boot process by
   pressing 'Ctrl-C'
3. Load and run OpenWrt initramfs image:
      tftpboot initramfs-kernel.bin
      bootm
4. Do what you need (restore partitions from a backup, install OpenWrt
   etc.)

Stock layout
------------
0x000000000000-0x000000200000 : "boot"
0x000000200000-0x000000300000 : "u-boot-env"
0x000000300000-0x000003500000 : "ubi0"
0x000003500000-0x000006700000 : "ubi1"
0x000006700000-0x000006f00000 : "userconfig"
0x000006f00000-0x000007300000 : "tp_data"

ubi0/ubi1 format
----------------
U-Boot at boot checks that all volumes are in place:
+-------------------------------+
| Volume Name: uboot   Vol ID: 0|
| Volume Name: kernel  Vol ID: 1|
| Volume Name: rootfs  Vol ID: 2|
+-------------------------------+

MAC addresses
-------------
+---------+-------------------+-----------+
|         | MAC               | Algorithm |
+---------+-------------------+-----------+
| label   | 00:eb:xx:xx:xx:be | label     |
| LAN     | 00:eb:xx:xx:xx:be | label     |
| WAN     | 00:eb:xx:xx:xx:bf | label+1   |
| WLAN 2g | 00:eb:xx:xx:xx:be | label     |
| WLAN 5g | 00:eb:xx:xx:xx:bd | label-1   |
+---------+-------------------+-----------+
label MAC address was found in UBI partition "tp_data", file
"default-mac". OEM wireless eeprom is also there (file
"MT7986_EEPROM.bin").

Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
2023-06-25 12:25:22 +02:00
Flole Systems 984786a2f7 filogic: add support for Netgear WAX220
Hardware
--------
SOC:   MediaTek MT7986
RAM:   1024MB DDR3
FLASH: 128MB SPI-NAND (Winbond)
WIFI:  Mediatek MT7986 DBDC 802.11ax 2.4/5 GHz
ETH:   Realtek RTL8221B-VB-CG 2.5 N-Base-T PHY with PoE
UART:  3V3 115200 8N1 (Pinout silkscreened / Do not connect VCC)

Installation
------------

1. Download the OpenWrt initramfs image. Copy the image to a TFTP server
2. Connect the TFTP server to the WAX220. Conect to the serial console,
   interrupt the autoboot process by pressing '0' when prompted.
3. Download & Boot the OpenWrt initramfs image.

   $ setenv ipaddr 192.168.2.1
   $ setenv serverip 192.168.2.2
   $ tftpboot openwrt.bin
   $ bootm

4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device
   using scp and install using sysupgrade.

   $ sysupgrade -n <path-to-sysupgrade.bin>

Signed-off-by: Flole Systems <flole@flole.de>
Signed-off-by: Stefan Agner <stefan@agner.ch>
2023-06-21 23:32:26 +02:00
Daniel Golle 98e6ea32a4 mediatek: use DEVICE_DTC_FLAGS and drop DTC_FLAGS where not needed
The MT7986 RFB was intended to use device tree overlays and for that
reason modified DTC_FLAGS. zyxel_ex5601-t0-stock later on probably
copied it from there. Both boards do not actually use device tree
overlays, so remove setting DTC_FLAGS from both.

The BPi-R3 does use device tree overlays, use DEVICE_DTC_FLAGS to give
it an extra 4kb of padding for overlays to be applied.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-06-06 13:26:19 +01:00
Daniel Golle 7a0ec001ff mediatek: sync MT7986 device trees with upstream
Sync device tree files for MT7986 boards with what landed in upstream
Linux tree to easy maintainance and also allow for a smooth update to
Linux 6.1.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-06-05 11:36:32 +01:00
Daniel Golle 037ce27244 mediatek: follow-up with renamed Build/bl2 and Build/bl31-uboot
Use renamed build step names for all boards which were not handled by
commit c620409d58 ("mediatek: filogic: add uboot build for mt7981")
and now breaking the build.

Fixes: c620409d58 ("mediatek: filogic: add uboot build for mt7981")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-05-27 21:57:01 +01:00
Chukun Pan dc2d4d7393 mediatek: filogic: add Qihoo 360T7 support
Hardware specification:
  SoC: MediaTek MT7981B 2x A53
  Flash: ESMT F50L1G41LB 128MB
  RAM: MT5CC128M16JR-EK 256MB
  Ethernet: 4x 10/100/1000 Mbps
  Switch: MediaTek MT7531AE
  WiFi: MediaTek MT7976C
  Button: Reset, WPS
  Power: DC 12V 1A

Flash instructions:
  1. Attach UART, boot the stock firmware until
     the message about failsafe mode appears.
  2. Enter failsafe mode by pressing "f" and "Enter"
  3. Type "mount_root", then run
     "fw_setenv bootmenu_delay 3"
  4. Back up all mtd partitions before flashing.
  5. Reboot, U-Boot now presents a menu.
  6. Connect to your PC via the Gigabit port of the router,
     set a static ip on the ethernet interface of your PC.
     (ip 192.168.1.254, gateway 192.168.1.1)
  7. Select "Upgrade ATF BL2", then use this file:
     openwrt-mediatek-filogic-qihoo_360t7-preloader.bin
  8. Select "Upgrade ATF FIP", then use this file:
     openwrt-mediatek-filogic-qihoo_360t7-bl31-uboot.fip
  9. Download the initramfs image, and type "reset",
     waiting for tftp recovery to complete.
  a. After openwrt boots up, perform sysupgrade.

Note:
  1. Since NMBM is disabled, we must back up all partitions.
  2. Flash instructions is based on commit 28df7f7.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
2023-05-27 11:17:08 +01:00
Chukun Pan c620409d58 mediatek: filogic: add uboot build for mt7981
Rename previous uboot build to mt7986-*.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
2023-05-27 11:01:45 +01:00
Daniel Golle 43d27b0252 mediatek: fix, clean and unify SD card image generation
Make sure sub-images on the SD card are size-checked, allow
generating SD card without squashfs and/or initramfs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-05-26 14:31:36 +01:00
Sam Shih e3a681bab4 mediatek: add basic mt7988 device tree support
This add basic device tree support for mediatek MT7988 SoC

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-05-23 15:53:22 +01:00
Pietro Ameruoso 1c05388ab0 mediatek: add support for Zyxel EX5601-T0 router
Zyxel EX5601-T0 specifics
--------------
The operator specific firmware running on the Zyxel branded
EX5601-T0 includes  U-Boot modifications affecting the OpenWrt
installation.

Partition Table
| dev  | size     | erasesize | name          |
| ---- | -------- | --------- | ------------- |
| mtd0 | 20000000 | 00040000  | "spi0.1"      |
| mtd1 | 00100000 | 00040000  | "BL2"         |
| mtd2 | 00080000 | 00040000  | "u-boot-env"  |
| mtd3 | 00200000 | 00040000  | "Factory"     |
| mtd4 | 001c0000 | 00040000  | "FIP"         |
| mtd5 | 00040000 | 00040000  | "zloader"     |
| mtd6 | 04000000 | 00040000  | "ubi"         |
| mtd7 | 04000000 | 00040000  | "ubi2"        |
| mtd8 | 15a80000 | 00040000  | "zyubi"       |

The router boots BL2 which than loads FIP (u-boot).
U-boot has hardcoded a command to always launch Zloader "mtd read zloader 0x46000000" and than "bootm". Bootargs are deactivated.
Zloader is the zyxel booloader which allow to dual-boot ubi or ubi2, by default access to zloader is blocked.
Too zloader checks that the firmware contains a particolar file called zyfwinfo.
Additional details regarding Zloader can be found here:
https://hack-gpon.github.io/zyxel/
https://forum.openwrt.org/t/adding-openwrt-support-for-zyxel-ex5601-t0/155914

Hardware
--------
SOC: MediaTek MT7986a
CPU: 4 core cortex-a53 (2000MHz)
RAM: 1GB DDR4
FLASH: 512MB SPI-NAND (Micron xxx)
WIFI: Wifi6 Mediatek MT7976 802.11ax 5 GHz 4x4 + 2.4GHZ 4x4
ETH: MediaTek MT7531 Switch + SoC
3 x builtin 1G phy (lan1, lan2, lan3)
1 x MaxLinear GPY211B 2.5 N-Base-T phy5 (lan4)
1 x MaxLinear GPY211B 2.5Gbit xor SFP/N-Base-T phy6 (wan)
USB: 1 x USB 3.2 Enhanced SuperSpeed port
UART: 3V3 115200 8N1 (Pinout: GND KEY RX TX VCC)
VOIP: 2 FXS ports for analog phones

MAC Address Table
-----------------
eth0/lan    Factory 0x002a
eth1/wan    Factory 0x0024
wifi 2.4Ghz Factory 0x0004
wifi 5Ghz   Factory 0x0004 + 1

Serial console (UART)
---------------------
+-------+-------+-------+-------+-------+
| +3.3V |  RX   |  TX   |  KEY  |  GND  |
+---+---+-------+-------+-------+-------+
    |
    +--- Don't connect

Installation
------------
Keep in mind that openwrt can only run on the UBI partition, the openwrt firmware is not able to understand the zloader bootargs.
The procedure allows restoring the UBI partition with the Zyxel firmware and retains all the OEM functionalities.

1. Unlock Zloader (this will allow to swap manually between partitions UBI and UBI2):
- Attach a usb-ttl adapter to your computer and boot the router.
- While the router is booting at some point you will read the following: `Please press Enter to activate this console.`
- As soon as you read that press enter, type root and than press enter again (just do it, don't care about the logs scrolling).
- Most likely the router is still printing the boot log, leave it boot until it stops.
- If everything went ok you should have full root access "root@EX5601-T0:/#".
- Type the following command and press enter: "fw_setenv EngDebugFlag 0x1".
- Reboot the router.
- As soon as you read `Hit any key to stop autoboot:` press Enter.
- If everything went ok you should have the following prompt: "ZHAL>".
- You have successfully unlocked zloader access, this procedure must be done only once.

2. Check the current active partition:
- Boot the router and repeat the steps above to gain root access.
- Type the following command to check the current active image: "cat /proc/cmdline".
- If `rootubi=ubi` it means that the active partition is `mtd6`
- If `rootubi=ubi2` it means that the active partition is `mtd7`
- As mentioned earlier we need to flash openwrt into ubi/mtd6 and never overwrite ubi2/mtd7 to be able to fully roll-back.
- To activate and boot from mtd7 (ubi2) enter into ZHAL> command prompt and type the following commands:
atbt 1  # unlock write
atsw    # swap boot partition
atsr    # reboot the router
- After rebooting check again with "cat /proc/cmdline" that you are correctly booting from mtd7/ubi2
- If yes proceed with the installation guide. If not probably you don't have a firmware into ubi2 or you did something wrong.

3. Flashing:
- Download the sysupgrade file for the router from openwrt, than we need to add the zyfwinfo file into the sysupgrade tar.
Zloader only checks for the magic (which is a fixed value 'EXYZ') and the crc of the file itself (256bytes).
I created a script to create a valid zyfwinfo file but you can use anything that does exactly the same:
https://raw.githubusercontent.com/pameruoso/OpenWRT-Zyxel-EX5601-T0/main/gen_zyfwinfo.sh
- Add the zyfwinfo file into the sysupgrade tar.
- Enter via telnet or ssh into the router with admin credentials
- Enter the following commands to disable the firmware and model checks
"zycli fwidcheck off" and "zycli modelcheck off"
- Open the router web interface and in the update firmware page select the "restore default settings option"
- Select the sysupgrade file and click on upload.
- The router will flash and reboot itself into openwrt from UBI

4. Restoring and going back to Zyxel firmware.
- Use the ZHAL> command line to manually swap the boot parition to UBI2 with the following:
atbt 1  # unlock write
atsw    # swap boot partition
atsr    # reboot the router
- You will boot again the Zyxel firmware you have into UBI2 and you can flash the zyxel firmware to overwrite the UBI partition and openwrt.

Working features
----------------
3 gbit lan ports
Wifi
Zyxel partitioning for coexistance with Zloader and dual boot.
WAN SFP port (only after exporting pins 57 and 10. gpiobase411)
leds
reset button
serial interface
usb port
lan ethernet 2.5 gbit port (autosense)
wan ethernet 2.5 gbit port (autosense)

Not working
----------------
voip (missing drivers or proper zyxel platform software)

Swapping the wan ethernet/sfp xor port
----------------
The way to swap the wan port between sfp and ethernet is the following:
export the pins 57 and 10.
Pin 57 is used to probe if an sfp is present.
If pin 57 value is 0 it means that an sfp is present into the cage (cat /sys/class/gpio/gpio468/value).
If pin 57 value is 1 it means that no sfp is inserted into the cage.
In conclusion by default both 57 an 10 pins are by default 1, which means that the active port is the ethernet one.
After inserting an SFP pin 57 will become 0 and you have to manually change the value of pin 10 to 0 too.
This is totally scriptable of course.

Leds description
------------
All the leds are working out of the box but the leds managed by the 2 maxlinear phy (phy 5 lan, phy6 wan).
To activate the phy5 led (rj45 ethernet port led on the back of the router) you have to use mdio-tools.
To activate the phy6 led (led on the front of the router for 2.5gbit link) you have to use mdio-tools.
Example:
Set lan5 led to fast blink on 2500/1000, slow blink on 10/100:
mdio mdio-bus mmd 5:30 raw 0x0001 0x33FC

Set wan 2.5gbit led to constant on when wan is 2.5gbit:
mdio mdio-bus mmd 6:30 raw 0x0001 0x0080

Signed-off-by: Pietro Ameruoso <p.ameruoso@live.it>
2023-05-22 17:58:59 +02:00
Daniel Golle a384490b10 mediatek: fix append-gl-metadata when running in buildbot
Use same logic as in append-metadata so build doesn't fail in case of
missing build-key (it was previously failing on the buildbot runners).

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-05-19 09:34:22 +01:00
Daniel Golle fd0118c0a5 mediatek: remove left-over reference to make_gl_metadata.py
When adding support for the GL.iNet GL-MT3000 a reference to the
non-existent make_gl_metadata.py script was accidentally added.
Remove it, flashing from vendor firmware also works fine without that.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-05-18 11:24:07 +01:00
Daniel Golle 7cbe34170e mediatek: add support for the GL.iNet GL-MT3000
The MT-3000 is a pocket-sized Wi-Fi 6 router based on MediaTek MT7981.

Specification:
 - SoC: MediaTek MT7981B
 - CPU: 2x 1.3 GHz Cortex-A53
 - Flash: 256 MiB Macronix SPI NAND
 - RAM: 512 MiB Nanya DDR4
 - WLAN: 2.4 GHz, 5 GHz (MediaTek MT7976CN)
 - Ethernet:
    - 1x 10/100/1000 Mbps built-in PHY (LAN)
    - 1x 10/100/1000/2500 Mbps MaxLinear GPY211 PHY (WAN)
 - USB 3.0 port
 - Buttons: 1 button, 1 switch
 - LEDs: 1x light-blue, 1x warm-white
 - Serial console: internal 4-pin header, 115200 8n1
 - PWM controlled fan with tacho
 - Power: 5 VDC, 3 A (USB Type-C)

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-05-18 02:41:49 +01:00
David Bauer c9cb6411c1 mediatek: add support for Cudy WR3000 v1
Hardware
--------
MediaTek MT7981 WiSoC
256MB DDR3 RAM
16MB SPI-NOR (XMC XM25QH128C)
MediaTek MT7981 2x2 DBDC 802.11ax 2T2R (2.4 / 5)
UART: 115200 8N1 3.3V
      [LEDS] VCC-GND-RX-TX [ETH]
      Header is located below the heatsink

Case
----
Unscrew the 4 bottom screws. Remove the top of the case by inserting a
small screwdriver into the ventilation holes and lift the top cover.

This works best by beginning near the ETH-ports. The top is clipped on
the front near the LEDs with two plastic clips. The back has a single
clip in the middle. Start at one of the back edges.

MAC-Addresses
-------------
80:AF:CA:00:F9:C6 LAN
80:AF:CA:00:F9:C7 WAN
80:AF:CA:00:F9:C6 W2
82:AF:CA:30:F9:C6 W5

Installation
------------

1. Connect to the serial port as described in the "Hardware" section.

2. Power on the device. Keep pressing the "0" key to enter the U-Boot
   shell.

3. Download the OpenWrt initramfs image. Place it on an TFTP server
   connected to the Cudy LAN ports. Make sure the server is reachable at
   192.168.1.2. Rename the image to "cudy3000.bin"

4. Download and boot the OpenWrt initramfs image.

   $ tftpboot 0x46000000 cudy3000.bin; bootm 0x46000000

5. Transfer the OpenWrt sysupgrade image to the device using scp.
   Install with sysupgrade.

Note: Cudy does not yet provide a image for disabling their
signature-protection. This has happened in the past. Make sure to check
the wiki for a possible easier installation method.

Signed-off-by: David Bauer <mail@david-bauer.net>
2023-05-18 01:46:13 +02:00
Chukun Pan 21be2c26d5 mediatek: add support for TP-Link TL-XDR4288/608x
Hardware specification:
  SoC: MediaTek MT7986A 4x A53
  Flash: ESMT F50L1G41LB 128MB
  RAM: ESMT M15T4G16256A 512MB
  Ethernet (Max Speed):
    XDR4288: 1x 2.5G Wan, 1x 2.5G Lan, 4x 1G Lan
    XDR6086: 1x 2.5G Wan, 1x 2.5G Lan, 1x 1G Lan
    XDR6088: 1x 2.5G Wan, 1x 2.5G Lan, 4x 1G Lan
  WiFi:
    XDR4288: MT7976DAN (2.4G 2T2R, 5G 3T3R)
    XDR6086/XDR6088:
      WiFi1: MT7976GN 2.4GHz 4T4R
      WiFi2: MT7976AN 5GHz 4T4R
  Button: Reset, WPS, Turbo
  USB: 1 x USB 3.0
  Power: DC 12V 4A

Flash instructions:
  1. Execute the following operation to open nc shell:
     https://openwrt.org/inbox/toh/tp-link/xdr-6086#rooting
  2. Replace the stock bootloader to OpenWrt's:
     dd bs=131072 conv=sync of=/dev/mtdblock9 if=/tmp/xxx-preloader.bin
     dd bs=131072 conv=sync of=/dev/mtdblock9 seek=28 if=/tmp/xxx-bl31-uboot.fip
  3. Connect to your PC via the Gigabit port of the router,
     set a static ip on the ethernet interface of your PC.
     (ip 192.168.1.254, gateway 192.168.1.1)
  4. Download the initramfs image, and restart the router,
     waiting for tftp recovery to complete.
  5. After openwrt boots up, perform sysupgrade.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
[Add uboot build, fit and sysupgrade support, fix RealTek PHYs]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-04-22 04:10:19 +01:00
Daniel Golle e92b153e99 mediatek: introduce KERNEL_LOADADDR to Device/Default template
We need to reset KERNEL_LOADADDR if we use it on a per-device base.
Otherwise the previous value will be kept in case a device doesn't
define KERNEL_LOADADDR and relies on the default.

Move initializing KERNEL_LOADADDR to target/linux/mediatek/image/Makefile,
similar to how it's done also on the ramips target.

This fixes image size related breakage on devices which rely on the
default value of KERNEL_LOADADDR.

While at it use 0x48000000 which is more common than the previous default
0x44000000 for the filogic subtarget.

Fixed: e7c399bee6 ("filogic: add support for ASUS TUF-AX4200")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-04-05 17:12:55 +01:00
David Bauer f25abdf144 mediatek: make TUF-AX4200 KERNEL simply expanded
The KERNEL variable was recursively expanded, breaking other devices.

Signed-off-by: David Bauer <mail@david-bauer.net>
2023-04-04 02:08:32 +02:00
Andrew Sim ed2849958f mediatek: re-add wireless driver for TUF-AX4200
The wireless driver package was incorrectly removed from the TUF-AX4200
device-packages, resulting in images without wireless functionality.

Fixes: d98c4fb8bf ("mediatek: broaden filogic target description")

Signed-off-by: Andrew Sim <andrewsimz@gmail.com>
[rework commit description]
Signed-off-by: David Bauer <mail@david-bauer.net>
2023-03-29 17:03:42 +02:00
Daniel Golle d98c4fb8bf mediatek: broaden filogic target description
The filogic subtarget now also supports MT7981 and will in future
also support MT7988. Reflect that in the target description.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2023-03-27 19:07:54 +01:00
David Bauer e7c399bee6 filogic: add support for ASUS TUF-AX4200
Hardware
--------
SOC:   MediaTek MT7986
RAM:   512MB DDR3
FLASH: 256MB SPI-NAND (Winbond W25N02KV)
WIFI:  Mediatek MT7986 DBDC 802.11ax 2.4/5 GHz
ETH:   MediaTek MT7531 Switch
       MaxLinear GPY211C 2.5 N-Base-T PHY
UART:  3V3 115200 8N1 (Pinout silkscreened / Do not ocnnect VCC)

Installation
------------

1. Download the OpenWrt initramfs image. Copy the image to a TFTP server
   reachable at 192.168.1.66/24. Rename the image to tufax4200.bin.

2. Connect the TFTP server to the AX4200. Conect to the serial console,
   interrupt the autoboot process by pressing '4' when prompted.

3. Download & Boot the OpenWrt initramfs image.

   $ setenv ipaddr 192.168.1.1
   $ setenv serverip 192.168.1.66
   $ tftpboot 0x46000000 tufax4200.bin
   $ bootm 0x46000000

4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device
   using scp and install using sysupgrade.

   $ sysupgrade -n <path-to-sysupgrade.bin>

Missing features
----------------

 - The LAN port LEDs are driven by the switch but OpenWrt does not
   correctly configure the output.

Signed-off-by: David Bauer <mail@david-bauer.net>
2023-03-24 20:30:29 +01:00
Chuanhong Guo d29dbf052a
mediatek: drop redmi-ax6000 variant with modified env
This variant uses xiaomi factory u-boot and modified u-boot-env &
bootcmd.
By modifying uboot-env, the xiaomi firmware recovery provided in
the vendor u-boot doesn't work anymore. It's possible to put
u-boot into a state where it refuese to take any serial input.
If the u-boot is in this state, users can't restore their
firmware without taking the flash off the board.
We now have a -stock variant where the vendor u-boot is used in
a way that xiaomi firmware recovery still works, and a -ubootmod
variant where we get rid of all xiaomi components, have more
usable space and no uart console lock. These two should cover all
use cases and we don't need this variant anymore.
Drop this redmi-ax6000 variant. Existing users of this variant
should perform a u-boot mod or restore to the -stock layout.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2022-12-30 16:11:59 +08:00
Furong Xu 8bac5dc18a mediatek: add new layout for Xiaomi Redmi Router AX6000 for OpenWrt U-Boot
This new layout is only bootable with OpenWrt U-Boot. It reuses the
two crash partions and expands the ubi partion to the end of whole flash.

Do not use this layout with stock U-Boot!

Signed-off-by: Furong Xu <xfr@outlook.com>
2022-12-29 03:00:31 +00:00
Chen Minqiang 18bea173a6 mediatek: add alternative stock layout for Xiaomi Redmi Router AX6000
In this implementation, the flash partition layout is adjusted to avoid
modifying the uboot environment of mtdparts. This ensures that the 30M
ubi_kernel partition remains aligned with the stock ubi partition, and
the kernel volume is placed in it. This allows the stock uboot to boot
from it without changing the mtdparts, which is useful for reverting back
to the stock firmware using Xiaomi Firmware Tools. In actual testing,
modifying mtdparts has been found to break Xiaomi Firmware Tools.

1. use ARTIFACTS to generate initramfs-factory.ubi for easy installation.
2. The NAND flash layout is changed to allow for reverting back to the
   stock firmware.
3. Before performing sysupgrade, do some cleanup in platform_pre_upgrade
   to ensure a clean installation of OpenWRT.
4. Setup the uboot env to ensure that the system always boot, which can
   be helpful for users who may forget to do this before sysupgrade in
   the initramfs.

New flash instructions:
1. Gain ssh access. Please refer to:
   https://openwrt.org/toh/xiaomi/redmi_ax6000#installation)

2. Check which system current u-boot is loading from:
   COMMAND: `cat /proc/cmdline`
   sample OUTPUT: `console=ttyS0,115200n1 loglevel=8 firmware=1 uart_en=1`
   if firmware=1, current system is ubi1
   if firmware=0, current system is ubi0

3. Setup nvram and write the firmware:
   If the current system is ubi1, please set it up so that the next time
   it will boot from ubi, and write the firmware to ubi:
```
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=0
nvram set flag_last_success=0
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit
ubiformat /dev/mtd8 -y -f /tmp/initramfs-factory.ubi
```
   If the current system is ubi, please set it up so that the next time
   it will boot from ubi1, and write the firmware to ubi1:
```
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=1
nvram set flag_last_success=1
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit
ubiformat /dev/mtd9 -y -f /tmp/initramfs-factory.ubi
```

4. After rebooting, the system should now boot into the openwrt initramfs.
   Flash the squashfs-sysupgrade.bin via using ssh or luci.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```
Done.

For existing users of the Redmi AX6000 running OpenWrt, here are the steps to
switch to this new layout:

1. Flash initramfs-factory.ubi
```
mtd -r -e ubi write /tmp/initramfs-factory.ubi ubi
```

2. After rebooting, the system will boot into the new openwrt-initramfs.
Log in and perform a sysupgrade to complete the process.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2022-12-17 15:04:16 +08:00
Furong Xu d9e1362581 mediatek: add LED support for Xiaomi Redmi AX6000
add DT nodes and default package for the LEDs on Redmi AX6000

Signed-off-by: Furong Xu <xfr@outlook.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2022-12-16 21:42:02 +08:00
Felix Fietkau 4f1e54801e mediatek: drop the use of device tree overlays on mt7986a-rfb board
The boot loader does not support it. Instead make NAND the default image for
this board

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-11-09 20:43:45 +01:00
Chukun Pan 641e4f2f04 mediatek: add Xiaomi Redmi Router AX6000 support
Hardware specification:
  SoC: MediaTek MT7986A 4x A53
  Flash: ESMT F50L1G41LB 128 MB
  RAM: K4A4G165WF-BCWE 512 MB
  Ethernet: 4x 10/100/1000 Mbps
  WiFi1: MT7976GN 2.4GHz ax 4x4
  WiFi2: MT7976AN 5GHz ax 4x4
  Button: Mesh, Reset

Flash instructions:
  1. Gain ssh and serial port access, see the link below:
     https://openwrt.org/toh/xiaomi/redmi_ax6000#installation
  2. Use ssh or serial port to log in to the router, and
     execute the following command:
     nvram set boot_wait=on
     nvram set flag_boot_rootfs=0
     nvram set flag_boot_success=1
     nvram set flag_last_success=1
     nvram set flag_try_sys1_failed=8
     nvram set flag_try_sys2_failed=8
     nvram commit
  3. Set a static ip on the ethernet interface of your computer
     (e.g. default: ip 192.168.31.100, gateway 192.168.31.1)
  4. Download the initramfs image, rename it to initramfs.bin,
     and host it with the tftp server.
  5. Interrupt U-Boot and run these commands:
     setenv mtdparts nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),112640k(ubi)
     saveenv
     tftpboot initramfs.bin
     bootm
  6. After openwrt boots up, use scp or luci web
     to upload sysupgrade.bin to upgrade.

Revert to stock firmware:
  Restore mtdparts back to default, then use the
  vendor's recovery tool (Windows only).

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
2022-10-30 14:30:22 +00:00
Daniel Golle f38276c9be mediatek: filogic: enable thermal, I2C and PWM of the BPi-R3
Setup thermal zone, select pins and enabled drivers for I2C (on 26-pin
GPIO bank) and PWM (1x fan and 1x GPIO bank).

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-10-07 16:45:10 +01:00
Daniel Golle a34cd4f66a mediatek: bananapi-r3: remove kmod-btmtkuart from default packages
The package kmod-btmtkuart is specific for MT7622 and isn't available
for MT7986 (which doesn't have this built-in Bluetooth like MT7622).

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-09-10 03:23:20 +01:00
Daniel Golle 1a6f6a1e8c mediatek: bpi-r3: make initramfs/recovery optional
Only include recovery image in SD card image generated for the
BananaPi BPi-R3 if building with CONFIG_TARGET_ROOTFS_INITRAMFS.
This allows to build images larger than 32 MB (the limit for
initramfs/recovery image) by deselecting initramfs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-09-08 02:51:11 +01:00
Daniel Golle a96382c1bb mediatek: add support for Bananapi BPi-R3
The Bananapi BPi-R3 is a development router board built around the
MediaTek Filogic 830 (MT7986A) SoC.
The board can boot either from microSD, SPI-NAND, SPI-NOR or eMMC.
Only either SPI-NAND or SPI-NOR can be used at the same time, also only
either microSD or eMMC can be used. The various storage options can be
selected using small SMD switches on the board.

Specs:
 * MediaTek MT7986A (Filogic 830) 4x ARM Cortex A53
 * 4T4R 2.4G 802.11bgnax (MT7975N)
 * 4T4R 5G 802.11anac/ax (MT7975P)
 * 2 GB DDR4 RAM
 * 8 GB eMMC
 * 128 MB SPI-NAND flash
 * 32 MB SPI-NOR flash
 * on-board MT7531 GbE switch
 * 2x SFP+ (1 GbE / 2.5 GbE)
 * 5x GbE network port
 * miniPCIe slot (only USB 2.0 connected)
 * uSIM slot (connected to miniPCIe interface)
 * M.2 KEY-E PCIe interface (PCIe x2)
 * microSD card interface
 * 26 PIN GPIO

Hardware details: https://wiki.banana-pi.org/Banana_Pi_BPI-R3

Working:
 * all 4 boot methods incl. installation via U-Boot, sysupgrade, ...
 * copper LAN and WAN ports
 * SFP1 (connected to gmac1, eth1 in Linux)
 * WiFi
 * LEDs
 * Buttons
 * PSTORE/ramoops based dual-boot

Not Working (missing driver features):
 * SFP2 (connected to MT7531 switch)

Untested:
 * M.2/NGFF slot (PCIe x2)
 * mPCIe slot (USB 2.0 + SIM)

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-08-30 13:36:28 +01:00
Felix Fietkau cffc77ae55 mediatek: add filogic subtarget
Initially this covers MT7986 only, but it will later be expanded to cover other
Filogic branded platforms by MediaTek

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-08-28 20:33:15 +01:00