Phytec中国的wiki
support@phytec.cn
热线:0755-61802110-803
BSP-Yocto-FSL-iMX7-PD18.1.1是基于NXP L4.9.11_1.0.0_ga Release.
使用connman服务设置网络
在nxp release note中提到, 上电后网口不会自动使能.
如果需要自动使能网口, 需要开启connman服务
root@imx7d-phyboard-zeta-001:~# systemctl unmask connman root@imx7d-phyboard-zeta-001:~# systemctl enable connman root@imx7d-phyboard-zeta-001:~# systemctl start connman
经过这些设置后,开发板重新上电后, 网口已经使能了, 但是eth0 和eth1 都是使用动态ip地址.
如果需要定义ip地址, 需要先用网线连接eth0 eth1, 查找connman service名称,然后设置每个service设置ip地址
root@imx7d-phyboard-zeta-001:~# connmanctl services *AO Wired ethernet_cee042e10460_cable *AR Wired ethernet_ce57125a93a6_cable root@imx7d-phyboard-zeta-001:~# connmanctl config <service> --ipv4 manual <ip address> <netmask> <gateway> root@imx7d-phyboard-zeta-001:~# connmanctl config ethernet_cee042e10460_cable --ipv4 manual 192.168.3.11 255.255.255.0 192.168.3.1 root@imx7d-phyboard-zeta-001:~# connmanctl config ethernet_ce57125a93a6_cable --ipv4 manual 192.168.4.11 255.255.255.0 192.168.4.1 root@imx7d-phyboard-zeta-001:~# ifconfig eth0 Link encap:Ethernet HWaddr ce:57:12:5a:93:a6 inet addr:192.168.4.11 Bcast:192.168.4.255 Mask:255.255.255.0 inet6 addr: fe80::cc57:12ff:fe5a:93a6/64 Scope:Link UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1 RX packets:492 errors:0 dropped:0 overruns:0 frame:0 TX packets:273 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:116118 (113.3 KiB) TX bytes:103625 (101.1 KiB) eth1 Link encap:Ethernet HWaddr ce:e0:42:e1:04:60 inet addr:192.168.3.11 Bcast:192.168.3.255 Mask:255.255.255.0 inet6 addr: fe80::cce0:42ff:fee1:460/64 Scope:Link UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1 RX packets:37843 errors:0 dropped:2784 overruns:0 frame:0 TX packets:2510 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2959968 (2.8 MiB) TX bytes:130578 (127.5 KiB)
https://manpages.debian.org/stretch/connman/connman-service.config.5.en.html 参考链接中的config 文件说明也可以设置ip地址, 但是设置后的eth0, eth1都会使用相同的配置, 无法分别设置.
所以使用connman 服务无法在配置文件中分别对连个网口分别设置, 如果需要将网口配置编译进镜像, 可以使用systemd-networkd服务.
使用systemd-networkd 服务配置网络
将networkd服务编译进镜像, 在bsp 包的build/conf/local.conf 增加以下一行:
PACKAGECONFIG_append_pn-systemd = " networkd"
而systemd-networkd中eth0, eth1的配置文件可在/lib/systemd/network目录下增加配置文件, 如果需要镜像, 参考自定义的layer中eth0, eth1的配置: meta-custom.tar.gz
在build/conf/bblayers.conf中的BBLAYERS 增加meta-custom layer
${BSPDIR}/sources/meta-custom \
在build/conf/local.conf增加网络配置的recipes
IMAGE_INSTALL_append = " networkdcfg"
经过以上修改重新编译镜像,然后网络配置可参考:
Overview
Content Tools
Activity
Tasks