Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1254047
  • 博文数量: 479
  • 博客积分: 12240
  • 博客等级: 上将
  • 技术积分: 4999
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 17:12
文章分类

全部博文(479)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(95)

2010年(177)

2009年(167)

2008年(16)

2007年(21)

分类: LINUX

2009-10-14 21:37:43

initramfs usage


使用initramfs可以实现内核和文件系统在一个映像文件中,不过会增大内核体积,同时占用较多内存。

(1)准备根文件系统

先准备好根文件系统,放到某个目录,不过为了方便和内核一起打包,可以放到内核源代码的usr/目录下,我的做法是在usr目录下建立了image目录,然后将可用的根文件系统的内容全部复制到image目录下:
[chenxibing@localhost linux-2.6.27.8-smartarm3250]$ ls usr/image
bin   dev  hello.c       home  lib       mnt  proc  sbin  tmp  var
boot  etc  hello_static  init  Makefile  opt  root  sys   usr

另外千万注意,initramfs识别的第一个进程名称为init,因此需要将原来根文件系统中busybox的linuxrc链接改名为init。

(2)配置内核

配置内核,在General setup中使能initramfs,
 [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support 
 (./usr/image) Initramfs source file(s)  

同时在Userspace binary formats 中使能elf文件支持:
 [*] Kernel support for ELF binaries 

(3)编译内核,加载运行

make 
make uImage

编译出来后内核较大,由于根文件系统也比较大,我得到的内核有11M,加载后运行,解压的时间也变长了,但是内核运行之后很快就进入到shell界面了。

U-Boot 1.3.3 (Sep  1 2009 - 12:31:06)

DRAM:  64 MB
Flash:  2 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
U-Boot$   ru nfsboot
        HW MAC address:  00:01:90:00:C0:81
ENET:auto-negotiation complete
ENET:Link status up
ENET:FULL DUPLEX
ENET:100MBase
TFTP from server 192.168.7.238; our IP address is 192.168.7.236
Filename 'uImage'.
Load address: 0x81000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############################################
done
Bytes transferred = 12108228 (b8c1c4 hex)
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   Linux-2.6.27.8
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    12108164 Bytes = 11.5 MB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................................................................................................................................................................................................................................................................................................. done, booting the kernel.
Linux version 2.6.27.8 (chenxibing@localhost.localdomain) (gcc version 4.3.2 (crosstool-NG-1.3.1) ) #9 PREEMPT Thu Sep 3 09:55:52 CST 2009
CPU: ARM926EJ-S [41069264] revision 4 (ARMv5TEJ), cr=00053177
Machine: SmartARM3250 board with the LPC3250 Microcontroller
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-back cache
CPU0: I cache: 32768 bytes, associativity 4, 32 byte lines, 256 sets
CPU0: D cache: 32768 bytes, associativity 4, 32 byte lines, 256 sets
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: root=/dev/mtdblock4 console=ttyS0,115200 mem=64M rootfstype=yaffs2
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
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: 50972KB available (3352K code, 238K data, 10296K init)
Calibrating delay loop... 129.84 BogoMIPS (lpj=649216)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 288 bytes
NET: Registered protocol family 16
Invalid board descriptor!
LPC32XX DMA driver
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
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
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
yaffs Sep  3 2009 09:30:12 Installing.
msgmni has been set to 99
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: ZHIYUAN LCD hardware, XVGA portrait display
Console: switching to colour frame buffer device 128x48
Serial: 8250/16550 driver4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0x40090000 (irq = 9) is a 16550A
console [ttyS0] enabled
serial8250.0: ttyS1 at MMIO 0x40080000 (irq = 7) is a 16550A
serial8250.0: ttyS2 at MMIO 0x40088000 (irq = 8) is a 16550A
serial8250.0: ttyS3 at MMIO 0x40098000 (irq = 10) is a 16550A
lpc32xx_hsuart.0: ttyTX0 at MMIO 0x40014000 (irq = 26) is a lpc32xx_hsuart
lpc32xx_hsuart.0: ttyTX1 at MMIO 0x40018000 (irq = 25) is a lpc32xx_hsuart
lpc32xx_hsuart.0: ttyTX2 at MMIO 0x4001c000 (irq = 24) is a lpc32xx_hsuart
loop: module loaded
LPC32XX_mii_bus: probed
eth0: LPC32XX mac at 0x31060000 irq 29
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1)
Uniform Multi-Platform E-IDE driver
ide0 at 0xc4866020-0xc486602e,0xc486602e on irq 86
Driver 'sd' needs updating - please use bus_type methods
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 627 at 0x04e60000
Creating 5 MTD partitions on "lpc32xx_nand":
0x00000000-0x00180000 : "smartarm3250-boot"
0x00180000-0x001c0000 : "smartarm3250-ubt-prms"
0x00200000-0x00600000 : "smartarm3250-kernel"
0x00600000-0x01600000 : "smartarm3250-safefs"
0x01600000-0x10000000 : "smartarm3250-rootfs"
at25 spi0.0: 32 KByte at25256a eeprom, pagesize 64
I2C device at address 0x2d<6>ISP1301 Vendor ID  : 0x04cc
ISP1301 Product ID : 0x1301
ISP1301 Version ID : 0x0210
usb-ohci usb-ohci: at 0xf3120000, irq 0
usb-ohci usb-ohci: pnx4008 OHCI
usb-ohci usb-ohci: new USB bus registered, assigned bus number 1
usb-ohci usb-ohci: irq 59, io mem 0xf3120000
usb usb1: configuration #1 chosen from 1 choice
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.
mice: PS/2 mouse device common for all mice
input: LPC32xx Touchscreen as /class/input/input0
rtc-pcf8563 3-0051: chip found, driver version 0.4.3
rtc-pcf8563 3-0051: rtc core: registered rtc-pcf8563 as rtc0
rtc-lpc32xx rtc-lpc32xx: rtc core: registered rtc-lpc32xx as rtc1
i2c /dev entries driver
PNX4008-WDT: PNX4008 Watchdog Timer: heartbeat 19 sec
mmci-pl18x: DMA buffer(10000 bytes), P:0x812b0000, V:0xffdc0000
mmc0: MMCI rev 0 cfg 00 at 0x0000000020098000 irq 15,13
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.17.
ASoC version 0.13.2
UDA1380 Audio Codec 0.6<6>ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
ieee80211: 802.11 data/management/control stack, git-1.1.13
ieee80211: Copyright (C) 2004-2005 Intel Corporation
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 1
rtc-pcf8563 3-0051: setting system clock to 2009-09-03 10:09:04 UTC (1251972544)
Freeing init memory: 10296K                                         #占用的内存很大
init started: BusyBox v1.11.2 ()
starting pid 326, tty '': '/etc/rc.d/rcS'
Mounting /proc and /sys
Setting the hostname to zlg
Mounting filesystems
Running sysctl
Setting up networking on loopback device:
Setting up networking on eth0:
Adding static route for default gateway to 192.168.7.1:
Setting nameserver to 192.168.7.1 in /etc/resolv.conf:
Starting inetd:
Starting the port mapper:
starting pid 369, tty '': '-/bin/sh'
[root@zlg /]# ls
Makefile      etc           init          proc          tmp
bin           hello.c       lib           root          usr
boot          hello_static  mnt           sbin          var
dev           home          opt           sys
[root@zlg /]# ls
Makefile      etc           init          proc          tmp
bin           hello.c       lib           root          usr
boot          hello_static  mnt           sbin          var
dev           home          opt           sys
[root@zlg /]# free
                  total         used         free       shared      buffers
  Mem:        61328        44732        16596            0            0
 Swap:            0            0            0
Total:        61328        44732        16596
阅读(1758) | 评论(0) | 转发(0) |
0

上一篇:ARM9低功耗

下一篇:ARM Linux 解压

给主人留下些什么吧!~~