嵌入式linux因资源紧缺,所以在制作根文件系统时,使用的是经过裁剪之后的busybox,然而很多工具都没有添加到根文件系统内部(如:traceroute)。假设现在要使用traceroute工具,需按照如下步骤添加:
1. 下载busybox
https://busybox.net/downloads/,这里下载的是 busybox-1.23.1.tar.bz2
2. 解压
tar jxvf busybox-1.23.1.tar.bz2 -C ./
3. 添加默认配置
make defconfig
4. make menuconfig
Busybox Setting ----->
Build Options ----->
#a. 选择将busybox进行静态编译,根文件系统为只读的,只能将其工具编译成静态库,否则无法使用!
[*]Build BusyBox as a static binary (no shared libs)
#b. 指定交叉编译器,不同的交叉编译工具对应的路径不一样,可以通过which工具查看(如:which arm-none-linux-gnueabi-gcc)
(/opt/9G25/arm-2009q1/bin/arm-none-linux-gnueabi-)Cross Compiler prefix
-------------------------------------------------------------------------------------------------------------------
进入menuconfig菜单选择traceroute
5. make CROSS_COMPILE=arm-none-linux-gnueabi-
6. make install
7. 在busybox-1.23.1\_install\目录下将生成traceroute工具
8. 将traceroute工具拷贝到嵌入式linux平台运行
[root@mike app]$./traceroute
BusyBox v1.23.1 (2018-08-04 14:56:49 CST) multi-call binary.
Usage: traceroute [-46FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]
[-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]
[-z PAUSE_MSEC] HOST [BYTES]
Trace the route to HOST
-4,-6 Force IP or IPv6 name resolution
-F Set the don't fragment bit
-I Use ICMP ECHO instead of UDP datagrams
-l Display the TTL value of the returned packet
-d Set SO_DEBUG options to socket
-n Print numeric addresses
-r Bypass routing tables, send directly to HOST
-v Verbose
-m Max time-to-live (max number of hops)
-p Base UDP port number used in probes
(default 33434)
-q Number of probes per TTL (default 3)
-s IP address to use as the source address
-t Type-of-service in probe packets (default 0)
-w Time in seconds to wait for a response (default 3)
-g Loose source route gateway (8 max)