Ethernet issue on MT7620 board after installing custom firmware

Hello, dear developpers,

I am trying to recreate a firmware on a 2015's router model we want to sell (model is :Ralink MT7620a V22SG)
We don't have the original source files so, I used an imagebuilder version close to what is originally installed.
The firmware is copied without apparent errors via sysupgrade, I manage to get the LAN working and to use the lucy application.
I am getting an issue with the WAN interface that seems to be running but, when doing "ping 8.8.8.8", I get 100% packet loss, and the connection doesn't seems to work.

I tried to modify the configuration files many times but I still have the issue. Thank you by advance, if someone have an idea that could clarify my understanding of the problem.

Configuration files, drivers are the same as the original one, so, I can't figure out what is wrong with the compilation.

Best Regards.

Here are some complementary informations :

//********************* SYSTEM BOARD ************************************************

root@OpenWrt:/etc# ubus call system board

- Original firmware : 

{
        "kernel": "3.18.20",
        "hostname": "OpenWrt",
        "system": "Ralink MT7620A ver:2 eco:6",
        "model": "Ralink MT7620a V22SG",
        "release": {
                "distribution": "OpenWrt",
                "version": "Chaos Calmer",
                "revision": "r46822",
                "codename": "chaos_calmer",
                "target": "ramips\/mt7620",
                "description": "OpenWrt Chaos Calmer 15.05"
        }
}


- Replacement firmware:

{
        "kernel": "3.18.109",
        "hostname": "OpenWrt",
        "system": "MediaTek MT7620A ver:2 eco:6",
        "model": "Ralink MT7620a V22SG High Power evaluation board",
        "release": {
                "distribution": "OpenWrt",
                "version": "Chaos Calmer",
                "revision": "r49632",
                "codename": "chaos_calmer",
                "target": "ramips\/mt7620",
                "description": "OpenWrt Chaos Calmer 15.05.1"
        }
}


//********************* DIAGNOSTICS ************************************************


root@OpenWrt:/# uci export network; uci export dhcp; uci export firewall; \
> head -n -0 /etc/firewall.user; \
> iptables-save -c; ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
> ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/* ; head -n -0 /etc/resolv.*
/tmp/resolv.* /tmp/resolv.*/*
{
        "kernel": "3.18.109",
        "hostname": "OpenWrt",
        "system": "MediaTek MT7620A ver:2 eco:6",
        "model": "Ralink MT7620a V22SG High Power evaluation board",
        "release": {
                "distribution": "OpenWrt",
                "version": "Chaos Calmer",
                "revision": "r49632",
                "codename": "chaos_calmer",
                "target": "ramips\/mt7620",
                "description": "OpenWrt Chaos Calmer 15.05.1"
        }
}
package network

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

config globals 'globals'
        option ula_prefix 'fd17:975b:bd8c::/48'

config interface 'lan'
        option macaddr '00:11:22:F0:00:17'
        option proto 'static'
        option ipaddr '172.16.254.200'
        option netmask '255.255.255.0'
        option force_link '1'

config interface 'wan'
        option macaddr '52:1F:10:C7:27:64'
        option proto 'static'
        option ipaddr '192.168.12.110'
        option netmask '255.255.255.0'
        option gateway '192.168.12.254'
        option ifname 'eth0.2'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 1 2 3 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '4 6t'

package dhcp

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
        option localservice '1'

config dhcp 'lan'
        option interface 'lan'
        option start '257'
        option limit '2557'
        option dhcpv6 'server'
        option ra 'server'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'

package firewall

config defaults
        option syn_flood '1'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'REJECT'

config zone
        option name 'lan'
        list network 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'

config zone
        option name 'wan'
        list network 'wan'
        list network 'wan6'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fe80::/10'
        option src_port '547'
        option dest_ip 'fe80::/10'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config include
        option path '/etc/firewall.user'

config rule
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.

# Internal uci firewall chains are flushed and recreated on reload, so
# put custom rules into the root chains e.g. INPUT or FORWARD or into the
# special user chains, e.g. input_wan_rule or postrouting_lan_rule.
# Generated by iptables-save v1.4.21 on Thu Jun  2 10:08:49 2022
*nat
:PREROUTING ACCEPT [227:31411]
:INPUT ACCEPT [116:7933]
:OUTPUT ACCEPT [241:16665]
:POSTROUTING ACCEPT [241:16665]
:delegate_postrouting - [0:0]
:delegate_prerouting - [0:0]
:postrouting_lan_rule - [0:0]
:postrouting_rule - [0:0]
:postrouting_wan_rule - [0:0]
:prerouting_lan_rule - [0:0]
:prerouting_rule - [0:0]
:prerouting_wan_rule - [0:0]
:zone_lan_postrouting - [0:0]
:zone_lan_prerouting - [0:0]
:zone_wan_postrouting - [0:0]
:zone_wan_prerouting - [0:0]
[227:31411] -A PREROUTING -j delegate_prerouting
[264:17861] -A POSTROUTING -j delegate_postrouting
[264:17861] -A delegate_postrouting -m comment --comment "user chain for postrouting" -j postrouting_rule
[1:345] -A delegate_postrouting -o wlan0 -j zone_lan_postrouting
[23:1196] -A delegate_postrouting -o eth0.2 -j zone_wan_postrouting
[227:31411] -A delegate_prerouting -m comment --comment "user chain for prerouting" -j prerouting_rule
[227:31411] -A delegate_prerouting -i wlan0 -j zone_lan_prerouting
[0:0] -A delegate_prerouting -i eth0.2 -j zone_wan_prerouting
[1:345] -A zone_lan_postrouting -m comment --comment "user chain for postrouting" -j postrouting_lan_rule
[227:31411] -A zone_lan_prerouting -m comment --comment "user chain for prerouting" -j prerouting_lan_rule
[23:1196] -A zone_wan_postrouting -m comment --comment "user chain for postrouting" -j postrouting_wan_rule
[23:1196] -A zone_wan_postrouting -j MASQUERADE
[0:0] -A zone_wan_prerouting -m comment --comment "user chain for prerouting" -j prerouting_wan_rule
COMMIT
# Completed on Thu Jun  2 10:08:49 2022
# Generated by iptables-save v1.4.21 on Thu Jun  2 10:08:49 2022
*raw
:PREROUTING ACCEPT [1381:125309]
:OUTPUT ACCEPT [1320:264619]
:delegate_notrack - [0:0]
[1381:125309] -A PREROUTING -j delegate_notrack
COMMIT
# Completed on Thu Jun  2 10:08:49 2022
# Generated by iptables-save v1.4.21 on Thu Jun  2 10:08:49 2022
*mangle
:PREROUTING ACCEPT [1381:125309]
:INPUT ACCEPT [1148:95487]
:FORWARD ACCEPT [145:7540]
:OUTPUT ACCEPT [1320:264619]
:POSTROUTING ACCEPT [1465:272159]
:fwmark - [0:0]
:mssfix - [0:0]
[1381:125309] -A PREROUTING -j fwmark
[145:7540] -A FORWARD -j mssfix
[145:7540] -A mssfix -o eth0.2 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "wan (mtu_fix)" -j TCPMSS --clamp-mss-to-pmtu
COMMIT
# Completed on Thu Jun  2 10:08:49 2022
# Generated by iptables-save v1.4.21 on Thu Jun  2 10:08:49 2022
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:delegate_forward - [0:0]
:delegate_input - [0:0]
:delegate_output - [0:0]
:forwarding_lan_rule - [0:0]
:forwarding_rule - [0:0]
:forwarding_wan_rule - [0:0]
:input_lan_rule - [0:0]
:input_rule - [0:0]
:input_wan_rule - [0:0]
:output_lan_rule - [0:0]
:output_rule - [0:0]
:output_wan_rule - [0:0]
:reject - [0:0]
:syn_flood - [0:0]
:zone_lan_dest_ACCEPT - [0:0]
:zone_lan_forward - [0:0]
:zone_lan_input - [0:0]
:zone_lan_output - [0:0]
:zone_lan_src_ACCEPT - [0:0]
:zone_wan_dest_ACCEPT - [0:0]
:zone_wan_dest_REJECT - [0:0]
:zone_wan_forward - [0:0]
:zone_wan_input - [0:0]
:zone_wan_output - [0:0]
:zone_wan_src_REJECT - [0:0]
[1148:95487] -A INPUT -j delegate_input
[145:7540] -A FORWARD -j delegate_forward
[1320:264619] -A OUTPUT -j delegate_output
[145:7540] -A delegate_forward -m comment --comment "user chain for forwarding" -j forwarding_rule
[0:0] -A delegate_forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[145:7540] -A delegate_forward -i wlan0 -j zone_lan_forward
[0:0] -A delegate_forward -i eth0.2 -j zone_wan_forward
[0:0] -A delegate_forward -j reject
[480:32640] -A delegate_input -i lo -j ACCEPT
[668:62847] -A delegate_input -m comment --comment "user chain for input" -j input_rule
[526:52038] -A delegate_input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[18:936] -A delegate_input -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn_flood
[142:10809] -A delegate_input -i wlan0 -j zone_lan_input
[0:0] -A delegate_input -i eth0.2 -j zone_wan_input
[600:42240] -A delegate_output -o lo -j ACCEPT
[720:222379] -A delegate_output -m comment --comment "user chain for output" -j output_rule
[717:221344] -A delegate_output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[3:1035] -A delegate_output -o wlan0 -j zone_lan_output
[0:0] -A delegate_output -o eth0.2 -j zone_wan_output
[0:0] -A reject -p tcp -j REJECT --reject-with tcp-reset
[0:0] -A reject -j REJECT --reject-with icmp-port-unreachable
[18:936] -A syn_flood -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m limit --limit 25/sec --limit-burst 50 -j RETURN
[0:0] -A syn_flood -j DROP
[3:1035] -A zone_lan_dest_ACCEPT -o wlan0 -j ACCEPT
[145:7540] -A zone_lan_forward -m comment --comment "user chain for forwarding" -j forwarding_lan_rule
[145:7540] -A zone_lan_forward -m comment --comment "forwarding lan -> wan" -j zone_wan_dest_ACCEPT
[0:0] -A zone_lan_forward -m conntrack --ctstate DNAT -m comment --comment "Accept port forwards" -j ACCEPT
[0:0] -A zone_lan_forward -j zone_lan_dest_ACCEPT
[142:10809] -A zone_lan_input -m comment --comment "user chain for input" -j input_lan_rule
[0:0] -A zone_lan_input -m conntrack --ctstate DNAT -m comment --comment "Accept port redirections" -j ACCEPT
[142:10809] -A zone_lan_input -j zone_lan_src_ACCEPT
[3:1035] -A zone_lan_output -m comment --comment "user chain for output" -j output_lan_rule
[3:1035] -A zone_lan_output -j zone_lan_dest_ACCEPT
[142:10809] -A zone_lan_src_ACCEPT -i wlan0 -j ACCEPT
[145:7540] -A zone_wan_dest_ACCEPT -o eth0.2 -j ACCEPT
[0:0] -A zone_wan_dest_REJECT -o eth0.2 -j reject
[0:0] -A zone_wan_forward -m comment --comment "user chain for forwarding" -j forwarding_wan_rule
[0:0] -A zone_wan_forward -p esp -m comment --comment "@rule[7]" -j zone_lan_dest_ACCEPT
[0:0] -A zone_wan_forward -p udp -m udp --dport 500 -m comment --comment "@rule[8]" -j zone_lan_dest_ACCEPT
[0:0] -A zone_wan_forward -m conntrack --ctstate DNAT -m comment --comment "Accept port forwards" -j ACCEPT
[0:0] -A zone_wan_forward -j zone_wan_dest_REJECT
[0:0] -A zone_wan_input -m comment --comment "user chain for input" -j input_wan_rule
[0:0] -A zone_wan_input -p udp -m udp --dport 68 -m comment --comment Allow-DHCP-Renew -j ACCEPT
[0:0] -A zone_wan_input -p icmp -m icmp --icmp-type 8 -m comment --comment Allow-Ping -j ACCEPT
[0:0] -A zone_wan_input -p igmp -m comment --comment Allow-IGMP -j ACCEPT
[0:0] -A zone_wan_input -m conntrack --ctstate DNAT -m comment --comment "Accept port redirections" -j ACCEPT
[0:0] -A zone_wan_input -j zone_wan_src_REJECT
[0:0] -A zone_wan_output -m comment --comment "user chain for output" -j output_wan_rule
[0:0] -A zone_wan_output -j zone_wan_dest_ACCEPT
[0:0] -A zone_wan_src_REJECT -i eth0.2 -j reject
COMMIT
# Completed on Thu Jun  2 10:08:49 2022
/bin/ash: ip: not found
/bin/ash: ip: not found
/bin/ash: ip: not found
ls: /tmp/resolv.*/*: No such file or directory
lrwxrwxrwx    1 root     root            16 Jun  2 10:02 /etc/resolv.conf -> /tmp/resolv.conf
-rw-r--r--    1 root     root           114 Jun  2 10:03 /tmp/resolv.conf
-rw-r--r--    1 root     root             0 Jun  2 10:02 /tmp/resolv.conf.auto
==> /etc/resolv.conf <==
# Generated by dhcpcd
# /etc/resolv.conf.head can replace this line
# /etc/resolv.conf.tail can replace this line

==> /tmp/resolv.conf <==
# Generated by dhcpcd
# /etc/resolv.conf.head can replace this line
# /etc/resolv.conf.tail can replace this line

==> /tmp/resolv.conf.auto <==
head: /tmp/resolv.*/*: No such file or directory


//********************* NETWORK CONFIGURATION ************************************************

root@OpenWrt:/# ifconfig
eth0      Link encap:Ethernet  HWaddr EE:2A:D4:5D:9A:ED
          inet addr:169.254.190.124  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::3d71:79b5:5b4f:11e/64 Scope:Link
          inet6 addr: fe80::ec2a:d4ff:fe5d:9aed/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:12943 (12.6 KiB)
          Interrupt:5

eth0.2    Link encap:Ethernet  HWaddr 52:1F:10:C7:27:64
          inet addr:192.168.12.110  Bcast:192.168.12.255  Mask:255.255.255.0
          inet6 addr: fe80::501f:10ff:fec7:2764/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:6484 (6.3 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:384 errors:0 dropped:0 overruns:0 frame:0
          TX packets:384 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:26112 (25.5 KiB)  TX bytes:26112 (25.5 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:11:22:F0:00:17
          inet addr:172.16.254.200  Bcast:172.16.254.255  Mask:255.255.255.0
          inet6 addr: fe80::211:22ff:fef0:17/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:982 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1061 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:127441 (124.4 KiB)  TX bytes:300943 (293.8 KiB)

Found your old thread just for perspective.

I get the idea that you want to mimic to something that worked earlier as in the older "Chaos Chalmer" release, but do you atleast have a git repository with the changes you made earlier?

Do you have real seperate ethernet interfaces in your device for WAN and LAN, or a builtin switch with just vlans to seperate ports? Does the WAN configuration work on the old firmware and whats the output of swconfig in the "old firmware" (if the device uses a switch) the same as "your own custom firmware"?

Found this:

https://downloads.openwrt.org/releases/21.02.0-rc2/targets/ramips/mt7620/openwrt-21.02.0-rc2-ramips-mt7620-ralink_mt7620a-v22sg-evb-squashfs-sysupgrade.bin

Hello walterav,

Thank you for your reply.
To give you an idea of the context :
My boss ordered the developping and manufacturing of the router 7 years ago.
The manufacturer has never sent us the firmware sources nor used a git repository, so we only access files using telnet connection via serial the port of the hardware.
There were custom files that were added, end the board has also been customized too, so I had to change the kernel, factory, firmware hexadecimal addresses to fit the hardware ones.

I don't really Know if there are separate interfaces, I only know that there is a TRXCOM controller :

image

But I noticed that on the original working firmware the hardware MAC addresses are the same but not on the customized one:

Original firmware

eth0      Link encap:Ethernet  HWaddr 80:0A:80:10:09:2D
          ...

eth0.2    Link encap:Ethernet  HWaddr 80:0A:80:10:09:2D
          inet addr:192.168.12.2  Bcast:192.168.12.255  Mask:255.255.255.0
          ...

wlan0     Link encap:Ethernet  HWaddr 80:0A:80:10:09:2D
          inet addr:172.16.254.254  Bcast:172.16.254.255  Mask:255.255.255.0
          ...

Custom firmware :

root@OpenWrt:/# ifconfig
eth0      Link encap:Ethernet  HWaddr 8A:E9:FC:74:EB:83
          ...

eth0.2    Link encap:Ethernet  HWaddr 8A:E9:FC:74:EB:83          ...
          ...

wlan0     Link encap:Ethernet  HWaddr 00:11:22:F0:00:17
          ...

In dhcp mode I have bad IP addresses , only with the customized firmware :

eth0      Link encap:Ethernet  HWaddr 8A:E9:FC:74:EB:83
          inet addr:169.254.188.64  Bcast:169.254.255.255  Mask:255.255.0.0
	  ...	

eth0.2    Link encap:Ethernet  HWaddr 8A:E9:FC:74:EB:83
          inet addr:169.254.11.119  Bcast:169.254.255.255  Mask:255.255.0.0
          ...

Other diagnostics are confirming the WAN issues :

root@OpenWrt:/# swconfig dev switch0 show

on custom firmware :
...
Port 4:
        pvid: 2
        link: port:4 link:down
...


on original firmware :
...
Port 4:
        pvid: 2
        link: port:4 link:up speed:100baseT full-duplex
...

This is what I go at the moment. I will search if there separate ports as I don't have the information at the moment.

Thanks. Best Regards,

Hello F5BJR,

Thank you for your reply.

Indeed I plan to upgrade the firmware in the future. At the moment, as I don't have the original firmware, I need to recreate it as close as possible, in order to duplicate files and configuration.
I will have to use the imagebuilder as the hardware is a customized version made by the manufacturer that not exactly matches the original model.

Best Regards,

You can found values in dts with dtc:

opkg update
opkg install dtc
dtc -I fs /proc/device-tree

--
Question:
why would you want to sell this old router that hardly anyone will want ?

1 Like

Hello,

Thank you F5BJR for your reply, I will check.

My boss has a stock of these routers that represent a certain amount of money, so he asked me to find a solution to add new functionalities in order to sell them again.

Best Regards

Hello,

Sorry, I forgot last time to show the output of swconfig for the old hardware

root@OpenWrt:~# swconfig list
Found: switch0 - mt7620

Update : My boss gave me more information concerning the hardware. It is a modified version of a commercial RF/Wifi converter which didn't had initially an ethernet port. It has been added to the board. So that leads to conclude that there is a physical separation between WAN and LAN switches.

Best Regards,

Not the conclusion I would make, since your earlier logs still only shows one single ethernet interface to the system/cpu itself being eth0.

The eth0.2 is probably a vlan interface on that interface connected to a switch chip (maybe integrated in mt7620) and than physically wired to a RJ45 port. So adding physically a RJ45 connector won't necessary give you a real extra ethernet adapter/interface like eth1.

But if you use a switch and or the integrated switch inside the mt7620 you also need the correct CODE to setup the switch ports so the internal cpu eth0 gets the right external physical RJ45 port / connection.

Could you answer @anon69880279 his dts/devicetree question and could you also give the output of:

cat /etc/board.json

cat /etc/board.d/02_network

#perhaps anything in the board.d folder can be usefull?

Again do you have git source for your custom patches?

Hello walterav,

Thank you for your reply.
I will need to investigate more because I have no idea about what the manufacturer made when they added the ethernet port to the board (the initial board commercial name Home Comfort WRC-300).

I tried to do "opkg install dtc" like F5BJR suggested, but there are no dts package for such an old firmware version.

I don't have a git repository for the moment. I will look to make one with what I have done yet.

Question : what do you mean by "the correct CODE" ?

Here are the output of the commands you asked

Best Regards,

1- output of "root@OpenWrt:~# cat /etc/board.json"


{
        "led": {
                "wifi_led": {
                        "name": "wifi",
                        "type": "netdev",
                        "sysfs": "ikim:blue:wifi",
                        "device": "wlan0"
                }
        },
        "network": {
                "lan": {
                        "ifname": "eth0",
                        "create_vlan": true,
                        "macaddr": "80:0a:80:10:00:00"
                },
                "wan": {
                        "ifname": "eth0",
                        "create_vlan": true,
                        "macaddr": "80:0a:80:10:00:01"
                }
        },
        "switch": {
                "switch0": {
                        "enable": true,
                        "reset": true,
                        "vlans": {
                                "lan": [
                                        0,
                                        1,
                                        2,
                                        3
                                ],
                                "wan": [
                                        4
                                ]
                        },
                        "cpu_port": 6
                }
        }
}

2 - output of "root@OpenWrt:~# cat /etc/board.d/02_network"

#!/bin/sh

. /lib/functions.sh
. /lib/ramips.sh
. /lib/functions/uci-defaults-new.sh
. /lib/functions/system.sh

ramips_setup_rt3x5x_vlans()
{
        if [ ! -x /sbin/swconfig ]; then
                # legacy default
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                return
        fi
        local wanports=""
        local lanports=""
        for port in 5 4 3 2 1 0; do
                if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
                        continue
                fi
                if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
                        wanports="$port $wanports"
                else
                        lanports="$port $lanports"
                fi
        done
        ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
        ucidef_add_switch "rt305x" "1" "1"
        ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
        ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
}

ramips_setup_interfaces()
{
        local board="$1"

        ucidef_set_interface_loopback

        case $board in
        a5-v11)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ;;

        3g150b | \
        3g300m | \
        microwrt | \
        w150m | \
        zte-q7 | \
        all0256n | \
        all5002 | \
        all5003 | \
        broadway | \
        dcs-930| \
        dcs-930l-b1| \
        ht-tm02| \
        ncs601w | \
        wnce2001)
                ucidef_add_switch "switch0" "1" "0"
                ucidef_set_interface_lan "eth0"
                ;;

        3g-6200nl | \
        mlw221 | \
        mr-102n)
                ucidef_set_interface_lan "eth0.2"
                ;;
        mlwg2)
                ucidef_set_interface_lan "eth0.1"
                ;;

        m2m)
                ucidef_add_switch "switch0" "4"
                ucidef_set_interface_lan "eth0"
                ;;

        wizard8800 | \
        wl-330n | \
        wmr300)
                ucidef_set_interface_lan "eth0.1"
                ;;

        b2c | \
        nw718 | \
        psr-680w | \
        sl-r7205 | \
        w502u | \
        wr6202)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ;;

        awapn2403)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ucidef_add_switch_vlan "switch0" "2" "1 6t"
                ;;

        br-6475nd)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
                ucidef_add_switch_vlan "switch0" "2" "0 9t"
                ;;

        re6500 | \
        asl26555)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
                ;;

        cf-wr800n)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "4 6t"
                ;;

        cy-swr1100)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
                ucidef_add_switch_vlan "switch0" "2" "4 9t"
                ;;

        3g-6200n | \
        ai-br100 | \
        dir-610-a1 | \
        dir-300-b7 | \
        dir-320-b1 | \
        dir-615-h1 | \
        firewrt | \
        pbr-m1 | \
        hlk-rm04 | \
        mt7621 | \
        mt7628 | \
        mzk-w300nh2 | \
        mzk-750dhp | \
        whr-300hp2 | \
        whr-600d | \
        wsr-600 | \
        wsr-1166 | \
        wt1520 | \
        xiaomi-miwifi-mini |\
        y1)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        v22sg)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        whr-1166d)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "5 6t"
                ;;

        awm002-evb | \
        awm003-evb | \
        argus-atp52b | \
        dir-645 | \
        dir-860l-b1 | \
        f5d8235-v1 | \
        f5d8235-v2 | \
        hg255d | \
        rt-n14u | \
        wrtnode | \
        wt3020 | \
        ur-326n4g | \
        zbt-wa05)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;

        ur-336un)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ;;

        br6524n | \
        v11st-fe)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
                ucidef_add_switch_vlan "switch0" "2" "0 5t"
                ;;

        ar670w | \
        ar725w | \
        rt-n15 | \
        wl-351)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
                ucidef_add_switch_vlan "switch0" "2" "4 5t"
                ;;

        rt-n56u)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
                ucidef_add_switch_vlan "switch0" "2" "4 8t"
                ;;

        tew-691gr|\
        tew-692gr)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
                ucidef_add_switch_vlan "switch0" "2" "0t 5"
                ;;

        vocore)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
                ;;

        wcr-150gn)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ucidef_add_switch_vlan "switch0" "2" "6t"
                ;;

        wr8305rt)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        y1s)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;
        d105 | \
        na930 | \
        omni-emb-hpm|\
        wli-tx4-ag300n)
                ucidef_set_interface_lan "eth0"
                ;;

        e1700 | \
        mt7620a_mt7530)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch1" "1" "1"
                ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch1" "2" "4 6t"
                ;;

        wzr-agl300nh)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
                ucidef_add_switch_vlan "switch0" "2" "0 5t"
                ;;
        *)
                RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
                if [ -n "${RT3X5X}" ]; then
                        ramips_setup_rt3x5x_vlans
                else
                        ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                fi
                ;;
        esac
}

ramips_setup_macs()
{
        local board="$1"
        local lan_mac=""
        local wan_mac=""

        case $board in
        br-6475nd)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(mtd_get_mac_binary devdata 7)
                ;;

        w306r-v20)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 5)
                ;;

        tew-691gr)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 3)
                ;;

        tew-692gr)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 4)
                ;;

        m3 |\
        m4 |\
        x5 |\
        x8)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_add "$lan_mac" -2)
                ;;

        a5-v11 |\
        bc2 |\
        broadway |\
        d105 |\
        dir-620-a1 |\
        esr-9753 |\
        freestation5 |\
        hlk-rm04 | \
        mpr-a1 | \
        mpr-a2 | \
        dir-300-b7 | \
        dir-320-b1 | \
        psr-680w |\
        sl-r7205 |\
        y1 |\
        y1s)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_setbit_la "$lan_mac")
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;

        ht-tm02)
                lan_mac=$(cat /sys/class/net/eth0/address)
                ;;

        cy-swr1100 | \
        dir-645)
                lan_mac=$(mtd_get_mac_ascii nvram lanmac)
                wan_mac=$(mtd_get_mac_ascii nvram wanmac)
                ;;

        e1700)
                wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
                ;;

        wcr-150gn)
                wan_mac=$(mtd_get_mac_binary factory 40)
                ;;

        rt-n56u)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_setbit_la "$lan_mac")
                wan_mac=$(mtd_get_mac_binary factory 32772)
                ;;

        all0239-3g | \
        carambola | \
        freestation5 | \
        w502u | \
        wnce2001)
                wan_mac=$(mtd_get_mac_binary factory 46)
                ;;

        wsr-600|whr-300hp2|whr-600d|whr-1166d)
                wan_mac=$(mtd_get_mac_binary factory 4)
                lan_mac=$wan_mac
                ;;
        wsr-1166)
                local index="$(find_mtd_index "board_data")"
                wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
                lan_mac=$wan_mac
                ;;
        *)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;

        esac

        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
        [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
}

board_config_update
board=$(ramips_board_name)
ramips_setup_interfaces $board
ramips_setup_macs $board
board_config_flush

exit 0

Hello F5BJR,

I tried to do "opkg install dts" on the original firmware as you suggested but, it seems that unfortunately the firmware version on the board doesn't have a dts package available.

Anyway thank you for the suggestion.

Best regards,

@anon69880279 the dtc package is missing from Chaos Chalmer compared to latest:
https://archive.openwrt.org/chaos_calmer/15.05/ramips/mt7620/packages/
https://downloads.openwrt.org/releases/21.02.3/packages/mipsel_24kc/base/

Is it an option to just cat or dd /proc/device-tree and do the decompile on a different machine as in upload dts-file to forum?

cat /proc/device-tree > /tmp/dts-file

@Ced27
Could you atleast run every command asked in this thread on both your orignal firmware and the custom one you did? Also editing your first topic, with clear distinction between output of the original and custom compiled would help.

Having these command output as files and diff firmwarex firmwarey as in would give you alot more insight. BTW any way of reading cat /proc/mtd and maybe fw / bootloader variables?

OK, I will update the info on the thread.
But as far as I have seen by comparing both, except the MAC addresses, all scripts and files seems to be identical, which doesn't help a lot.

Best Regards

I am starting to wonder if a change of RAM location 0x... could cause the issue.
Here are the results of /proc/mtd for both the firmwares. There are differences in locations as the custom firmware is not an exact replication.
There may be something I miss in the .dts file that force the RAM location of 'some' component that is necessary for ethernet connexion to work, as I don't see where any other customization (at device level) could be possible...

ORIGINAL :

root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "u-boot"
mtd1: 00080000 00020000 "u-boot-env"
mtd2: 00040000 00020000 "factory"
mtd3: 07ec0000 00020000 "firmware"
mtd4: 001159f4 00020000 "kernel"
mtd5: 07daa60c 00020000 "rootfs"
mtd6: 064a0000 00020000 "rootfs_data"
CUSTOM

root@OpenWrt:/etc/board.d#  cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "u-boot"
mtd1: 00080000 00020000 "u-boot-env"
mtd2: 00040000 00020000 "factory"
mtd3: 07ec0000 00020000 "firmware"
mtd4: 001173b4 00020000 "kernel"
mtd5: 07da8c4c 00020000 "rootfs"
mtd6: 07b20000 00020000 "rootfs_data"

Note : my access to bootloader variable is fairly limited. I have only access to printenv via serial port but nothing really meaningfull

U-Boot 1.1.3 (Aug 26 2015 - 11:07:38)
MT7620 # help
?       - alias for 'help'
bootm   - boot application image from memory
go      - start application at address 'addr'
help    - print online help
md      - memory display
mdio   - Ralink PHY register R/W command !!
mm      - memory modify (auto-incrementing)
nand    - nand command
nm      - memory modify (constant address)
printenv- print environment variables
reset   - Perform RESET of the CPU
rf      - read/write rf register
saveenv - save environment variables to persistent storage
setenv  - set environment variables
tftpboot- boot image via network using TFTP protocol
version - print monitor version
MT7620 # printenv
bootcmd=tftp
bootdelay=5
baudrate=57600
ethaddr="00:AA:BB:CC:DD:10"
ipaddr=192.168.1.241
serverip=192.168.1.116
stdin=serial
stdout=serial
stderr=serial

Here are the output for the previous commands for boths

///////////////////////////////////// ORIGINAL /////////////////////////////////////

root@OpenWrt:~# swconfig list
Found: switch0 - mt7620


root@OpenWrt:~# cat /etc/board.json
{
        "led": {
                "wifi_led": {
                        "name": "wifi",
                        "type": "netdev",
                        "sysfs": "ikim:blue:wifi",
                        "device": "wlan0"
                }
        },
        "network": {
                "lan": {
                        "ifname": "eth0",
                        "create_vlan": true,
                        "macaddr": "80:0a:80:10:00:00"
                },
                "wan": {
                        "ifname": "eth0",
                        "create_vlan": true,
                        "macaddr": "80:0a:80:10:00:01"
                }
        },
        "switch": {
                "switch0": {
                        "enable": true,
                        "reset": true,
                        "vlans": {
                                "lan": [
                                        0,
                                        1,
                                        2,
                                        3
                                ],
                                "wan": [
                                        4
                                ]
                        },
                        "cpu_port": 6
                }
        }
}


ORIGINAL


root@OpenWrt:~# cat /etc/board.d/02_network
#!/bin/sh

. /lib/functions.sh
. /lib/ramips.sh
. /lib/functions/uci-defaults-new.sh
. /lib/functions/system.sh

ramips_setup_rt3x5x_vlans()
{
        if [ ! -x /sbin/swconfig ]; then
                # legacy default
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                return
        fi
        local wanports=""
        local lanports=""
        for port in 5 4 3 2 1 0; do
                if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
                        continue
                fi
                if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
                        wanports="$port $wanports"
                else
                        lanports="$port $lanports"
                fi
        done
        ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
        ucidef_add_switch "rt305x" "1" "1"
        ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
        ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
}

ramips_setup_interfaces()
{
        local board="$1"

        ucidef_set_interface_loopback

        case $board in
        a5-v11)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ;;

        3g150b | \
        3g300m | \
        microwrt | \
        w150m | \
        zte-q7 | \
        all0256n | \
        all5002 | \
        all5003 | \
        broadway | \
        dcs-930| \
        dcs-930l-b1| \
        ht-tm02| \
        ncs601w | \
        wnce2001)
                ucidef_add_switch "switch0" "1" "0"
                ucidef_set_interface_lan "eth0"
                ;;

        3g-6200nl | \
        mlw221 | \
        mr-102n)
                ucidef_set_interface_lan "eth0.2"
                ;;
        mlwg2)
                ucidef_set_interface_lan "eth0.1"
                ;;

        m2m)
                ucidef_add_switch "switch0" "4"
                ucidef_set_interface_lan "eth0"
                ;;

        wizard8800 | \
        wl-330n | \
        wmr300)
                ucidef_set_interface_lan "eth0.1"
                ;;

        b2c | \
        nw718 | \
        psr-680w | \
        sl-r7205 | \
        w502u | \
        wr6202)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ;;

        awapn2403)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ucidef_add_switch_vlan "switch0" "2" "1 6t"
                ;;

        br-6475nd)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
                ucidef_add_switch_vlan "switch0" "2" "0 9t"
                ;;

        re6500 | \
        asl26555)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
                ;;

        cf-wr800n)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "4 6t"
                ;;

        cy-swr1100)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
                ucidef_add_switch_vlan "switch0" "2" "4 9t"
                ;;

        3g-6200n | \
        ai-br100 | \
        dir-610-a1 | \
        dir-300-b7 | \
        dir-320-b1 | \
        dir-615-h1 | \
        firewrt | \
        pbr-m1 | \
        hlk-rm04 | \
        mt7621 | \
        mt7628 | \
        mzk-w300nh2 | \
        mzk-750dhp | \
        whr-300hp2 | \
        whr-600d | \
        wsr-600 | \
        wsr-1166 | \
        wt1520 | \
        xiaomi-miwifi-mini |\
        y1)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        v22sg)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        whr-1166d)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "5 6t"
                ;;

        awm002-evb | \
        awm003-evb | \
        argus-atp52b | \
        dir-645 | \
        dir-860l-b1 | \
        f5d8235-v1 | \
        f5d8235-v2 | \
        hg255d | \
        rt-n14u | \
        wrtnode | \
        wt3020 | \
        ur-326n4g | \
        zbt-wa05)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;

        ur-336un)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ;;

        br6524n | \
        v11st-fe)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
                ucidef_add_switch_vlan "switch0" "2" "0 5t"
                ;;

        ar670w | \
        ar725w | \
        rt-n15 | \
        wl-351)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
                ucidef_add_switch_vlan "switch0" "2" "4 5t"
                ;;

        rt-n56u)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
                ucidef_add_switch_vlan "switch0" "2" "4 8t"
                ;;

        tew-691gr|\
        tew-692gr)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
                ucidef_add_switch_vlan "switch0" "2" "0t 5"
                ;;

        vocore)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
                ;;

        wcr-150gn)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ucidef_add_switch_vlan "switch0" "2" "6t"
                ;;

        wr8305rt)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        y1s)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;
        d105 | \
        na930 | \
        omni-emb-hpm|\
        wli-tx4-ag300n)
                ucidef_set_interface_lan "eth0"
                ;;

        e1700 | \
        mt7620a_mt7530)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch1" "1" "1"
                ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch1" "2" "4 6t"
                ;;

        wzr-agl300nh)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
                ucidef_add_switch_vlan "switch0" "2" "0 5t"
                ;;
        *)
                RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
                if [ -n "${RT3X5X}" ]; then
                        ramips_setup_rt3x5x_vlans
                else
                        ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                fi
                ;;
        esac
}

ramips_setup_macs()
{
        local board="$1"
        local lan_mac=""
        local wan_mac=""

        case $board in
        br-6475nd)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(mtd_get_mac_binary devdata 7)
                ;;

        w306r-v20)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 5)
                ;;

        tew-691gr)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 3)
                ;;

        tew-692gr)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 4)
                ;;

        m3 |\
        m4 |\
        x5 |\
        x8)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_add "$lan_mac" -2)
                ;;

        a5-v11 |\
        bc2 |\
        broadway |\
        d105 |\
        dir-620-a1 |\
        esr-9753 |\
        freestation5 |\
        hlk-rm04 | \
        mpr-a1 | \
        mpr-a2 | \
        dir-300-b7 | \
        dir-320-b1 | \
        psr-680w |\
        sl-r7205 |\
        y1 |\
        y1s)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_setbit_la "$lan_mac")
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;

        ht-tm02)
                lan_mac=$(cat /sys/class/net/eth0/address)
                ;;

        cy-swr1100 | \
        dir-645)
                lan_mac=$(mtd_get_mac_ascii nvram lanmac)
                wan_mac=$(mtd_get_mac_ascii nvram wanmac)
                ;;

        e1700)
                wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
                ;;

        wcr-150gn)
                wan_mac=$(mtd_get_mac_binary factory 40)
                ;;

        rt-n56u)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_setbit_la "$lan_mac")
                wan_mac=$(mtd_get_mac_binary factory 32772)
                ;;

        all0239-3g | \
        carambola | \
        freestation5 | \
        w502u | \
        wnce2001)
                wan_mac=$(mtd_get_mac_binary factory 46)
                ;;

        wsr-600|whr-300hp2|whr-600d|whr-1166d)
                wan_mac=$(mtd_get_mac_binary factory 4)
                lan_mac=$wan_mac
                ;;
        wsr-1166)
                local index="$(find_mtd_index "board_data")"
                wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
                lan_mac=$wan_mac
                ;;
        *)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;

        esac

        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
        [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
}

board_config_update
board=$(ramips_board_name)
ramips_setup_interfaces $board
ramips_setup_macs $board
board_config_flush

exit 0

///////////////////////////////////// CUSTOM /////////////////////////////////////////////////

root@OpenWrt:/etc/board.d# swconfig list
Found: switch0 - mt7620 

root@OpenWrt:/etc/board.d# cat /etc/board.json
{
        "network": {
                "lan": {
                        "ifname": "eth0",
                        "create_vlan": true,
                        "macaddr": "00:11:22:F0:00:17"
                },
                "wan": {
                        "ifname": "eth0",
                        "create_vlan": true,
                        "macaddr": "52:1F:10:C7:27:64"
                }
        },
        "switch": {
                "switch0": {
                        "enable": true,
                        "reset": true,
                        "vlans": {
                                "lan": [
                                        0,
                                        1,
                                        2,
                                        3
                                ],
                                "wan": [
                                        4
                                ]
                        },
                        "cpu_port": 6
                }
        }
}



CUSTOM

root@OpenWrt:/etc/board.d# cat /etc/board.d/02_network
#!/bin/sh

. /lib/functions.sh
. /lib/ramips.sh
. /lib/functions/uci-defaults-new.sh
. /lib/functions/system.sh

ramips_setup_rt3x5x_vlans()
{
        if [ ! -x /sbin/swconfig ]; then
                # legacy default
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                return
        fi
        local wanports=""
        local lanports=""
        for port in 5 4 3 2 1 0; do
                if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
                        continue
                fi
                if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
                        wanports="$port $wanports"
                else
                        lanports="$port $lanports"
                fi
        done
        ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
        ucidef_add_switch "rt305x" "1" "1"
        ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
        ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
}

ramips_setup_interfaces()
{
        local board="$1"

        ucidef_set_interface_loopback

        case $board in
        a5-v11)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ;;

        3g150b | \
        3g300m | \
        linkits7688 | \
        linkits7688d | \
        microwrt | \
        w150m | \
        zte-q7 | \
        all0256n | \
        all5002 | \
        all5003 | \
        broadway | \
        dcs-930| \
        dcs-930l-b1| \
        ht-tm02| \
        ncs601w | \
        wnce2001)
                ucidef_add_switch "switch0" "1" "0"
                ucidef_set_interface_lan "eth0"
                ;;

        3g-6200nl | \
        mlw221 | \
        mr-102n)
                ucidef_set_interface_lan "eth0.2"
                ;;
        mlwg2)
                ucidef_set_interface_lan "eth0.1"
                ;;

        m2m)
                ucidef_add_switch "switch0" "4"
                ucidef_set_interface_lan "eth0"
                ;;

        wizard8800 | \
        wl-330n | \
        wmr300)
                ucidef_set_interface_lan "eth0.1"
                ;;

        b2c | \
        nw718 | \
        psr-680w | \
        sl-r7205 | \
        w502u | \
        wr6202)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ;;

        awapn2403)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ucidef_add_switch_vlan "switch0" "2" "1 6t"
                ;;

        br-6475nd)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
                ucidef_add_switch_vlan "switch0" "2" "0 9t"
                ;;

        re6500 | \
        asl26555)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
                ;;

        cf-wr800n|\
        ex2700)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "4 6t"
                ;;

        cy-swr1100)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
                ucidef_add_switch_vlan "switch0" "2" "4 9t"
                ;;

        3g-6200n | \
        ai-br100 | \
        dir-610-a1 | \
        dir-300-b7 | \
        dir-320-b1 | \
        dir-615-h1 | \
        firewrt | \
        pbr-m1 | \
        hlk-rm04 | \
        mt7621 | \
        mt7628 | \
        mzk-w300nh2 | \
        mzk-750dhp | \
        whr-300hp2 | \
        whr-600d | \
        wsr-600 | \
        wsr-1166 | \
        wt1520 | \
        xiaomi-miwifi-mini |\
        y1|\
        zbt-wg2626)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        whr-1166d)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch0" "2" "5 6t"
                ;;
        wizfi630a)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;
        awm002-evb | \
        awm003-evb | \
        argus-atp52b | \
        dir-645 | \
        dir-860l-b1 | \
        f5d8235-v1 | \
        f5d8235-v2 | \
        hg255d | \
        rt-n14u | \
        wrtnode | \
        wt3020 | \
        ur-326n4g | \
        zbt-wa05)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;

        ur-336un)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ;;

        br6524n | \
        v11st-fe)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
                ucidef_add_switch_vlan "switch0" "2" "0 5t"
                ;;

        ar670w | \
        ar725w | \
        rt-n15 | \
        wl-351)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
                ucidef_add_switch_vlan "switch0" "2" "4 5t"
                ;;

        rt-n56u)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
                ucidef_add_switch_vlan "switch0" "2" "4 8t"
                ;;

        tew-691gr|\
        tew-692gr)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
                ucidef_add_switch_vlan "switch0" "2" "0t 5"
                ;;

        vocore)
                ucidef_set_interface_lan "eth0.1"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
                ;;

        wcr-150gn)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 6t"
                ucidef_add_switch_vlan "switch0" "2" "6t"
                ;;

        wr8305rt)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
                ucidef_add_switch_vlan "switch0" "2" "4 6t"
                ;;

        y1s)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;
        d105 | \
        na930 | \
        omni-emb-hpm|\
        wli-tx4-ag300n)
                ucidef_set_interface_lan "eth0"
                ;;

        e1700 | \
        mt7620a_mt7530)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch1" "1" "1"
                ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
                ucidef_add_switch_vlan "switch1" "2" "4 6t"
                ;;

        wzr-agl300nh)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "switch0" "1" "1"
                ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
                ucidef_add_switch_vlan "switch0" "2" "0 5t"
                ;;
        *)
                RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
                if [ -n "${RT3X5X}" ]; then
                        ramips_setup_rt3x5x_vlans
                else
                        ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                fi
                ;;
        esac
}

ramips_setup_macs()
{
        local board="$1"
        local lan_mac=""
        local wan_mac=""

        case $board in
        br-6475nd)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(mtd_get_mac_binary devdata 7)
                ;;

        w306r-v20)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 5)
                ;;

        tew-691gr)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 3)
                ;;

        tew-692gr)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 4)
                ;;

        m3 |\
        m4 |\
        x5 |\
        x8)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_add "$lan_mac" -2)
                ;;

        a5-v11 |\
        bc2 |\
        broadway |\
        d105 |\
        dir-620-a1 |\
        esr-9753 |\
        freestation5 |\
        hlk-rm04 | \
        mpr-a1 | \
        mpr-a2 | \
        dir-300-b7 | \
        dir-320-b1 | \
        psr-680w |\
        sl-r7205 |\
        y1 |\
        y1s)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_setbit_la "$lan_mac")
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;

        ht-tm02)
                lan_mac=$(cat /sys/class/net/eth0/address)
                ;;

        cy-swr1100 | \
        dir-645)
                lan_mac=$(mtd_get_mac_ascii nvram lanmac)
                wan_mac=$(mtd_get_mac_ascii nvram wanmac)
                ;;

        e1700)
                wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
                ;;

        wcr-150gn)
                wan_mac=$(mtd_get_mac_binary factory 40)
                ;;

        rt-n56u)
                lan_mac=$(cat /sys/class/net/eth0/address)
                lan_mac=$(macaddr_setbit_la "$lan_mac")
                wan_mac=$(mtd_get_mac_binary factory 32772)
                ;;

        all0239-3g | \
        carambola | \
        freestation5 | \
        w502u | \
        wnce2001)
                wan_mac=$(mtd_get_mac_binary factory 46)
                ;;

        wsr-600|whr-300hp2|whr-600d|whr-1166d)
                wan_mac=$(mtd_get_mac_binary factory 4)
                lan_mac=$wan_mac
                ;;
        wizfi630a)
                lan_mac=$(mtd_get_mac_binary factory 4)
                wan_mac=$(mtd_get_mac_binary factory 40)
                ;;
        wsr-1166)
                local index="$(find_mtd_index "board_data")"
                wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
                lan_mac=$wan_mac
                ;;
        linkits7688 | \
        linkits7688d)
                wan_mac=$(mtd_get_mac_binary factory 4)
                lan_mac=$(mtd_get_mac_binary factory 46)
                ;;
        *)
                lan_mac=$(cat /sys/class/net/eth0/address)
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;

        esac

        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
        [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
}

board_config_update
board=$(ramips_board_name)
ramips_setup_interfaces $board
ramips_setup_macs $board
board_config_flush

exit 0

I don't think that Chaos Calmer used a DTS at all, it was the old way with model-specific C code. So there isn't much you can do to port the old build. Start over by looking at DTS files of other MT7620 models. You can start with one that has all 5 ports enabled, this should at least allow you to bring up some sort of Ethernet connection. But I think the chip also has a provision for a single port to bypass the switch which would suit this hardware better.

The Ethernet logic is all inside the MT7620 and controlled by the kernel. The Txcom component is a passive signal transformer which contains no active logic and requires no configuration.

1 Like

Hello Mike,

Thank you for your reply.

Ok, as the imagebuilder produce several mt7620 firmwares at the same time. I will try other ones from the list, it doesn't cost a thing.

Best Regards

If you're going to flash images the partitioning must also be correct, so I would run initramfs builds to see if the Ethernet works.

Hello,

I have found a solution to my problem.
I changed some definition on the dts file on the "ethernet@10100000" part.
As the ethernet port was added later on the board, the definition of the physical ports of the original dts file was not correct.
After many trials and error, I found my eth0.2 working.

Here is the part of the dts file I modified :

ethernet@10100000 {
		status = "okay";

		pinctrl-names = "default";
		pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
		
		ralink,port-map = "llllw";		

		port@5 {
			status = "okay";
			phy-handle = <&phy0>;
			phy-mode = "rgmii";
		};

		mdio-bus {
			status = "okay";			

			phy0: ethernet-phy@0 {
				reg = <0>;
				phy-mode = "rgmii";
			};
		};
	};

Anyway, thank you walterav, FBJR, mk24, anon69880279 for the help, and the suggestions.

Now, I am facing another problem but It is not in the scope of this topic...

Best Regards

1 Like

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