1.下载ethtool源代码
git clone git://git.kernel.org/pub/scm/network/ethtool/ethtool.git
2.准备交叉编译工具
可以从codesoucery下载
3.编译
假设目标机器的规格如下:
ABI: EABI version 4
little endian
armv5te
按如下顺序运行:
./autogen.sh
./configure CC=CROSS-COMPILER PATH CFLAGS=-march=armv5te --host=arm-xx-linux
或者 cat /proc/cpuinfo 查看mcpu属性或march属性,添加对应configure属性
./configure CC=CROSS-COMPILER CFLAGS=-mcpu=cortex-a7 --host=arm-xx-linux
如果需要静态编译则
打开vim Makefile 在CC= CROSS-COMPILER后面加上--static
保存
make
就在当前文件夹内生成一个可执行文件ethtool
确认编译后的文件
readelf -h ethtool
确认以下信息(具体内容要看自己的配置了)
OS/ABI UNIX - System V
Machine :ARM
Flags Version4 EABI
命令描述:
ethtool 是用于查询及设置网卡参数的命令。
使用概要:
ethtool ethx //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0、eth1等等
ethtool –h //显示ethtool的命令帮助(help)
ethtool –i ethX //查询ethX网口的相关信息
ethtool –d ethX //查询ethX网口注册性信息
ethtool –r ethX //重置ethX网口到自适应模式
ethtool –S ethX //查询ethX网口收发包统计
ethtool –s ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off] //设置网口速率10/100/1000M、设置网口半/全双工、设置网口是否自协商