數位天堂

Nokia:科技始終來自於人性; 拜耳:如果文明不能使我們更相愛,那科技便失去意義!
歡迎您的加入,讓我們一起討論科技與環保的整合應用...

您尚未登入。

#1 2010-09-01 22:38:08

hippo
天使
註冊日期: 2008-10-07
文章數: 1562
目前積分 :   20 

BusyBox v1.17.2 編譯測試

韌體內建的BusyBox是精簡過的, 功能或許夠用, 但不完整. 嘗試自行編譯.

若要直接使用別人已編譯好的檔案, 請參考這篇.

使用Optware提供的compiler, 或tomato-ND-USBmod(K24), tomato-RT(K26)提供的cross compiler, 都無法將完整的命令作編譯. 有些命令更與核心版本有所關聯, 所以得事先經過篩選(make menuconfig). 不過, 這樣就不是我要的BusyBox.

機型: 華碩WL-500W
韌體: 泰迪熊 v1.28.9049 MIPSR1-beta19 K26 USB vpn3.6
編譯環境: Debian Lenny v5.0.5

1. chroot至Debian.
2. BusyBox下載, 解壓縮, 參閱內附說明文件.
3. 編譯.(static library)

# make defconfig # make LDFLAGS="--static"


4. 結果

# ls -l busybox -rwxr-xr-x 1 root root 2298120 Sep 1 01:00 busybox


# ./busybox --help BusyBox v1.17.2 (2010-09-01 00:06:42 CST) multi-call binary. Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko and others. Licensed under GPLv2. See source distribution for full notice. Usage: busybox [function] [arguments]... or: function [arguments]... BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as. Currently defined functions: [, [[, acpid, addgroup, adduser, adjtimex, arp, arping, ash, awk, basename, beep, blkid, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw, cttyhack, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, insmod, install, ionice, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, last, length, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.minix, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nc, netstat, nice, nmeter, nohup, nslookup, ntpd, od, openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, popmaildir, poweroff, printenv, printf, ps, pscan, pwd, raidautorun, rdate, rdev, readahead, readlink, readprofile, realpath, reboot, reformime, renice, reset, resize, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run-parts, runlevel, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont, setkeycodes, setlogcons, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, smemcap, softlimit, sort, split, start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, ttysize, tunctl, udhcpc, udhcpd, udpsvd, umount, uname, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, volname, wall, watch, watchdog, wc, wget, which, who, whoami, xargs, xz, xzcat, yes, zcat, zcip


編譯後的busybox, 可於MIPSR1 K26使用. 若於K24使用, 則出現錯誤:

# ./busybox --help FATAL: kernel too old Illegal instruction




最後修改: hippo (2011-02-11 14:46:56)


離線

 

#2 2011-02-11 14:46:03

hippo
天使
註冊日期: 2008-10-07
文章數: 1562
目前積分 :   20 

Re: BusyBox v1.17.2 編譯測試

BusyBox, 無論是自己編譯, 或取用別人已編譯好的(參考, ), 最簡單的使用方式是建立連結. 但function那麼多, 有些function是系統管理者專用, 一一建立連結豈不昏倒在地. 以下簡述自訂連結過程.

機型: 華碩 WL-500W
韌體: 泰迪熊 v1.28.9054 MIPSR1-beta K26 USB vpn3.6
BusyBox: v1.18.3 (dynamic library)
編譯平台: Mandriva 2010.2
交叉編譯器: tomato-RT K26

# ./busybox --help BusyBox v1.18.3 (2011-02-11 11:53:09 CST) multi-call binary. Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko and others. Licensed under GPLv2. See source distribution for full notice. Usage: busybox [function] [arguments]... or: busybox --list[-full] or: function [arguments]... (省略)


連結路徑:

# ./busybox --list-full usr/bin/[ usr/bin/[[ sbin/acpid (省略)


程式執行路徑:

# echo $PATH /bin:/usr/bin:/sbin:/usr/sbin:/home/root:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin:


/(root)下的動不了, /opt/下的可能會與Optware衝突, 所以拿/mmc/來開刀好了.
當然, 您也可以自己修改環境變數值, 參考/etc/profile內容. $PATH可在三處修改, 分別是nvram的env_path, /jffs/etc/profile, /opt/etc/profile

假設busybox置於/jffs/usr/bin/內
# vi busybox-link.sh

#!/bin/sh [ ! -d mmc ] && mkdir mmc mount -o bind mmc /mmc for D in bin sbin usr/bin usr/sbin; do mkdir -p /mmc/$D done ln -s /jffs/usr/bin/busybox /mmc/bin/busybox for L in `/mmc/bin/busybox --list-full`; do ln -s /mmc/bin/busybox /mmc/$L done


執行之後, 自行驗證結果.



離線

 

#3 2011-08-10 14:21:31

hippo
天使
註冊日期: 2008-10-07
文章數: 1562
目前積分 :   20 

Re: BusyBox v1.17.2 編譯測試

第一篇是在WL-500W編譯, 速度最慢. 第二篇是在x86交叉編譯. 本篇使用Lly K26 x86_64 Toolchain編譯BusyBox v1.18.5.

編譯平台: Mageia x86_64
交叉編譯器: wl500g Toolchain (gcc 4.4.6 uClibc 0.9.32) K26 x86_64 build 2011.07.08

1. 參考這篇或wl500g wiki建立K26編譯環境.
2. 下載BusyBox v1.18.5, 解壓縮, 建立.config

$ make defconfig


3. 參考Tomato Utilitiestomato-busybox, 修改.config
$ vi .config

CONFIG_CROSS_COMPILER_PREFIX="mipsel-uclibc-"


4. 編譯

$ make


5. 結果

$ file busybox busybox: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, stripped


6. 驗證(Tomato PL K26@WL-500W)

# ./busybox --help BusyBox v1.18.5 (2011-08-10 12:32:28 CST) multi-call binary. Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko and others. Licensed under GPLv2. See source distribution for full notice. ...



離線

 

相關討論主題

主題 回覆 點閱 最後發表
28 144201 2020-10-03 09:38:19 作者 a7700741
13 52499 2011-01-05 17:58:37 作者 hippo
2 17417 2010-11-01 09:00:33 作者 hippo
2 15135 2010-04-15 16:47:35 作者 hannahmo

友情連結

論壇頁尾

Powered by PunBB
© Copyright 2018 Rickard Andersson
RSS Feed