Setting up switch and wireless on MT7621

I'm porting OpenWRT to a custom device with custom partitions and currently I'm struggling with getting Ethernet and Wireless working. The problem is that I don't fully understand the underlying concepts of all that and experience the absence of at least mid-level complexity documentation.

/etc/board.d/02_network:

        case $board in
        <my-board>)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan1 wan2"
                ;;

/etc/board.json:

{
        "model": {
                "id": "<my-board>",
                "name": "<model-name>"
        },
        "network": {
                "lan": {
                        "ports": [
                                "lan1",
                                "lan2",
                                "lan3",
                                "lan4"
                        ],
                        "protocol": "static"
                },
                "wan": {
                        "ports": [
                                "wan1",
                                "wan2"
                        ],
                        "protocol": "dhcp"
                }
        },
        "system": {
                "compat_version": "1.1"
        }
}

Generated /etc/config/network file:

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd46:d76f:1b01::/48'
        option packet_steering '1'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config device
        option name 'br-wan'
        option type 'bridge'
        list ports 'wan1'
        list ports 'wan2'

config interface 'wan'
        option device 'br-wan'
        option proto 'dhcp'

config interface 'wan6'
        option device 'br-wan'
        option proto 'dhcpv6'

The output of ip link list (phy0-ap0 and phy1-ap0 are PCIe wireless devices):

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5: br-lan: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 72:2d:68:c4:37:6f brd ff:ff:ff:ff:ff:ff
6: phy0-ap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:00:00:00:00:49 brd ff:ff:ff:ff:ff:ff
7: phy1-ap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether f8:5e:3c:1e:57:e3 brd ff:ff:ff:ff:ff:ff

When I remove /etc/board.json and invoke board_detect, I get

Cannot parse config file '/etc/fw_env.config': No such file or directory
Failed to find NVMEM device

So what is the problem? How to get network working?

You need to add uboot env offsets, it does not work on most platforms.

Are MAC addresses and wifi powers and led blinks correct?

No, LEDs don't blink, as 1) there are no triggers set and 2) there are no interfaces. PCI WiFi devices send some messages in dmesg and I have phy0-ap0 and phy1-ap0, which must be them. Could you explain uboot env offsets in more details?

If you are very lucky the ubootenv offsets are printed in some obscure serial output of bootloader. Sometimes it is separate mtd, sometimes last blocks of uboot, sometimes something else.
I'd suggest making a new porting thread to get more input and get through faster.

Is there already firmware for this device ?
or are you making it from the ground up ?

The problem was not where I expected it to be. I assigned RGMII and MDIO to GPIO, and the switch couldn't claim these pins.

&state_default {
	gpio {
		/* groups = "wdt", "rgmii2", "jtag", "mdio", "uart3"; */
		groups = "wdt", "jtag", "uart3";
		function = "gpio";
	};
};

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.