由于制作initramfs文件系统启动时会在根文件系统中执行第一个init程序,它对uboot传过来的参数init=/linuxrc不予理睬,所以需要在制作的根文件系统里的根目录加入init程序,否则无法启动。init程序和linuxrc程序一样都是符号链接文件,它们都是指向/bin/busybox程序。
[lingyun@localhost rootfs]$ ll
total 60
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
lrwxrwxrwx 1 root root 11 Apr 26 15:16 linuxrc -> bin/busybox
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
[lingyun@localhost rootfs]$ ln -s bin/busybox init
[lingyun@localhost rootfs]$ ll
total 60
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
lrwxrwxrwx 1 lingyun trainning 11 Apr 27 21:19 init -> bin/busybox
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
lrwxrwxrwx 1 root root 11 Apr 26 15:16 linuxrc -> bin/busybox
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
[lingyun@localhost rootfs]$
[lingyun@localhost kernel]$ ls
build.sh linux-3.0 linux-3.0.tar.bz2 patch
[lingyun@localhost kernel]$ cd linux-3.0
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
。 。 。 。 。 。
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/opt/rootfs) Initramfs source file(s) #输入根文件系统的所在目录
。 。 。 。 。 。
[lingyun@localhost linux-3.0]$ ls
arch crypto fs Kbuild linuxrom-s3c2440.bin modules.builtin README security usr
block Documentation include Kconfig MAINTAINERS modules.order REPORTING-BUGS sound virt
COPYING drivers init kernel Makefile Module.symvers samples System.map vmlinux
CREDITS firmware ipc lib mm net scripts tools vmlinux.o
[lingyun@localhost linux-3.0]$ du -h linuxrom-s3c2440.bin
6.9M /tftp/linuxrom-s3c2440.bin
[lingyun@localhost linux-3.0]$ mv linuxrom-s3c2440.bin /tftp/
因为文件系统和内核是集成在一起的,所以不需要制作文件系统映像
下面对uboot进行修改。
[ s3c2440@guowenxue ]# pri
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
bkr=tftp 30008000 uImage-$cpu.gz;nand erase 100000 400000;nand write 30008000 100000 $filesize
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
cpu=arm920t
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bootargs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
filesize=4DF000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.111
serverip=192.168.1.3
bootcmd=run bootcmd_rootfs
stdin=serial
stdout=serial
stderr=serial
Environment size: 2064/131068 bytes
[ s3c2440@guowenxue ]#
[ s3c2440@guowenxue ]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000'
[ s3c2440@guowenxue ]# set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'
[ s3c2440@guowenxue ]# set bootcmd_initramdisk 'nand read 30008000 100000 800000;bootm 30008000'
[ s3c2440@guowenxue ]# set bootcmd 'run bootcmd_initramdisk'
[ s3c2440@guowenxue ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... Done
[ s3c2440@guowenxue ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###################################
done
Bytes transferred = 7187832 (6dad78 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@guowenxue ]# boot
NAND read: device 0 offset 0x100000, size 0x800000
8388608 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-04-27 9:26:23 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 7187540 Bytes = 6.9 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #3 Fri Apr 26 22:06:01 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 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: noinitrd console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7
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: 48940k/48940k available, 16596k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0a77000 (10684 kB)
.text : 0xc0a77000 - 0xc0f3b000 (4880 kB)
.data : 0xc0f3c000 - 0xc0f6bc40 ( 192 kB)
.bss : 0xc0f6bc64 - 0xc0f980c4 ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab <bio-0> at 0
SCSI subsystem initialized
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
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
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
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 95
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
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 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
dm9000 dm9000.0: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: fe:82:53:01:3c:fa (random)
usbcore: registered new interface driver rt2800usb
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: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (764 buckets, 3056 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-09 16:43:58 UTC (1673282638)
Freeing init memory: 10684K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
dm9000 dm9000.0: eth0: link down
Copyright (C) 2013 fulinux<[email protected]>
root login: dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Copyright (C) 2013 fulinux<[email protected]>
root login: root
>:
>: ls
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr
>:
这样initramfs文件系统就制作成功:-)