busybox-1.20.2 交叉编译 并构建最小根文件系统

1 导出交叉编译器路径:

export PATH=$PATH:/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/


2 进入busybox-1.20.2目录执行make menuconfig

Busybox Settings  ---> 

Build Options  --->  

[ ] Build BusyBox as a static binary (no shared libs) 

( ) Cross Compiler prefix 

Cross Compiler prefix 输入交叉编译器前缀:arm-none-linux-gnueabi-

如果需要静态编译busybox,可以选上以下这一项:Build BusyBox as a static binary (no shared libs) 

Installation Options ("make install" behavior)  --->  

( ) BusyBox installation prefix 

BusyBox installation prefix 输入.bin,即make install后安装到.bin目录下


3 建立安装目录:mkdir bin

4 编译:make 

5 安装:make install

到此,busybox已经全部编译结束。


进入安装bin目录下,建立最小根文件系统所需其他目录:mkdir dev  etc  lib  mnt  proc  sbin  sys  tmp  usr

进入etc下,建立以下两个文件:inittab  rcS

inittab文件内容:

# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run


# Startup the system
::sysinit:/etc/rcS


# Set up a couple of getty's
# Put a getty on the serial port
ttymxc0::askfirst:/bin/sh
#ttymxc0::respawn:/bin/sh 


# Logging junk


# Stuff to do before rebooting
#null::shutdown:/bin/umount -a -r


rcS文件内容:

#!/bin/sh
mount -t proc /proc /proc
mount -t sysfs /sys /sys
#busybox --install -s
mount tmpfs /tmp -t tmpfs -o size=80%
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

ifconfig eth0 192.168.1.11 up
ifconfig lo up &


进入dev下建立两个设备文件:console  null

mknod console c 5 1

mknod null c 1 3


由于我用来做initramfs,所以把linuxrc改为init:mv linuxrc init

接下来就是把busybox所需动态库拷贝到lib下,首先查看一下所需动态库: arm-none-linux-gnueabi-readelf -d bin/busybox  

Dynamic section at offset 0xe400c contains 25 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0xbfbc
 0x0000000d (FINI)                       0xca524
 0x00000019 (INIT_ARRAY)                 0xf4000
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0xf4004
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000004 (HASH)                       0x8168
 0x00000005 (STRTAB)                     0xa3dc
 0x00000006 (SYMTAB)                     0x8b9c
 0x0000000a (STRSZ)                      3232 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0xf40fc
 0x00000002 (PLTRELSZ)                   2968 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0xb424
 0x00000011 (REL)                        0xb3c4
 0x00000012 (RELSZ)                      96 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0xb384
 0x6fffffff (VERNEEDNUM)                 2
 0x6ffffff0 (VERSYM)                     0xb07c
 0x00000000 (NULL)                       0x0


一般只需要拷贝以上两个红色标注的动态库,但是为了以后开发不需要重修拷贝,把整个交叉编译器的库都拷到lib下。


至此,最小根文件系统已经构建完成。


Busybox for Android v1.20.2 Stable built by Linus Yang [Aug 12, 2012 Update] - Update to 1.20.2 stable [Features] - Tested on Android 2.1, 2.3, 4.0 and 4.1. Should be capable with all Android devices (Use at your own risk) - ELF armv5te binary (statically linked) - More suitable for Android than the prebuilt ARM binaries from busybox.net - IPv6 support, using own DNS resolver, correct user name display and more improvements for Android [Install] wget http://yangapp.googlecode.com/files/busybox-1.20.2 mv busybox-1.20.2 busybox chmod 755 busybox ./busybox --install [INSTALL_DIR] You can build by yourself from my github's project: (forked from tias/android-busybox-ndk) https://github.com/linusyang/android-busybox-ndk [Information] BusyBox v1.20.2-linusyang (2012-08-12 21:41:27 CST) multi-call binary. Copyright (C) 1998-2011 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: busybox --install [-s] [DIR] 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, adjtimex, ar, arp, arping, ash, awk, base64, basename, bbconfig, beep, blkid, blockdev, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cttyhack, cut, date, dc, dd, deallocvt, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flash_lock, flash_unlock, flashcp, flock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifup, inetd, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, less, linuxrc, ln, loadkmap, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.minix, mkfs.reiser, mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap, popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev, readlink, readprofile, realpath, reboot, reformime, renice, reset, resize, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run-parts, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setconsole, setkeycodes, setlogcons, setserial, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, smemcap, softlimit, sort, split, start-stop-daemon, stat, strings, stty, 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, tune2fs, ubiattach, ubidetach, ubimkvol, ubirmvol, ubirsvol, ubiupdatevol, udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, volname, watch, watchdog, wc, wget, which, whoami, whois, xargs, xz, xzcat, yes, zcat, zcip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值