• A Linux system needs a basic set of
programs to work
– An init program
– A shell
• Various basic utilities for le
manipulation and system configuration
• In normal Linux systems, those
programs are provided by different projects
– coreutils, bash, grep, sed, tar, wget,
modutils, etc. are all different projects
– A lot of different components to
integrate
– Components not designed with
embedded systems constraints in mind: they are not very configurable and have a
wide range of features
• Busybox is an alternative solution, extremely
common on embedded systems
General purpose
toolbox: Busybox
• Rewrite of many useful Unix command
line utilities
– Integrated into a single project,
which makes it easy to work with
– Designed with embedded systems in
mind: highly configurable, no unnecessary features
• All the utilities are compiled into
a single executable, /bin/busybox
– Symbolic links to /bin/busybox are
created for each application integrated into Busybox
• Although BusyBox does not support
all the options provided by the commands it replaces, the subset it provides is
sufficient for most typical uses
Configuring busybox
• Congure BusyBox (creates a .config
le):
– make defconfig
Good to begin with BusyBox.
Congures BusyBox with all options for regular users.
• make allnoconfig
– Unselects all options. Good to
congure only what you need.
• make xconfig (graphical, needs the
libqt3-mt-dev package) or make menuconfig (text)
– Same conguration interfaces as the
ones used by the Linux kernel (though older versions are used).
Compiling Busybox
• Using
“make menuconfig” command you can choose the commands to compile and the
commands options and features that you need.
• Set the cross-compiler prefix in the
conguration interface:
– BusyBox Settings -> Build Options
-> Cross Compiler prefix
– Example: arm-linux-
• Set the installation directory in
the conguration interface:
– BusyBox Settings -> Installation
Options -> BusyBox installation prefix
• Add the cross-compiler path to the
PATH environment variable:
– export
PATH=/usr/xtools/arm-unknown-linux-uclibcgnueabi/bin:$PATH
• Compile BusyBox:
– Make
– Install it (this creates a Unix
directory structure symbolic links to the busybox executable):
• make install
Using busybox
commands
• To understand how best to use
BusyBox, let's first take a look at the components installed on the target's
root filesystem by BusyBox's build process. As observed there is only one executable was installed, /bin/busybox.
• This is the single binary with
support for all the commands configured This binary is never called directly,
however. Instead, symbolic links bearing the original commands' names have been
created to /bin/busybox. Such symbolic links have been created in all the
directories in which the original commands would be found, including /bin,
/sbin, /usr/bin, and /usr/sbin.
• When you type a command during the
system's normal operation, the busybox command is invoked via the symbolic
link. In turn, busybox determines the actual command you were invoking using
the name being used to run it. /bin/ls, for instance, points to
/bin/busybox.
• When you type ls, the busybox command
is called and it
determines that you were trying to use the ls command, because ls is the first
argument on the command line
Busy box
• Busy
box provides all the required functionality while still remaining a very
small-size application
• BusyBox implements many commands.
Here are a few:
• ar, cat, chgrp, chmod, chown, chroot, cp,
cpio, date, dd, df, dmesg, dos2unix, du, echo, env, expr, find, grep, gunzip,
gzip, halt, id, ifconfig, init, insmod, kill, killall, ln, ls, lsmod, md5sum,
mkdir, mknod, modprobe, more, mount, mv, ping, ps, pwd, reboot, renice, rm,
rmdir, rmmod, route, rpm2cpio, sed, stty, swapon, sync, syslogd, tail, tar,
telnet, tftp, touch, traceroute, umount, uname, uuencode, vi, wc, which, and
whoami.
• Although BusyBox does not support
all the options provided by the commands it replaces, the subset it provides is
sufficient for most typical uses.
No comments:
Post a Comment