filogic: support Telenor branded ZyXEL EX5700

Telenor quirks
--------------
The operator specific firmware running on the Telenor branded
ZyXEL EX5700 includes U-Boot modifications affecting the OpenWrt
installation.

Notable changes to U-Boot include
- environment is stored in RAM and reset to defaults when power
  cycled
- dual partition scheme with "nomimal" or "rescue" systems, falling
  back to "rescue" unless the OS signals success in 3 attempts
- several runtime additions to the device-tree

Some of these modifications have side effects requiring workarounds
- U-Boot modifies /chosen/bootargs in an unsafe manner, and will crash
  unless this node exists
- U-Boot verifies that the selected rootfs UBI volume exists, and
  refuses to boot if it doesn't. The chosen "rootfs" volume must contain
  a squashfs signature even for tftp or initramfs booting.
- U-Boot parses the "factoryparams" UBI volume, setting the "ethaddr"
  variable to the label mac.  But "factoryparams" does not always
  exist.  Instead there is a "RIP" volume containing all the factory
  data.  Copying the "RIP" volume to  "factoryparams" will fix this

Hardware
--------
SOC:   MediaTek MT7986
RAM:   1GB DDR4
FLASH: 512MB SPI-NAND (Mikron xxx)
WIFI:  Mediatek MT7986 802.11ax 5 GHz
       Mediatek MT7916 DBDC 802.11ax 2.4 + 6 GHz
ETH:   MediaTek MT7531 Switch + SoC
       3 x builtin 1G phy (lan1, lan2, lan3)
       2 x MaxLinear GPY211C 2.5 N-Base-T phy (lan4, wan)
USB:   1 x USB 3.2 Enhanced SuperSpeed port
UART:  3V3 115200 8N1 (Pinout: GND KEY RX TX VCC)

Installation
------------
1. Download the OpenWrt initramfs image. Copy the image to a TFTP server
   reachable at 192.168.1.2/24. Rename the image to C0A80101.img.

2. Connect the TFTP server to lan1, lan2 or lan3. Connect to the serial
   console, Interrupt the autoboot process by pressing ESC when prompted.

3. Download and boot the OpenWrt initramfs image.

   $ env set uboot_bootcount 0
   $ env set firmware nominal
   $ tftpboot
   $ 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>

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

- The "lan1", "lan2" and "lan3" port LEDs are driven by the switch but
  OpenWrt does not correctly configure the output.
- The "lan4" and "wan" port LEDs are driven by the GPH211C phys and
  not configured by OpenWrt.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
This commit is contained in:
Bjørn Mork 2023-03-28 15:04:21 +02:00 committed by Hauke Mehrtens
parent 1dd1ac2c35
commit 6cc14bf66a
4 changed files with 403 additions and 0 deletions

View File

@ -71,6 +71,9 @@ zyxel,ex5601-t0)
local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
;;
zyxel,ex5700-telenor)
ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
;;
esac
config_load ubootenv

View File

@ -0,0 +1,374 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include "mt7986a.dtsi"
/ {
model = "ZyXEL EX5700 (Telenor)";
compatible = "zyxel,ex5700-telenor", "mediatek,mt7986a";
aliases {
serial0 = &uart0;
ethernet0 = &gmac0;
led-boot = &led_status_green;
led-failsafe = &led_status_green;
led-running = &led_status_green;
led-upgrade = &led_status_amber;
};
chosen {
stdout-path = "serial0:115200n8";
// Stock U-Boot crashes unless /chosen/bootargs exists
bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8";
};
memory {
reg = <0 0x40000000 0 0x40000000>;
};
reg_3p3v: regulator-3p3v {
compatible = "regulator-fixed";
regulator-name = "fixed-3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
reg_5v: regulator-5v {
compatible = "regulator-fixed";
regulator-name = "fixed-5V";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-boot-on;
regulator-always-on;
};
keys {
compatible = "gpio-keys";
poll-interval = <20>;
reset-button {
label = "reset";
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
wps-button {
label = "wps";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
};
leds {
compatible = "gpio-leds";
red1 {
label = "red:net";
gpios = <&pio 23 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
green1 {
label = "green:net";
gpios = <&pio 25 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
amber1 {
label = "amber:net";
gpios = <&pio 29 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
white2 {
label = "white:status";
gpios = <&pio 16 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
red2 {
label = "red:status";
gpios = <&pio 17 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
led_status_green: green2 {
label = "green:status";
gpios = <&pio 31 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
led_status_amber: amber2 {
label = "amber:status";
gpios = <&pio 18 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
};
};
&eth {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&eth_pins>;
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
label = "wan";
phy-mode = "2500base-x";
phy-handle = <&phy6>;
};
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
};
};
&mdio {
reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>;
reset-delay-us = <50000>;
reset-post-delay-us = <20000>;
phy5: phy@5 {
compatible = "ethernet-phy-ieee802.3-c45";
reg = <5>;
};
phy6: phy@6 {
compatible = "ethernet-phy-ieee802.3-c45";
reg = <6>;
};
switch: switch@1f {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
interrupt-controller;
#interrupt-cells = <1>;
interrupt-parent = <&pio>;
interrupts = <66 IRQ_TYPE_LEVEL_HIGH>;
};
};
&switch {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan3";
};
port@1 {
reg = <1>;
label = "lan2";
};
port@2 {
reg = <2>;
label = "lan1";
};
port@5 {
reg = <5>;
label = "lan4";
phy-mode = "2500base-x";
phy-handle = <&phy5>;
};
port@6 {
reg = <6>;
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
&crypto {
status = "okay";
};
&pcie {
pinctrl-names = "default";
pinctrl-0 = <&pcie_pins>;
status = "okay";
pcie@0,0 {
reg = <0x0000 0 0 0 0>;
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0xa0000>;
};
};
};
&pcie_phy {
status = "okay";
};
&watchdog {
status = "okay";
};
&wifi {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&wf_5g_pins>;
mediatek,mtd-eeprom = <&factory 0x0>;
};
&pio {
eth_pins: eth-pins {
mux {
function = "eth";
groups = "switch_int", "mdc_mdio";
};
};
pcie_pins: pcie-pins {
mux {
function = "pcie";
groups = "pcie_pereset"; // "pcie_clk" and "pcie_wake" is unused?
};
};
spi_flash_pins: spi-flash-pins-33-to-38 {
mux {
function = "spi";
groups = "spi0", "spi0_wp_hold";
};
conf-pu {
pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
drive-strength = <8>;
mediatek,pull-up-adv = <0>; /* bias-disable */
};
conf-pd {
pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
drive-strength = <8>;
mediatek,pull-down-adv = <0>; /* bias-disable */
};
};
wf_5g_pins: wf_5g-pins {
mux {
function = "wifi";
groups = "wf_5g";
};
conf {
pins = "WF1_HB1", "WF1_HB2", "WF1_HB3", "WF1_HB4",
"WF1_HB0", "WF1_HB5", "WF1_HB6", "WF1_HB7",
"WF1_HB8", "WF1_TOP_CLK", "WF1_TOP_DATA";
drive-strength = <4>;
};
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi_flash_pins>;
cs-gpios = <0>, <0>;
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <20000000>;
};
flash@1 {
compatible = "spi-nand";
reg = <1>;
mediatek,nmbm;
mediatek,bmt-max-ratio = <1>;
mediatek,bmt-max-reserved-blocks = <64>;
spi-max-frequency = <20000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "BL2";
reg = <0x000000 0x100000>;
read-only;
};
partition@100000 {
label = "u-boot-env";
reg = <0x100000 0x80000>;
};
factory: partition@180000 {
label = "Factory";
reg = <0x180000 0x200000>;
read-only;
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
};
partition@380000 {
label = "FIP";
reg = <0x380000 0x200000>;
read-only;
};
partition@580000 {
label = "ubi";
reg = <0x580000 0x1da80000>;
};
};
};
};
&ssusb {
vusb33-supply = <&reg_3p3v>;
vbus-supply = <&reg_5v>;
status = "okay";
};
&trng {
status = "okay";
};
&uart0 {
status = "okay";
};
&usb_phy {
status = "okay";
};

View File

@ -0,0 +1,12 @@
#!/bin/sh /etc/rc.common
# SPDX-License-Identifier: GPL-2.0-only
START=99
boot() {
case $(board_name) in
zyxel,ex5700-telenor)
fw_setenv uboot_bootcount 0
;;
esac
}

View File

@ -509,6 +509,20 @@ define Device/zyxel_ex5601-t0-stock
endef
TARGET_DEVICES += zyxel_ex5601-t0-stock
define Device/zyxel_ex5700-telenor
DEVICE_VENDOR := ZyXEL
DEVICE_MODEL := EX5700 (Telenor)
DEVICE_DTS := mt7986a-zyxel-ex5700-telenor
DEVICE_DTS_DIR := ../dts
DEVICE_PACKAGES := kmod-mt7916-firmware kmod-ubootenv-nvram kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 65536k
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += zyxel_ex5700-telenor
define Device/zyxel_nwa50ax-pro
DEVICE_VENDOR := ZyXEL
DEVICE_MODEL := NWA50AX Pro