Forlinx Posted Saturday at 06:40 AM Report Share Posted Saturday at 06:40 AM Routing is a core component of device networking, responsible for intelligent data packet forwarding, ensuring efficient communication and internet access. It also assigns IP addresses to devices connected via the network interface, ensuring stable and secure connections. Below is a guide on how to implement routing functionality on the Forlinx i.MX93 platform. 1. Bridge Building 1.1 Busybox Compilation and Brctl Tool Loading There is no brctl tool in the busybox of the 93 development board, so it needs to be recompiled. If the busybox of the board has the brctl tool, this step can be ignored. Down load busybox-1.35 source code, website: https://busybox.net/ Unzip it on the 93 development environment and execute make menuconfig to configure. forlinx@ubuntu:~/work/busybox$ tar -xvf busybox-1.35.0.tar.bz2 forlinx@ubuntu:~/work/busybox$ cd busybox-1.35.0/ forlinx@ubuntu:~/work/busybox/busybox-1.35.0$ . /opt/fsl-imx-xwayland/5.15-kirkstone/environment-setup-armv8a-poky-linux forlinx@ubuntu:~/work/busybox/busybox-1.35.0$ make menuconfig Select Setting-->[*] Don't use /usr In this way, it will be installed to the directory specified by itself (default./_ install). This option must be selected, otherwise busybox will be installed under/usr of the original system after make install, which will overwrite the original commands of the system. After selecting this, make install will generate the _ install directory under the busybox directory, which contains the busybox and the link pointing to it. Add cross-compilation path (it can be set according to your own requirements): Setting-->--- Build Options (arch64-poky-linux-) Cross compiler prefix (/opt/fsl-imx-xwayland/5.15-kirkstone/sysroots/armv8a-poky-linux) Path to sysroot (-O2 -pipe -g -feliminate-unused-debug-types) Additional CFLAGS (-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now) Additional LDFLAGS Select brctl tool Networking Utilities --->[*] brctl (4.7 kb) Modify and then compile forlinx@ubuntu:~/work/busybox/busybox-1.35.0$ make forlinx@ubuntu:~/work/busybox/busybox-1.35.0$ make install Copy the generated busybox command to the development board/home/root path 1.2 Kernel Source Code Modification forlinx@ubuntu:~/work/ok-mx93/OKMX93-linux-sdk/OKMX93-linux-kernel$ vi drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c (478 line) /* if (hw->promisc) { netdev_err(dev, “Adding VLAN in promisc mode not supported\n"); return -EPERM; }*/ (533 line) /* if (hw->promisc) { netdev_err(dev, "Deleting VLAN in promisc mode not supported\n"); return -EPERM; }*/ Save and recompile the kernel after modification, generate Image and update the kernel 1.3 Building a Bridge With Brctl root@ok-mx93:~# ./busybox brctl addbr br0 //Create bridge device br0 root@ok-mx93:~# ./busybox brctl stp br0 off //Turn off the STP root@ok-mx93:~# ./busybox brctl addif br0 eth0 //Add eth0 to the bridge root@ok-mx93:~# ./busybox brctl addif br0 eth1 //Add eth1 to the bridge root@ok-mx93:~# ifconfig br0 192.168.0.10 up configure br0 ip and start it 2. 4G for Network Forwarding 2.1 4G Dial-up If there is command service, you need to delete it and restart. root@ok-mx93:~# rm /usr/sbin/connmand root@ok-mx93:~# sync root@ok-mx93:~# reboot root@ok-mx93:~# fltest_quectel.sh root@ok-mx93:~# ifconfig eth0 up root@ok-mx93:~# ifconfig eth1 up Note: The network port will be closed in the 93 dial-up script. If it is not necessary, you can comment out the command to close the network port in the script. 2.2 Route Priority Adjustment Checking with ''route -n'' reveals that the priorities of eth0 and eth1 are higher than 4G. At this point, 4G cannot access the Internet, so it is necessary to adjust the priorities to avoid affecting the 4G network. root@ok-mx93:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth1 0.0.0.0 10.137.251.242 0.0.0.0 UG 10 0 0 usb0 10.137.251.240 0.0.0.0 255.255.255.252 U 0 0 0 usb0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 Modify the metric parameter to change the priority. root@ok-mx93:~# route del default gw 192.168.1.1 root@ok-mx93:~# route del default gw 192.168.2.1 root@ok-mx93:~# route add default gw 192.168.1.1 dev eth0 metric 11 root@ok-mx93:~# route add default gw 192.168.2.1 dev eth1 metric 11 root@ok-mx93:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.137.251.242 0.0.0.0 UG 10 0 0 usb0 0.0.0.0 192.168.2.1 0.0.0.0 UG 11 0 0 eth1 0.0.0.0 192.168.1.1 0.0.0.0 UG 11 0 0 eth0 10.137.251.240 0.0.0.0 255.255.255.252 U 0 0 0 usb0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 After modification, 4G can access the Internet normally. root@ok-mx93:~# ping www.baidu.com PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data. 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=51 time=32.7 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=51 time=31.4 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=51 time=29.3 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=51 time=29.1 ms ^C --- www.a.shifen.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3003ms rtt min/avg/max/mdev = 29.066/30.612/32.663/1.494 ms 2.3 4G Forwarding Turn on IP to forward. root@ok-mx93:~# echo 1 > /proc/sys/net/ipv4/ip_forward Set forwarding rules. root@ok-mx93:~# iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o usb0 -jMASQUERADE root@ok-mx93:~# iptables -A FORWARD -i br0 -j ACCEPT Configure the udhcpd service and modify the/etc/udhcpd. conf films. root@ok-mx93:~# vi /etc/udhcpd.conf ... # The start and end of the IP lease block start 192.168.0.100 end 192.168.0.254 # The interface that udhcpd will use interface br0 ... # Examples: opt dns 114.114.114.114 option subnet 255.255.255.0 opt router 192.168.0.10 Turn on the udhcpd service root@ok-mx93:~# udhcpd /etc/udhcpd.conf & 3. Computer and Device Side Set both the computer and the device to obtain IP automatically. After obtaining the IP, the two can access the external network and ping each other. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.