How to support 2 ethernets for iMX8mm?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to support 2 ethernets for iMX8mm?

Jump to solution
1,809 Views
chadA
Contributor III

Dear all,

Now I have a project which need to support 2 ethernets. The first ethernet we can use the default one on iMX8mm, and the second one we are trying to use the USB-Ethernet, the chip is RealTek R8152B.

Now the driver works fine, and I can get the "eth1" device. But after I configed the IP address, and try to ping another IP, it failed. Ping report: Network is unreachable.

So anyone knows what happened? Am I missing any settings?

Best Regards~

Chad

Labels (1)
0 Kudos
1 Solution
1,627 Views
chadA
Contributor III

Dear Sanket,

Now I am checking the framework, but still do not find the problem.

For your suggestion, I had compared all logs except using ethtool. Ethtool is not the default tool in my system, and I'm lazy.  For the log, they are the same. because there are no changes in kernel between the right version and failed version. 

And with the failed version, if I use "ifconfig eth1" over and over again to check the RX and TX bytes, they are increasing, So I think eth1 should work normal in kernel.

I guess it's something that's been moved to framework under Android. But it is difficult to find out.

Beside, you can close this case if you want.

Thanks

Chad

View solution in original post

0 Kudos
14 Replies
1,789 Views
chadA
Contributor III

More information, board is iMX8MM-EVK, OS is android9.0.

0 Kudos
1,782 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @chadA ,

I hope you are doing well.

It may be possible that the Eth1 port is not defined in the /etc/network/interfaces file. Only Eth0 is defined and this is why you cannot use both. To define Eth1 please edit /etc/network/interfaces adding the following information:

->For a DHCP client:
auto eth1
iface eth1 inet dhcp

->For a Static IP (of course this is an example, your numbers will be different):
auto eth1
iface eth1 inet static
address 192.168.0.100
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1

I hope this helps!

Thanks & Regards,
Sanket Parekh

0 Kudos
1,761 Views
chadA
Contributor III

Dear Sanket,

Add some things I‘ve tried。

////////////// iMX8mm Log ///////////////

evk_8mm:/ # ip route
172.20.20.0/23 dev eth1 proto kernel scope link src 172.20.20.76
evk_8mm:/ # ip route add default via 172.20.20.1 dev eth1
evk_8mm:/ # ip route
default via 172.20.20.1 dev eth1
172.20.20.0/23 dev eth1 proto kernel scope link src 172.20.20.76
evk_8mm:/ # ping 172.20.20.220
connect: Network is unreachable
2|evk_8mm:/ # ifconfig eth1
eth1 Link encap:Ethernet HWaddr 4a:19:1b:00:0f:f3 Driver r8152
inet addr:172.20.20.76 Bcast:172.20.21.255 Mask:255.255.254.0
inet6 addr: fe80::4819:1bff:fe00:ff3/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32324 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1511071 TX bytes:1076

/////////////////////////////////////////////////////////////

It is on the same network with my server, and this is my server's configuration:

/********** My Server's network configuration*********/

root@forlinx:/home/forlinx/Workspace/imx8mm/OK8MM-android-source# ifconfig
enp2s0:

flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.20.220 netmask 255.255.254.0 broadcast 172.20.21.255
inet6 fe80::8d2:c3be:14cf:4053 prefixlen 64 scopeid 0x20<link>
ether 6c:4b:90:8c:3e:8f txqueuelen 1000 (Ethernet)
RX packets 103701 bytes 10940619 (10.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2677 bytes 270458 (270.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@forlinx:/home/forlinx/Workspace/imx8mm/OK8MM-android-source# ip route show
default via 172.20.20.1 dev enp2s0 proto static metric 100
169.254.0.0/16 dev enp2s0 scope link metric 1000
172.20.20.0/23 dev enp2s0 proto kernel scope link src 172.20.20.220 metric 100

/*************************************************/

Hope it is useful~

Thanks

Chad

 

0 Kudos
1,765 Views
chadA
Contributor III

Dear Sanket,

Beside, after the system starting up , when I try to use "ifconfig eth1 up" to open the eth1 for the first time, it will report the following prompts. Only the first time,after that this prompt will not appear again. is this normal?

evk_8mm:/ #  ifconfig eth1 172.20.20.76 netmask 255.255.254.0 broadcast 172.20.21.255 up
[ 158.873785] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 158.901184] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[ 158.908260] r8152 1-1.3:1.0 eth1: carrier on
[ 160.028301] nf_conntrack: default automatic helper assignment has been turned off for security reasons and CT-based firewall rule not found. Use the iptable s CT target to attach helpers instead.

I think it should be cased by the firewall, so I used the "iptables -P INPUT ACCEPT" to disable the firewall, but this prompt still appear. Will it caused the "Network is unreachable" problem?

Thanks

Chad

0 Kudos
1,746 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @chadA ,

I hope you are doing well.

The error shows that conntrack helpers are not loaded automatically anymore (there has been a warning about this behavior becoming the default for a long while now) and the admin needs to set firewall rules for all needed connection tracking.

->One needs to replace any rules using the 'old' style `-m state --state` with the 'new' style `-m conntrack --ctstate` instead.
-A FORWARD -i eth0 -m conntrack --ctstate NEW -j ACCEPT

It may help!

Thanks & Regards,
Sanket Parekh

0 Kudos
1,736 Views
chadA
Contributor III

Hello @Sanket_Parekh ,

Thanks for your quickly support~

For the new rules, does it solve the ping's problem? or it just solve the prompt?

For the prompt, I also had made some testing. I found the prompt is caused by the USB DWC2 host feature which I enabled in the kernel. If I set the USB DWC2 into dual mode, it is disappeared. But ping still fail, and return "Network is unreachable".

Even with the prompt, according to my understand, if I use "iptables -P FORWARD ACCEPT" to close the firewall, it also should not matter. But I failed again, ping also do not work, same result.

And I tested the hardware with Linux system. On Linux system, it works fine. So I'm sure it is a software problem.

In short, I will test your new suggestion later. And before that if you have any other idea, please let me know. I will be happy to test them together.

Thanks

Chad

0 Kudos
1,713 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @chadA ,

I hope you are doing well.

->Please also make sure the configuration of the device tree for the Ethernet you have set.
git/tree/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt

Please refer to the below location for reference.

Please also check the pin configurations and the voltage setting
Refer to this device tree node in the Linux source code for reference.
In the file imx8mm-evk.dtsi please refer to the node -> pinctrl_fec2_gpios:

I hope this helps!

Thanks & Regards,

Sanket Parekh

0 Kudos
1,707 Views
chadA
Contributor III

Hi @Sanket_Parekh ,

Thanks.

But I do not undertand.

As you know, my device is a usb-ethernet, so it is connected to the USB port, for dts, the pin ctrl should configured into USB first. If the USB works fine, then there is no need to re-configured.

 I have a small board like this:

微信图片_20230628132039.jpg

I connected it to the USB2.0 port on the board directly. So I think there is no need to configure the DTS.

Beside, same hardware connection, it works fine with Linux system.

Thanks

Chad

0 Kudos
1,678 Views
chadA
Contributor III

Hi @Sanket_Parekh ,

Hello Sanket,

Amazing, I tried to add some debug print in kernel, then it works, now ping wroks fine.

Hard to understand~

Chad

0 Kudos
1,668 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @chadA ,

I'm glad the ping works fine.
If the issue is solved now, Hence Can I Close this case?

Thanks & Regards,
Sanket Parekh

0 Kudos
1,663 Views
chadA
Contributor III

Hi @Sanket_Parekh ,

Before that, a little question:

I compared the code and found that the failure was caused by eth1 not being discovered by the Ethernet service in the framework. This is a little different from my understanding.

In my understanding, Ethernet service is based on the kernel, it should not affect the kenel. So even the Ethernet service did not find eth1, eth1 also should work fine with command in kernel. But now it is not. So do you have any idea about this?

Thanks

Chad

0 Kudos
1,634 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @chadA ,

->You are correct that the Ethernet service is based on the kernel, and it should not affect the kernel in the ideal case.
->It may be possible that the kernel does not have the driver for eth1 installed.
One can check the same by giving the below command.
lsmod | grep eth1

-> One can check the issue further using the below command, It will help you.
dmesg | grep eth1
ethtool eth1

I hope it helps!

Thanks & Regards,
Sanket Parekh

0 Kudos
1,628 Views
chadA
Contributor III

Dear Sanket,

Now I am checking the framework, but still do not find the problem.

For your suggestion, I had compared all logs except using ethtool. Ethtool is not the default tool in my system, and I'm lazy.  For the log, they are the same. because there are no changes in kernel between the right version and failed version. 

And with the failed version, if I use "ifconfig eth1" over and over again to check the RX and TX bytes, they are increasing, So I think eth1 should work normal in kernel.

I guess it's something that's been moved to framework under Android. But it is difficult to find out.

Beside, you can close this case if you want.

Thanks

Chad

0 Kudos
1,769 Views
chadA
Contributor III

Dear Sanket,

Thanks for your answer. But it does not work.

First, I did not find the network/interface file under the etc directory on my system.

Second, according to your description, I think you mean try to use dhcp or config a static IP for eth1. And I tested both of them with command, but none of them works, and still have the same result: "Network is unreachable".

Third, yes, my target is 2 ethernets can work together, but now the problem is the second ethernet eth1 does not work well. So do you have any idea how to make it work fine first?

Best Regards~

Chad

0 Kudos