嵌入式Linux Ramdisk文件系统制作(u-boot, busybox)
申明:此贴乃引用贴为尊重原作者,特注明出处:随点BBShttp://www.b2tang.com/viewthread.php?tid=621&extra=page%3D1本文以mpc8247主板上移植Linux为例,详细讲解了嵌入式Linux Ramdisk文件系统制作过程,图文并茂,并有排错方法,涉及u-boot和busybox一、busybox的编译 首先是交叉编译设置,打开busyb
·
申明:此贴乃引用贴
为尊重原作者,特注明出处: 随点BBS
http://www.b2tang.com/viewthread.php?tid=621&extra=page%3D1
本文以mpc8247主板上移植Linux为例,详细讲解了嵌入式Linux Ramdisk文件系统制作过程,
图文并茂,并有排错方法,涉及u-boot和busybox
一、busybox的编译
首先是交叉编译设置,打开busybox根目录下的Makefile,进行修改
一般情况下,为了让busybox能够独立于其他的库文件而可以单独运行,需要将busybox编译成静态的。
而编译成静态的分为glibc和uclibc,如果系统没有安装uclibc的话,那就会报下面的错
解决办法是打开 applets/applets.c 将其中的错误注释掉
其他的busybox选项根据需要进行选择!
这样就在./_install目录下生成了busybox
二、ramdisk文件系统生成
上图中首先创见了一个10M的文件系统映象
然后使用losetup命令将此镜像与块设备/dev/loop0进行挂接
如果出现"ioctl: LOOP_SET_FD:设备或资源忙",说明/dev/loop0设备还和一文件联系,可用losetup /dev/loop0查看地,并可用-d 删除
上图是用命令mke2fs来格式化此块设备/dev/loop0,其实就是格式化我们刚生成的那个文件系统镜像,ext2格式
上图是挂载文件系统镜像,可见经过刚才格式化之后的文件系统镜像里面只有lost+found这个文件夹
之后可以将步骤一中生成的_install目录下的所有文件拷贝进来即可,
/et/init.d/rcS文件如下修改
其他的系统配置文件可以根据需要进行更改
三、u-boot加载内核和文件系统
为尊重原作者,特注明出处: 随点BBS
http://www.b2tang.com/viewthread.php?tid=621&extra=page%3D1
本文以mpc8247主板上移植Linux为例,详细讲解了嵌入式Linux Ramdisk文件系统制作过程,
图文并茂,并有排错方法,涉及u-boot和busybox
一、busybox的编译
首先是交叉编译设置,打开busybox根目录下的Makefile,进行修改
一般情况下,为了让busybox能够独立于其他的库文件而可以单独运行,需要将busybox编译成静态的。
CODE:
#make menuconfig
Busybox Settings --->
Build Options --->
Build BusyBox as a static binary (no shared libs) //静态
Installation Options --->
Don't use /usr //make install的时候不会安装到根目录,而是安装到./_install
Linux System Utilities --->
mdev //相当于udev
Support /etc/mdev.conf
Support command execution at device addition/removal
Shells --->
Choose your default shell (msh) //具有ash没有的功能,比如支持tab补齐,历史纪录等等的高级功能
Busybox Settings --->
Build Options --->
Build BusyBox as a static binary (no shared libs) //静态
Installation Options --->
Don't use /usr //make install的时候不会安装到根目录,而是安装到./_install
Linux System Utilities --->
mdev //相当于udev
Support /etc/mdev.conf
Support command execution at device addition/removal
Shells --->
Choose your default shell (msh) //具有ash没有的功能,比如支持tab补齐,历史纪录等等的高级功能
而编译成静态的分为glibc和uclibc,如果系统没有安装uclibc的话,那就会报下面的错
解决办法是打开 applets/applets.c 将其中的错误注释掉
其他的busybox选项根据需要进行选择!
CODE:
#make
#make install
#make install
这样就在./_install目录下生成了busybox
二、ramdisk文件系统生成
上图中首先创见了一个10M的文件系统映象
然后使用losetup命令将此镜像与块设备/dev/loop0进行挂接
如果出现"ioctl: LOOP_SET_FD:设备或资源忙",说明/dev/loop0设备还和一文件联系,可用losetup /dev/loop0查看地,并可用-d 删除
上图是用命令mke2fs来格式化此块设备/dev/loop0,其实就是格式化我们刚生成的那个文件系统镜像,ext2格式
上图是挂载文件系统镜像,可见经过刚才格式化之后的文件系统镜像里面只有lost+found这个文件夹
之后可以将步骤一中生成的_install目录下的所有文件拷贝进来即可,
/et/init.d/rcS文件如下修改
其他的系统配置文件可以根据需要进行更改
三、u-boot加载内核和文件系统
CODE:
=> tftp 800000 uImage; tftp a00000 rootfs.img; bootm 800000 a00000
Using FCC1 ETHERNET device
TFTP from server 192.168.0.102; our IP address is 192.168.0.20
Filename 'uImage'.
Load address: 0x800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################
done
Bytes transferred = 1880231 (1cb0a7 hex)
Using FCC1 ETHERNET device
TFTP from server 192.168.0.102; our IP address is 192.168.0.20
Filename 'rootfs.img'.
Load address: 0xa00000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###################################
done
Bytes transferred = 3170368 (306040 hex)
## Booting image at 00800000 ...
Image Name: Linux-2.6.11
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 1880167 Bytes = 1.8 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
## cmdline at 0x007FFF00 ... 0x007FFF14
memstart = 0x00000000
memsize = 0x08000000
flashstart = 0xFE000000
flashsize = 0x01000000
flashoffset = 0x00033000
sramstart = 0x00000000
sramsize = 0x00000000
immr_base = 0xF0000000
bootflags = 0x00000001
vco = 400 MHz
sccfreq = 100 MHz
brgfreq = 100 MHz
intfreq = 400 MHz
cpmfreq = 200 MHz
busfreq = 100 MHz
ethaddr = 00:08:02:06:10:00
IP addr = 192.168.0.20
baudrate = 115200 bps
## Loading RAMDisk Image at 00a00000 ...
Image Name:
Image Type: PowerPC Linux RAMDisk Image (uncompressed)
Data Size: 3170304 Bytes = 3 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Loading Ramdisk to 07880000, end 07b86000 ... OK
Linux version 2.6.11 (root@Embedded001) (gcc version 3.4.3) #1 Fri Sep 26 11:08:35 CST 2008
Motorola PQ2 ADS PowerPC port
arch/ppc/syslib/m82xx_pci.c: The PCI bus is 33333333 Mhz.
Waiting 1 second after deasserting RST...
Built 1 zonelists
Kernel command line: console=ttyS0,115200
PID hash table entries: 1024 (order: 10, 16384 bytes)
Warning: real time clock seems stuck!
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 122272k available (2660k kernel code, 1524k data, 116k init, 0k highmem)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd
Freeing initrd memory: 3096k freed
NET: Registered protocol family 16
PCI: Probing PCI hardware
dev = 0, pin = 1
slot = 0, dev = 0, pin = 1
dev = a0, pin = 1
slot = 20, dev = a0, pin = 1
dev = b8, pin = 1
slot = 23, dev = b8, pin = 1
dev = b9, pin = 1
slot = 23, dev = b9, pin = 1
PCI: Cannot allocate resource region 0 of device 0000:00:00.0
PCI: Cannot allocate resource region 1 of device 0000:00:00.0
SCSI subsystem initialized
Sangoma WANPIPE Router v1.1 (c) 1995-2000 Sangoma Technologies Inc.
devfs: 2004-01-31 Richard Gooch ([email]rgooch@atnf.csiro.au[/email])
devfs: boot_options: 0x1
Initializing Cryptographic API
Serial: CPM driver $Revision: 0.01 $
ttyS0 at MMIO 0xf0011a80 (irq = 4) is a CPM UART
ttyS1 at MMIO 0xf0011a00 (irq = 40) is a CPM UART
ttyS2 at MMIO 0xf0011a60 (irq = 43) is a CPM UART
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
loop: loaded (max 8 devices)
nbd: registered device at major 43
Intel(R) PRO/1000 Network Driver - version 5.6.10.1-k2
Copyright (c) 1999-2004 Intel Corporation.
e100: Intel(R) PRO/100 Network Driver, 3.3.6-k2-NAPI
e100: Copyright(c) 1999-2004 Intel Corporation
ipddp.c:v0.01 8/28/97 Bradford W. Johnson <[email]johns393@maroon.tc.umn.edu[/email]>
ipddp0: Appletalk-IP Encap. mode by Bradford W. Johnson <[email]johns393@maroon.tc.umn.edu[/email]>
i2c /dev entries driver
eth0: FCC ENET Version 0.3, 00:08:02:86:10:00
eth1: FCC ENET Version 0.3, 00:08:02:46:10:00
NET: Registered protocol family 26
NET: Registered protocol family 2
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
IPv4 over IPv4 tunneling driver
GRE over IPv4 tunneling driver
ip_conntrack version 2.1 (1024 buckets, 8192 max) - 248 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
ipt_recent v0.3.1: Stephen Frost <[email]sfrost@snowman.net[/email]>. [url]http://snowman.net/projects/ipt_recent/[/url]
ClusterIP Version 0.6 loaded successfully
arp_tables: (C) 2002 David S. Miller
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
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.
Initializing IPsec netlink socket
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15
Bridge firewalling registered
Ebtables v2.0 registered
NET: Registered protocol family 4
NET: Registered protocol family 5
NET: Registered protocol family 9
X.25 for Linux. Version 0.2 for Linux 2.1.15
NET: Registered protocol family 8
NET: Registered protocol family 20
lec.c: Sep 26 2008 11:07:03 initialized
mpoa: /proc/mpoa initialized
mpc.c: Sep 26 2008 11:07:01 initialized
NET4: DECnet for Linux: V.2.5.68s (C) 1995-2003 Linux DECnet Project Team
DECnet: Routing cache hash table of 1024 buckets, 8Kbytes
NET: Registered protocol family 12
NET: Registered protocol family 19
802.1Q VLAN Support v1.8 Ben Greear <[email]greearb@candelatech.com[/email]>
All bugs added by David S. Miller <[email]davem@redhat.com[/email]>
SCTP: Hash tables configured (established 4096 bind 8192)
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 3096KiB [1 disk] into ram disk... done.
VFS: Mounted root (ext2 filesystem) readonly.
Mounted devfs on /dev
init started: BusyBox v1.7.2 (2008-09-26 10:46:55 CST)
starting pid 810, tty '': '/etc/init.d/rcS'
mdev: /sys/block: No such file or directory
mdev: /sys/class: No such file or directory
starting pid 813, tty '': '/bin/sh'
Processing /etc/profile... Done
Using FCC1 ETHERNET device
TFTP from server 192.168.0.102; our IP address is 192.168.0.20
Filename 'uImage'.
Load address: 0x800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################
done
Bytes transferred = 1880231 (1cb0a7 hex)
Using FCC1 ETHERNET device
TFTP from server 192.168.0.102; our IP address is 192.168.0.20
Filename 'rootfs.img'.
Load address: 0xa00000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###################################
done
Bytes transferred = 3170368 (306040 hex)
## Booting image at 00800000 ...
Image Name: Linux-2.6.11
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 1880167 Bytes = 1.8 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
## cmdline at 0x007FFF00 ... 0x007FFF14
memstart = 0x00000000
memsize = 0x08000000
flashstart = 0xFE000000
flashsize = 0x01000000
flashoffset = 0x00033000
sramstart = 0x00000000
sramsize = 0x00000000
immr_base = 0xF0000000
bootflags = 0x00000001
vco = 400 MHz
sccfreq = 100 MHz
brgfreq = 100 MHz
intfreq = 400 MHz
cpmfreq = 200 MHz
busfreq = 100 MHz
ethaddr = 00:08:02:06:10:00
IP addr = 192.168.0.20
baudrate = 115200 bps
## Loading RAMDisk Image at 00a00000 ...
Image Name:
Image Type: PowerPC Linux RAMDisk Image (uncompressed)
Data Size: 3170304 Bytes = 3 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Loading Ramdisk to 07880000, end 07b86000 ... OK
Linux version 2.6.11 (root@Embedded001) (gcc version 3.4.3) #1 Fri Sep 26 11:08:35 CST 2008
Motorola PQ2 ADS PowerPC port
arch/ppc/syslib/m82xx_pci.c: The PCI bus is 33333333 Mhz.
Waiting 1 second after deasserting RST...
Built 1 zonelists
Kernel command line: console=ttyS0,115200
PID hash table entries: 1024 (order: 10, 16384 bytes)
Warning: real time clock seems stuck!
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 122272k available (2660k kernel code, 1524k data, 116k init, 0k highmem)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd
Freeing initrd memory: 3096k freed
NET: Registered protocol family 16
PCI: Probing PCI hardware
dev = 0, pin = 1
slot = 0, dev = 0, pin = 1
dev = a0, pin = 1
slot = 20, dev = a0, pin = 1
dev = b8, pin = 1
slot = 23, dev = b8, pin = 1
dev = b9, pin = 1
slot = 23, dev = b9, pin = 1
PCI: Cannot allocate resource region 0 of device 0000:00:00.0
PCI: Cannot allocate resource region 1 of device 0000:00:00.0
SCSI subsystem initialized
Sangoma WANPIPE Router v1.1 (c) 1995-2000 Sangoma Technologies Inc.
devfs: 2004-01-31 Richard Gooch ([email]rgooch@atnf.csiro.au[/email])
devfs: boot_options: 0x1
Initializing Cryptographic API
Serial: CPM driver $Revision: 0.01 $
ttyS0 at MMIO 0xf0011a80 (irq = 4) is a CPM UART
ttyS1 at MMIO 0xf0011a00 (irq = 40) is a CPM UART
ttyS2 at MMIO 0xf0011a60 (irq = 43) is a CPM UART
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
loop: loaded (max 8 devices)
nbd: registered device at major 43
Intel(R) PRO/1000 Network Driver - version 5.6.10.1-k2
Copyright (c) 1999-2004 Intel Corporation.
e100: Intel(R) PRO/100 Network Driver, 3.3.6-k2-NAPI
e100: Copyright(c) 1999-2004 Intel Corporation
ipddp.c:v0.01 8/28/97 Bradford W. Johnson <[email]johns393@maroon.tc.umn.edu[/email]>
ipddp0: Appletalk-IP Encap. mode by Bradford W. Johnson <[email]johns393@maroon.tc.umn.edu[/email]>
i2c /dev entries driver
eth0: FCC ENET Version 0.3, 00:08:02:86:10:00
eth1: FCC ENET Version 0.3, 00:08:02:46:10:00
NET: Registered protocol family 26
NET: Registered protocol family 2
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
IPv4 over IPv4 tunneling driver
GRE over IPv4 tunneling driver
ip_conntrack version 2.1 (1024 buckets, 8192 max) - 248 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
ipt_recent v0.3.1: Stephen Frost <[email]sfrost@snowman.net[/email]>. [url]http://snowman.net/projects/ipt_recent/[/url]
ClusterIP Version 0.6 loaded successfully
arp_tables: (C) 2002 David S. Miller
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
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.
Initializing IPsec netlink socket
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15
Bridge firewalling registered
Ebtables v2.0 registered
NET: Registered protocol family 4
NET: Registered protocol family 5
NET: Registered protocol family 9
X.25 for Linux. Version 0.2 for Linux 2.1.15
NET: Registered protocol family 8
NET: Registered protocol family 20
lec.c: Sep 26 2008 11:07:03 initialized
mpoa: /proc/mpoa initialized
mpc.c: Sep 26 2008 11:07:01 initialized
NET4: DECnet for Linux: V.2.5.68s (C) 1995-2003 Linux DECnet Project Team
DECnet: Routing cache hash table of 1024 buckets, 8Kbytes
NET: Registered protocol family 12
NET: Registered protocol family 19
802.1Q VLAN Support v1.8 Ben Greear <[email]greearb@candelatech.com[/email]>
All bugs added by David S. Miller <[email]davem@redhat.com[/email]>
SCTP: Hash tables configured (established 4096 bind 8192)
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 3096KiB [1 disk] into ram disk... done.
VFS: Mounted root (ext2 filesystem) readonly.
Mounted devfs on /dev
init started: BusyBox v1.7.2 (2008-09-26 10:46:55 CST)
starting pid 810, tty '': '/etc/init.d/rcS'
mdev: /sys/block: No such file or directory
mdev: /sys/class: No such file or directory
starting pid 813, tty '': '/bin/sh'
Processing /etc/profile... Done
更多推荐
已为社区贡献5条内容
所有评论(0)