以太网功能
i2C-MP15X-B开发板提供了两路以太网接口
一路为STM32MP1芯片原生10/100/1000 Mbps自适应以太网接口(CN1),Linux系统中设备名为eth0
一路为USB扩展的10/100 Mbps以太网接口(CN2),Linux系统中设备名是eth1
root@i2cmp15xbe:~# ifconfig -a
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:16 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:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:42
eth0 Link encap:Ethernet HWaddr 6a:e7:1d:3d:52:b1
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)
Interrupt:71 Base address:0xe000
eth1 Link encap:Ethernet HWaddr 76:0f:e1:a0:3f:ce
UP 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)
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:6180 errors:0 dropped:0 overruns:0 frame:0
TX packets:6180 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:469176 (458.1 KiB) TX bytes:469176 (458.1 KiB)
sit0 Link encap:UNSPEC HWaddr 00-00-00-00-30-30-30-30-00-00-00-00-00-00-00-00
NOARP MTU:1480 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)
usb0 Link encap:Ethernet HWaddr a2:7c:8c:37:7b:2f
inet addr:192.168.7.2 Bcast:192.168.7.255 Mask:255.255.255.0
UP 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)
wlan0 Link encap:Ethernet HWaddr c0:84:7d:2d:89:4c
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)
配置IP地址
# ifconfig eth0 192.168.1.100
配置网关
# route add default gw 192.168.1.1
配置DNS域名解析服务
# echo "nameserver 8.8.8.8" > /etc/resolv.conf
# echo "nameserver 114.114.114.114" >> /etc/resolv.conf
配置完成后就可以使用ping命令来测试开发板与互联网的连通性。
# ping bing.com
PING bing.com (204.79.197.200): 56 data bytes
64 bytes from 204.79.197.200: icmp_seq=0 ttl=118 time=12.205 ms
64 bytes from 204.79.197.200: icmp_seq=1 ttl=118 time=12.017 ms
64 bytes from 204.79.197.200: icmp_seq=2 ttl=118 time=11.565 ms
64 bytes from 204.79.197.200: icmp_seq=3 ttl=118 time=12.116 ms
配置网卡
i2C-MP15X-B开发板使用Systemd作为系统服务的管理工具,默认网卡是DHCP模式,自动从网关出获取IP,网关信息。如果需要手动配置网络信息,可以在/etc/systemd/network下编写配置文件。
/etc/systemd/network/10-eth0.network的文件内容如下
[Match]
Name=eth0
[Network]
DHCP=none
Address=192.168.5.242/24
Gateway=192.168.5.50
DNS=8.8.8.8
配置文件写好后,使用systemctl命令重启服务即可。
systemctl restart systemd-networkd
建议执行reboot命令来重启,而不是按Reset复位按键。
作者:SteveChen 创建时间:2024-09-18 16:34
最后编辑:SteveChen 更新时间:2024-09-18 16:34
最后编辑:SteveChen 更新时间:2024-09-18 16:34