Help completing dts for ZyXEL WRE6505 (mt7620a + mt7610e)

Depending on what is in the U-Boot environment, something like

lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)

may resolve the MAC-address issue.

deleted. figured it out.

hexdump on mtd2 looks like a winner. The MAC 58 8b f3 9a 9d 3c is in the 00000020 row as well as at 0x4

Edit:
addr 0x00-0x01 is 7620 - this is the firmware for the 7620 2.4G wireless part.
addr 0x8000-0x8001 is 7610 - this is the firmware for the 7610 5G wireless part.

root@OpenWrt:/# hexdump  -C /dev/mtd2
00000000  20 76 05 01 58 8b f3 9a  9d 3c ff ff ff ff ff ff  | v..X....<......|
00000010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00000020  ff ff ff ff ff ff ff ff  58 8b f3 9a 9d 3c 00 0c  |........X....<..|
00000030  43 76 20 66 22 0c 00 20  00 ff 77 01 55 77 a8 aa  |Cv f".. ..w.Uw..|
00000040  8c 88 ff ff 0a 00 00 00  00 00 00 00 00 00 ff ff  |................|
00000050  82 00 0d 0d 0d 0d 0d 0d  0d 0d 0d 0d 0d 0d 0d 02  |................|
00000060  0f 03 03 03 03 03 10 03  03 03 03 03 10 03 82 f0  |................|
00000070  ea ed 7c 0b 0a 0e 00 00  ff ff ff ff ff ff ff ff  |..|.............|
00000080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
000000d0  1c ff ff ff ff ff ff ff  ff ff ff ff ff ff 05 05  |................|
000000e0  03 03 02 00 03 03 02 00  03 03 02 00 00 07 04 00  |................|
000000f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00008000  10 76 00 01 58 8b f3 9a  9d 3d 10 76 c3 14 00 00  |.v..X....=.v....|
00008010  00 00 10 76 c3 14 00 00  00 00 00 0c 43 46 00 01  |...v........CF..|
00008020  ff ff ff 1f ef ff 30 3e  3c 9b ff ff ff ff ff ff  |......0><.......|
00008030  ff ff ff ff 11 fd 02 00  ff ff 7f 01 ff ff 99 99  |................|
00008040  8c 88 ff 07 00 0b 00 00  00 0e 00 00 00 0d 00 00  |................|
00008050  ff ff 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00008060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 ff ff  |................|
00008070  ff ff ff ff ff ff ff ff  08 08 07 07 07 06 06 05  |................|
00008080  05 05 04 04 04 04 05 05  06 06 06 07 07 07 08 08  |................|
00008090  09 09 0a 0a 09 09 09 0a  0a 0a 0a 00 ff ff ff ff  |................|
000080a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
000080c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ef  |................|
000080d0  1a fa 00 82 00 ff ff ff  ff ff ff ff ff ff 04 04  |................|
000080e0  01 01 04 00 01 01 04 00  01 01 04 00 01 01 04 00  |................|
000080f0  80 80 80 80 f6 f9 fc 04  7f 7f 7f 7f 7f 7f 80 80  |................|
00008100  80 80 80 f3 f9 0a 7f 7f  7f 7f 7f 7f 80 f7 00 00  |................|
00008110  00 00 00 00 00 00 00 00  ff ff ff ff ff ff ff ff  |................|
00008120  04 04 04 00 04 04 04 00  00 00 00 00 00 00 00 ff  |................|
00008130  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00008200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00010000

This corresponds to the factory partition

So roughly in target/linux/ramips/base-files/etc/board.d/02_network

...
        zyxel,wre6505)
                lan_mac=$(mtd_get_mac_binary factory 4)
                wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 4)" 1)
...

Additionally, it would seem that this would also achieve the same result. Which should be used?

                wan_mac=$(mtd_get_mac_binary factory 0x8004)

Edit: added these to 02_network and no dice. But running those scripts pulls the correct MACs.

OK - permanent MACs problem solved. Added the following to the dts target/linux/ramips/dts/mt7620a_zyxel_wre6505.dts:

        ethernet@10100000 {
                mtd-mac-address = <&factory 0x4>;
        };

Edit: trying something similar for wifi. I added rt2800-pci-firmware kmod-rt2800-pci to the target/linux/ramips/image/mt7620.mk and even make menuconfig to elect in the rt2800-pci-firmware - no dice yet.

[    7.638200] ieee80211 phy0: rt2x00lib_request_eeprom_file: Info - Loading EEPROM data from 'soc_wmac.eeprom'.
[    7.658874] rt2800_wmac 10180000.wmac: Direct firmware load for soc_wmac.eeprom failed with error -2
[    7.677144] rt2800_wmac 10180000.wmac: Falling back to user helper
[    7.742784] firmware soc_wmac.eeprom: firmware_loading_store: map pages failed
[    7.757464] ieee80211 phy0: rt2x00lib_request_eeprom_file: Error - Failed to request EEPROM.
[    7.774374] rt2800_wmac: probe of 10180000.wmac failed with error -11
[    7.814168] kmodloader: done loading kernel modules from /etc/modules.d/*
1 Like

So with the 0-3 gpios defined in the dts, kernel like so

&gpio0 {
        status = "okay";
};

&gpio1 {
        status = "okay";
};

&gpio2 {
        status = "okay";
};

&gpio3 {
        status = "okay";
};

yields:

[    0.492943] rt2880_gpio 10000600.gpio: registering 24 gpios
[    0.503982] rt2880_gpio 10000600.gpio: registering 24 irq handlers
[    0.516556] rt2880_gpio 10000638.gpio: registering 16 gpios
[    0.527555] rt2880_gpio 10000638.gpio: registering 16 irq handlers
[    0.540147] rt2880_gpio 10000660.gpio: registering 32 gpios
[    0.551149] rt2880_gpio 10000660.gpio: registering 32 irq handlers
[    0.563722] rt2880_gpio 10000688.gpio: registering 1 gpios
[    0.574544] rt2880_gpio 10000688.gpio: registering 1 irq handlers

Some of those are 'busy' when probed, but nothing reveals any LEDs :confused:

Pick off the Ethernet MAC from sysfs, mac_addr_add, and stuff into the wireless MAC


Edit: For someone else finding this later:

$(macaddr_add "$(cat /sys/class/net/eth0/address)" <some offset>)

Didn't feel right to do that. I found this old link.

So I did this in the dts

        wmac@10180000 {
                ralink,mtd-eeprom = <&factory 0>;
        };

and kernel goes woooosh

[    7.644667] rt2800_wmac 10180000.wmac: loaded eeprom from mtd device "factory"
[    7.659144] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 6352, rev 0500 detected
[    7.674600] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 7620 detected

So I did this in the dts

        wmac@10180000 {
                ralink,mtd-eeprom = <&factory 0x8000>;
        };

and kernel goes

[    7.886071] rt2800_wmac 10180000.wmac: loaded eeprom from mtd device "factory"
[    7.900545] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 6352, rev 0500 detected
[    7.916004] ieee80211 phy0: rt2800_init_eeprom: Error - Invalid RF chipset 0x7610 detected
[    7.932486] ieee80211 phy0: rt2x00lib_probe_dev: Error - Failed to allocate device
root@OpenWrt:/# iwinfo
wlan0     ESSID: unknown
          Access Point: 58:8B:F3:9A:9D:3C
          Mode: Client  Channel: unknown (unknown)
          Tx-Power: 0 dBm  Link Quality: unknown/70
          Signal: unknown  Noise: unknown
          Bit Rate: unknown
          Encryption: unknown
          Type: nl80211  HW Mode(s): 802.11bgn
          Hardware: 14C3:7620 14C3:000C [MediaTek MT7620]
          TX power offset: none
          Frequency offset: none
          Supports VAPs: yes  PHY name: phy0

Bringing up wireless normally service network restart gives:

[  478.924420] ieee80211 phy0: rt2800_rf_self_txdc_cal: Info - RF Tx self calibration start
[  478.941103] ieee80211 phy0: rt2800_rf_self_txdc_cal: Info - RF Tx self calibration end
[  481.931970] ieee80211 phy0: rt2800_loft_iq_calibration: Info - LOFT Calibration Done!
[  481.951560] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Start!
[  481.979504] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Done! CH = 0, (gain= d, phase=3f)
[  481.998632] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Start!
[  482.026124] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Done! CH = 1, (gain= 0, phase=3c)
[  482.044365] ieee80211 phy0: rt2800_loft_iq_calibration: Info - TX IQ Calibration Done!
[  482.073706] ieee80211 phy0: rt2800_rxiq_calibration: Info - RXIQ G_imb=0, Ph_rx=-1
[  482.099055] ieee80211 phy0: rt2800_rxiq_calibration: Info - RXIQ G_imb=2, Ph_rx=3

Gonna have to play a bit to get the 7610e 5G part right.

1 Like

Where does the bridge init stuff go? It seems clear already that the LAN and WiFi will (have to) share a MAC. At least in this 'AP' mode it has.

OEM firmware has:



# ifconfig -a
apcli0    Link encap:Ethernet  HWaddr 5A:8B:F3:9A:9D:3C  
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

apclii0   Link encap:Ethernet  HWaddr 5A:8B:F3:98:9D:3D  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

apclii1   Link encap:Ethernet  HWaddr 5A:8B:F3:98:9D:3D  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

br0       Link encap:Ethernet  HWaddr 58:8B:F3:9A:9D:3C  
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:3584 (3.5 KiB)

br1       Link encap:Ethernet  HWaddr 58:8B:F3:9A:9D:3D  
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:3520 (3.4 KiB)

eth2      Link encap:Ethernet  HWaddr 58:8B:F3:9A:9D:3C  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:3860 (3.7 KiB)
          Interrupt:3 

lo        Link encap:Local Loopback  
          LOOPBACK  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ra0       Link encap:Ethernet  HWaddr 58:8B:F3:9A:9D:3C  
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:4 

rai0      Link encap:Ethernet  HWaddr 58:8B:F3:9A:9D:3D  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:13 

# ls /sys/class/net
apclii1  apcli0   br0      ra0      lo
apclii0  br1      rai0     eth2
# ls /sys/class/net/eth2
brport            dormant           link_mode         dev_id
statistics        duplex            type              addr_len
tx_queue_len      speed             features          addr_assign_type
flags             carrier           ifindex           subsystem
mtu               broadcast         iflink            uevent
operstate         address           ifalias
# brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.588bf39a9d3c	no		apcli0
							eth2
							ra0
							rai0
br1		8000.588bf39a9d3d	no		apclii0

Check the OEM firmware and see if the MAC address of the wireless is different than the Ethernet.

Switch config, when needed, is usually in 02_network

Bridge config, should be "auto-magical" once LAN is defined and wireless detection creates a template /etc/config/wireless

1 Like

Just pasted above: wireless + physical have the same MAC, in AP mode. In repeater mode I don't get a shell, and I think I don't get a phys link. Probably the 2.4GHz steals the show.

Figure 6 from the device PDF manual indicates that all 3 should work.

Yadda. 5G working. Just need to ensure you compile in the mt76x0e driver. ( make menuconfig -> kernel modules -> wireless drivers -> kmod-76x0e

DTS file addition:

&pcie0 {
        mt76@0,0 {
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x8000>;
                ieee80211-freq-limit = <5000000 6000000>;
                mtd-mac-address = <&factory 0x8004>;
                //mtd-mac-address-increment = <(-1)>;
        };
};

Kernel:

[    8.390577] mt76x0e 0000:01:00.0: card - bus=0x1, slot = 0x0 irq=4
[    8.403143] mt76x0e 0000:01:00.0: ASIC revision: 76100002
[    8.415481] mt76x0e 0000:01:00.0: Firmware Version: 0.1.00
[    8.512013] mt76x0e 0000:01:00.0: EEPROM ver:01 fae:00

then you can

root@OpenWrt:/# ifconfig wlan0 up

Standard /etc/config/wireless config will ensure config endures.

2 Likes

Not sure what that is (it might not exist in this case) - but I got the sources. Had a dig for everything that mentions GPIO stuff. It seems that all of the flashing LED things were done in some separate daemon/app. Not to mention for an older kernel.

I cannot seem to find a combination in the DTS file which doesn't produce something like:

[  136.754602] rt2880-pinmux pinctrl: pin 13 is not set to gpio mux
[  136.766647] rt2880-pinmux pinctrl: request() failed for pin 13
[  136.778303] rt2880-pinmux pinctrl: pin-13 (pio:13) status -22

DTS (probably got this wrong):

        keys {
                compatible = "gpio-keys-polled";
                poll-interval = <20>;

                //confirmed 0
                wps {
                        label = "wps";
                        gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_WPS_BUTTON>;
                };
                //there's the AP/repeater slide switch. Basically reboots the device.
        };

        leds {
                compatible = "gpio-leds";

                lan {
                        //ra ether 32-24;
                        label = "wre6505:green:lan";
                        gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
                };

                led_power: power {
                        label = "wre6505:green:power";
                        gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
                        //default-state = "keep";
                };

                //confirmed: 13
                wps {
                        label = "wre6505:blue:wps";
                        gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
                };
        };

        pinctrl {
                state_default: pinctrl0 {
                        gpio { //tried various combinations of this
                                //ralink,group = "i2c", "spi", "jtag", "mdio", "rgmii", "uartf";
                                ralink,group = "wled";
                                ralink,function = "gpio";
                        };
                        uartf {
                                ralink,group = "uartf";
                                ralink,function = "uartf";

                        };
                };
        };

help :confused:

Does the part compatible = "gpio-keys-polled"; mean that kmod-input-gpio-keys-polled should be built and loaded? If it is I just get log lines like:

[    8.692040] Error: Driver 'gpio-keys-polled' is already registered, aborting...

Try

        keys {
                compatible = "gpio-keys";
[...]
        };

Old-style kernel config, is a C file. See, for example

target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c

Edit: Which, for that device, includes information like

#define ARCHER_C7_GPIO_LED_WLAN2G       12
#define ARCHER_C7_GPIO_LED_SYSTEM       14
#define ARCHER_C7_GPIO_LED_QSS          15
#define ARCHER_C7_GPIO_LED_WLAN5G       17
#define ARCHER_C7_GPIO_LED_USB1         18
#define ARCHER_C7_GPIO_LED_USB2         19

#define ARCHER_C7_GPIO_BTN_RFKILL       23
#define ARCHER_C7_V2_GPIO_BTN_RFKILL    23
#define ARCHER_C7_GPIO_BTN_RESET        16

#define ARCHER_C7_GPIO_USB1_POWER       22
#define ARCHER_C7_GPIO_USB2_POWER       21

#define ARCHER_C7_KEYS_POLL_INTERVAL    20      /* msecs */
#define ARCHER_C7_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C7_KEYS_POLL_INTERVAL)

#define ARCHER_C7_WMAC_CALDATA_OFFSET   0x1000
#define ARCHER_C7_PCIE_CALDATA_OFFSET   0x5000
1 Like

Oh sweet. :slight_smile:
Altho the equivalent for ramips doesn't exist. Folder target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/ is fairly thin on the ground for mentions of gpio. But the patches folder.... hmm - this could be what I've been missing. I have no idea whether those patches have been applied at compile time or this is some sauce we add by hand. e.g.

target/linux/ramips/patches-4.14/0027-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch

Edit: seems to be. Just not obvious :confused:

Those are patches that OpenWrt supplies, yes.

The mach file would be in the OEM source.

You have to look it up in MT7620 datasheet/programming guide to figure out a correct pinctrl setting

Yeah, I figured out that much by myself. I've been reading the data-sheet, and I understand what's there, but this doesn't help me with the specifics of how this board is built, and to which GPIOs the LEDs and buttons are connected... I'm under the impression that once you've specced the LEDs and their pins correctly in the DTS, OWRT takes care of the rest, right?

No mach file in the source, as I can see. :frowning: From what kernel version did the mach file syntax appear? The source was built against 2.6.

“mach” files are the old way, DTS is current

OK, after some DTS fun, all LEDs light up and flash, everything is working. Buttons don't seem to be a thing people want much... but when they do, they want them baaad. :smiley:

In case anyone else is interested to do something with this device, the relevant files should be here in my repo.. Special thanks to @jeff for the pointers.

One issue I don't think I ever managed to get past was having the original firmware accept an owrt compiled image for flashing. There was always something about the magic that I tried to insert that it did not like. I tried this to suit what I found in the original source. Maybe others with firmware magic experience have some good ideas?