暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
busybox.pdf
172
13页
0次
2023-08-30
10墨值下载
CHAPTER 14
BusyBox and Linux initialization
Chapter Outline
Introducing BusyBox 220
Configuring and Installing BusyBox 220
BusyBox Settings 222
Applets 224
Building and Installing 225
Using BusyBox 226
User Space Initialization 226
Stage 1 Boot Loader 226
Stage 2 MLO 227
U-Boot 227
Linux Kernel 227
Systemd 228
User Space Initialization, the “Old Way” 230
Resources 231
Linux: the choice of a GNU generation
ksh@cis.ufl.edu put this on T-shirts in 1993
Very often the biggest problem in an embedded environment is the lack of resources,
specifically memory and storage space. As you have no doubt observed, either in the course
of reading this book, or from other experience, Linux is big! The kernel itself is often in the
range of two to four megabytes, and then there is the root file system, with its utility
programs and configuration files. Granted, our BBB is running a full Debian distro, but
still, we are limited to the 4 GB eMMC, or a microSD card.
In this chapter, we will look at a powerful tool for substantially reducing the overall
“footprint” of Linux to make it fit in limited resource embedded devices. The other topic
we will address in this chapter is User Space initialization, and specifically the question of
how to get our thermostat application to start at boot up.
219
Linux for Embedded and Real-time Applications.
DOI:
http://dx.doi.org/10.1016/B978-0-12-811277-9.00014-6
© 2018 Elsevier Inc. All rights reserved.
Introducing BusyBox
Even if your embedded device is “headless,” that is it has no screen and/or keyboard in the
usual sense for user interaction, you still need a minimal set of command line utilities. You
will no doubt need
mount, ifconfig, and probably several others to get the system up and
running. Remember that every shell command line utility is a separate program, with its
own executable file.
The idea behind BusyBox is brilliantly simple. Rather than have every utility be a separate
program with its attendant overhead, why not simply write one program that implements all
the utilities? Well, perhaps not all, but a very large number of the most common utilities.
Most utilities require the same set of “helper” functionality, such as parsing command lines
and converting ASCII to binary. Rather than duplicating these functions in hundreds of
files, BusyBox implements them exactly once.
The BusyBox project began in 1996, with the goal of putting a complete Linux system on a
single floppy disk that could serve as a rescue disk or an installer for the Debian Linux
distribution. A rescue disk is used to repair a Linux system that has become unbootable.
This means the rescue disk must be able to boot the system and mount the hard disk file
systems, and it must provide sufficient command line tools to bring the hard disk root file
system back to a bootable state.
Subsequently, embedded developers figured out that this was an obvious way to reduce the
Linux footprint in resource-constrained embedded environments. So the project grew well
beyond its Debian roots, and today BusyBox is a part of almost every commercial
embedded Linux offering, and is found in a wide array of Linux-based products, including
numerous routers, and media players.
BusyBox calls itself the “Swiss army knife” of embedded Linux because, like the knife, it
is an all-purpose tool. Technically, the developers refer to it as a “multi-call binary,”
meaning that the program is invoked in multiple ways to execute different commands. This
is done with symbolic links named for the various utilities. These links then all point to the
BusyBox executable.
Configuring and Installing BusyBox
The version of BusyBox running on my BBB is 1.20.2. Go to the website in the
“Resources” section and download that version, or any other one that matches your board
or strikes your fancy. Oddly, even though the BBB incorporates BusyBox, it appears there
are only two links to it. This may be because we are running a Debian distro, and Debian
itself does not use BusyBox.
220 Chapter 14
BusyBox is highly modular and configurable. While it is capable of implementing over 300
hundred shell commands, by no means are you required to have all of them in your system.
The configuration process lets you choose exactly which commands will be included in
your system.
Table 14.1 is the full list of commands available in recent releases of
BusyBox.
Table 14.1: BusyBox commands
[
[[
acpid
addgroup
adduser
adjtimex
ar
arp
arping
ash
awk
basename
beep
blkid
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
dirname
dmesg
dnsd
dnsdomainname
dos2unix
dpkg
du
dumpkmap
dumpleases
echo
ed
egrep
eject
env
envdir
envuidgid
expand
expr
fakeidentd
false
fbs plash
fdflush
fdformat
fdisk
fgrep
find
findfs
flash_lock
flash_unlock
fold
free
freeramdisk
fsck
fsck.minix
fsync
ftpd
ftpget
ftpput
fuser
getopt
hwclock
id
ifconfig
ifdown
ifenslave
ifplugd
ifup
inetd
init
inotifyd
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
md5sum
mdev
mesg
microcom
mkdir
mkdosfs
mkfifo
mkfs.minix
mkfs.vfat
mknod
mkpasswd
mkswap
mktemp
modprobe
more
mount
mountpoint
mt
mv
nameif
nc
netstat
nice
nmeter
nohup
nslookup
od
openvt
passwd
patch
pgrep
pidof
ping
ping6
pipe_progress
pivot_root
pkill
popmaildir
printenv
printf
resize
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
softlimit
sort
split
start-stop-daemon
stat
strings
sty
su
tac
tail
tar
taskset
tcpsvd
tee
telnet
telnetd
test
tftp
tftpd
time
timeout
top
touch
tr
traceroute
true
tty
ttysize
udhcpc
udhcpd
udpsvd
umount
uname
uncompress
unexpand
uniq
unix2dos
unlzma
unlzop
unzip
uptime
usleep
uudecode
uuencode
vconfig
vi
vlock
volname
(Continued)
BusyBox and Linux initialization 221
of 13
10墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论