Académique Documents
Professionnel Documents
Culture Documents
(Chin-Feng Lai)
Assistant Professor, institute of CSIE, National Ilan University Sep 29th 2012
2012 MMN Lab. All Rights Reserved
2012
Outline
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
File System
Everything is a file.
In linux
/dev/hda /dev/hdb /dev/hdf /dev/sda /dev/sdb /dev/sdf
Description Essential user command binaries Static files of the boot loader
/dev/ /etc/
/home/ /lib/
10
dev \
bin Partition 2 home
File System Hierarchy Standard
11
Indexed allocation
12
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
13
Common features
14
15
C library (Libc)
Virtual File System (VFS) ext2 . ext3 FTL or NFTL MTD => Flash memory JFFS2 . YAFFS2
Abstraction Layer
Kernel Space
Hardware
16
fb
Process
File object
f_dentry
Dentry object
d_inode i_sb
Disk File
Inode object
17
18
super_operations object
19
inode_operations object
dentry_operations object
Shm
Sysfs usbfs /sys /proc/bus/usb
IPC
USB
20
/sys
models specific kernel objects such as physical devices and provides a way to associate devices with device drivers
21
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
22
Introduction to BusyBox
BusyBox combines tiny versions of many common UNIX utilities into a single small executable It has been called "The Swiss Army Knife of Embedded Linux Easy to use Releasing as Free software
under the GNU General Public License
23
Introduction to BusyBox
Size-optimization and limited resources Easily include or exclude features Provides a fairly complete POSIX environment Easy to customize your small or embedded systems BusyBox is a multi-call binary
an executable program that performs the same job as more than one utility program.
24
Introduction to BusyBox
BusyBox source tree
. |-- applets |-- arch |-- archival |-- AUTHORS |-- busybox |-- busybox.links |-- busybox_unstripped |-- busybox_unstripped.map |-- busybox_unstripped.out |-- Config.in |-- console-tools |-- coreutils |-- debianutils |-- docs |-- e2fsprogs |-- editors |-- examples |-- findutils |-- include |-- init |-- _install |-- INSTALL |-- libbb |-- libpwdgrp |-- LICENSE |-- loginutils |-- Makefile |-- Makefile.custom |-- Makefile.flags |-- Makefile.help |-- miscutils |-- modutils |-- networking |-- printutils |-- procps |-- README |-- runit |-- scripts |-- selinux |-- shell |-- sysklogd |-- testsuite |-- TODO |-- TODO_config_nommu `-- util-linux
25
25
Introduction to BusyBox
Currently available applets include:
[, [[, 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, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod,devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname,dos2unix, dpkg, du, dumpkmap, dumpleases, echo, ed, egrep, eject,env, envdir, envuidgid, expand, expr, fakeidentd, false, fbset,fbsplash, fdflush, fdformat, fdisk, fgrep, find, findfs, flash_lock,flash_unlock, fold, free, freeramdisk, fsck, fsck.minix, fsync,ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, hd,hdparm, head, hexdump, hostid, hostname, httpd, hush, 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, losetup, lpd, lpq, lpr,ls, lsattr, lsmod, lzmacat, lzop, lzopcat, makemime, man, 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, ps, pscan, pwd,raidautorun, rdate, rdev, readlink, readprofile, realpath,reformime, renice, reset, 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, stty, su, sulogin, sum, sv,svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, 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, watch, watchdog, wc, wget, which, who,whoami, xargs, yes, zcat, zcip
26
Introduction to BusyBox
Three steps:
$ make menuconfig (configure) $ make (to compile BusyBox using your .config) $ make install (install the 'bin/busybox' binary)
After make install, will create a dir named _install containing BusyBox utilities and basic root File System make menuconfig
BusyBox is extremely configurable. allows you to include only the components you need, thereby reducing binary size. Run xxxxconfig' to select the functionality that you wish to enable.
27
Introduction to BusyBox
make menuconfig
28
Introduction to BusyBox
Some of the make options available for BusyBox
Make target
help defconfig allnoconfig allyesconfig config menuconfig
Description
Show the complete list of make options Enable a default (generic) configuration Disable all applications (empty configuration) Enable all applications (complete configuration) Text-based configurator N-curses (menu-based) configurator
all
busybox clean distclean sizes
29
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
30
31
32
33
35
35
36
37
MTD modules
YAFFS
MTD Chip drivers
NOR flash
NAND flash
RAM
ROM
Memory devices
Hardware
38
UBI subsystem
which is a wear-leveling and volume management.
MTD
Block Block Block Block Block Block
39
40
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
41
42
mount
Mount a file system Serves to attach the file system found unmount will detach
43
Bootloader
Kernel
File System
44
3. Make UBI.img by
$ sudo [tool_path]/ubinize -o ubi.img -m 2048 -p 128KiB -s 512 [tool_path]/ubinize.cfg
45
UBIFS
MTD modules
46
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Network File System Introduction LAB
47
48
49
No need for users to have separate home directories or disk partition on every network machine for sharing Storage devices such as floppy disks and CDROM drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.
50
NFS Mapping
51
MMN Lab.
NFS server
Share the file directory to clients as file system
NFS Client
Connect to server and mount NFS on local machine
52
NFS client 2 NFS client 1 mount /root/nfs to /home/data/sharefile mount /root/nfs to /mnt/nfs/sharefile
53
In Cross-development environment
54
File system Overview File Abstraction Layer Introduction to BusyBox File system format File system image tool Trivial File Transfer Protocol Introduction Network File System Introduction LAB
55
LABLearn
Learn how to use File System
Understanding BusyBox How to create BusyBox File System
56
FS LAB
Step1 : Get the source code & tool
Host$ cd ~/embed/src Host$ tar -xvf busybox-1.18.5.tar.bz2
57
FS LAB
Step3 : Use make utility to build
Host$ cd ~/embed/src/busybox-1.18.5 Host$ make menuconfig
Busybox Settings ---> Build Options ---> [*] Build BusyBox as a static binary (no shared libs)
FS LAB
All binary file link to busybox
59
FS LAB
Compile busybox and output _install folder
Step5 : Configure
60
FS LAB
Step6 : Libary configure
Host$ cd ~/embed/rootfs
61
FS LAB
Step8 : Connect Devkit8000
Host$ kermit -c
62
FS LAB
Step9 : Set the target boot argument
Devkit8000# setenv bootargs console=ttyS2,115200n8 rootdelay=1 root=/dev/mmcblk0p2 rw init/init Devkit8000# setenv bootcmd mmcinit;fatload mmc 1 80300000 uImage;bootm 80300000 Devkit8000# save
63
FS LAB
Devkit8000# pri
See the arguments of environment
64
FS LAB
Step10: Run boot
Devkit8000# boot
65
LAB (Coding)
Write a hello world program use cross compiler to compile
Host$ arm-none-linux-gnueabi-gcc hello.c -o hello Host$ cp hello ~/embed/rootfs
66