In embedded Linux environments with devices, there are two network cards. If A is recognized as eth0 and B is recognized as eth1, sometimes you may want to swap the device nodes (i.e., swap the mapping of A and B to eth0 and eth1, loading as eth0 first and eth1 second). The following methods can solve this problem:
1. Confirm the device nodes corresponding to the driver
Network card A:
ls /sys/devices/c9410000.ethernet/driver
Returns the following content:
bindc9410000.ethernetueventunbind
And for network card B:
ls /sys/devices/c9420000.ethernet/driver
Returns the following content:
bindc9420000.ethernetueventunbind
2. Unbind and rebind
a. Unbind
echo "c9410000.ethernet" > /sys/devices/c9410000.ethernet/driver/unbind
echo "c9420000.ethernet" > /sys/devices/c9420000.ethernet/driver/unbind
b. Rebind
echo "c9420000.ethernet" > /sys/devices/c9420000.ethernet/driver/bind
echo "c9410000.ethernet" > /sys/devices/c9410000.ethernet/driver/bind
This effectively swaps the order of unbinding and rebinding. During debugging, you can also unbind and then rebind, which is equivalent to reloading the driver for the device; or unbind the original driver and then bind a new driver. The above commands are for reference only and are convenient for debugging; some systems may encounter OOPS during operation, so please handle according to the actual situation.