③文件系统制作
要用的的工具:busybox-1.13.3.tar.gz
null@ubuntu:~/work/test$ mkdir rootfs
null@ubuntu:~/work/test$ pwd
/home/null/work/test
这是我做实验的目录,rootfs用来存放制作的文件系统
进入rootfs目录
null@ubuntu:~/work/test$ cd rootfs/
创建以下目录:
null@ubuntu:~/work/test/rootfs$ mkdir bin dev etc lib proc sbin sys usr mnt tmp var
null@ubuntu:~/work/test/rootfs$ mkdir usr/bin usr/lib usr/sbin lib/modules
进入dev创建字符设备文件:
null@ubuntu:~/work/test/rootfs/dev$ sudo mknod -m 666 console c 5 1
[sudo] password for null:
null@ubuntu:~/work/test/rootfs/dev$ sudo mknod -m 666 null c 1 3
进入etc目录创建 fstab inittab profile 文件,创建init.d目录,然后再init.d下创建rcS文件
具体文件内容如下
#vim fstab
内容:
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
#vim inittab
内容:
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
#vim probile
内容:
# /etc/profile: system-wide .profile file for the Bourne shells
echo
echo -n "Processing /etc/profile... "
# no-op
echo "Done"
echo
#vim rcS
内容:
#! /bin/sh
/bin/mount -a
/bin/mount -t tmpfs mdev /dev
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
然后进入刚才的内核文件中:
执行下面的命令
null@ubuntu:~/work/linux-kernel/linux-2.6.32.2$ make modules
要等会儿
然后再执行:
null@ubuntu:~/work/linux-kernel/linux-2.6.32.2$ make modules_install ARCH=arm INSTALL_MOD_PATH=/home/null/work/test/rootfs
这个/home/null/work/test/rootfs是刚才文件系统安排的位置
进入/home/null/work/test/rootfs/lib/modules
会看到:
null@ubuntu:~/work/test/rootfs/lib/modules$ ls
2.6.32.2
下面是编译busybox
结构如上。
执行:
null@ubuntu:~/work/test/busybox-1.13.3$ make menuconfig
出现如下:
进入Busybox Settings ---> Build Options—>
选择:
Build BusyBox as a static binary (no shared libs)
然后选择:
Cross Compiler prefix
交叉编译工具链使用arm-linux-
然后进入:
Busybox Settings ---> Installation Options --->
如下:
文件系统的安装目录是:/home/null/work/test/rootfs ß这个看你安装的目录
如果不修改要破坏服务器的文件系统。。
保存退出:
执行如下命令:
null@ubuntu:~/work/test/busybox-1.13.3$ make ARCH=arm CROSS_COMPILE=arm-linux-
等会儿
null@ubuntu:~/work/test/busybox-1.13.3$ make install
结果:
--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
进入文件系统目录:会看到如下:
null@ubuntu:~/work/test/rootfs$ ls
bin dev etc lib linuxrc mnt proc sbin sys tmp usr var
然后我们把制作好的文件系统挂载
要修改/etc/exports文件,
null@ubuntu:~$ sudo vim /etc/exports
增加如下:
/home/null/work/test/rootfs *(rw,sync,no_root_squash)
这里增加的/home/null/work/test/rootfs 是我制作的文件系统的目录,你的可能不一样。
然后重启nfs服务器
如下:
把编译好的内核uImage拷贝到rootfs目录下。
下面启动服务器上的内核和文件系统。
这里设置u-boot ip和服务器ip就不说了。
这里要设置的是如下的内容:
setenv bootargs console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.107:/home/null/work/test/rootfs ip=192.168.1.109:smdk2440a.embedclub.com:eth0:off
/home/null/work/test/rootfs ß这个是我们服务器上的制作好的文件系统。
192.168.1.107 ß服务器IP
下面是我的u-boot参数:
bootcmd=nand read 0x30008000 60000 500000;bootm 0x30008000
bootdelay=1
baudrate=115200
ethaddr=08:08:11:18:12:27
gatewayip=192.168.1.1
netmask=255.255.255.0
embedclub=bmp d 70000
stdin=serial
stdout=serial
stderr=serial
lcdtype=w
ethact=dm9000
ipaddr=192.168.1.108
serverip=192.168.1.107
bootargs=console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.107:/home/null/work/test/rootfs ip=192.168.1.109:smdk2440a.embedclub.com:eth0:off
下面我们启动无盘mini2440:
nfs 31000000 192.168.1.107:/home/null/work/test/rootfs/uImage;bootm 31000000
内核启动参数如下:
Environment size: 428/131068 bytes
[u-boot@SMDK2440A]# nfs 31000000 192.168.1.107:/home/null/work/test/rootfs/uImage;bootm 31000000
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
File transfer via NFS from server 192.168.1.107; our IP address is 192.168.1.108
Filename '/home/null/work/test/rootfs/uImage'.
Load address: 0x31000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################
done
Bytes transferred = 2162436 (20ff04 hex)
## Booting kernel from Legacy Image at 31000000 ...
Image Name: Linux-2.6.32.2
Created: 2012-11-29 12:45:53 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2162372 Bytes = 2.1 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux....................................................................................................................................... done, booting the kernel.
Linux version 2.6.32.2 (null@ubuntu) (gcc version 4.4.3 (ctng-1.6.1) ) #1 Thu Nov 29 04:34:06 PST 2012
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: FriendlyARM Mini2440 development board
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.107:/home/null/work/test/rootfs ip=192.168.1.109:smdk2440a.embedclub.com:eth0:off
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60384KB available (3768K code, 462K data, 168K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000007
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 80x40
fb0: s3c2410fb frame buffer device
leds initialized
buttons initialized
pwm initialized
adc initialized
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 558 at 0x0000045c0000
Bad eraseblock 891 at 0x000006f60000
Bad eraseblock 1114 at 0x000008b40000
Bad eraseblock 1664 at 0x00000d000000
Bad eraseblock 1665 at 0x00000d020000
Bad eraseblock 1726 at 0x00000d7c0000
Bad eraseblock 1748 at 0x00000da80000
Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "supervivi"
uncorrectable error :
0x000000040000-0x000000060000 : "param"
ftl_cs: FTL header not found.
0x000000060000-0x000000560000 : "Kernel"
ftl_cs: FTL header not found.
0x000000560000-0x000040560000 : "root"
mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000
ftl_cs: FTL header not found.
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000
uncorrectable error :
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c4872300,c4876304 IRQ 51 MAC: 08:90:90:90:90:90 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
#0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: hctosys: invalid date/time
eth0: link down
IP-Config: Unable to set interface netmask (-22).
Looking up port of RPC 100003/2 on 192.168.1.107
eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1
Looking up port of RPC 100005/1 on 192.168.1.107
VFS: Mounted root (nfs filesystem) on device 0:14.
Freeing init memory: 168K
Processing /etc/profile... Done
# ls
bin etc linuxrc proc sys uImage var
dev lib mnt sbin tmp usr
大功告成