Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4602741
  • 博文数量: 385
  • 博客积分: 21208
  • 博客等级: 上将
  • 技术积分: 4393
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-30 13:40
文章分类

全部博文(385)

文章存档

2015年(1)

2014年(3)

2012年(16)

2011年(42)

2010年(1)

2009年(2)

2008年(34)

2007年(188)

2006年(110)

分类: LINUX

2007-01-14 17:29:22

   ramdisk 制作:

1: 内核支持:
其中主要修改3项,如下:
①、修改Bootoptions
 Default kernel command string  这一项我设为空,让bootloader(u-boot,vivi)传入。
 
②、选上 Float point emulation ->
[ * ] NWFE math emnulaiton

③、修改Driver device  ->
   Block device ->
(4096)Default RAM disk size (kbytes)
改4096为8192

2:以下是摘自网上的,

制作空的ramdisk:
# dd if=/dev/zero of=ramdisk bs=1k count=8000
    在本地目录下出现一个rmdisk的块文件
# losetup /dev/loop2 ramdisk
# mkfs.ext2 /dev/loop2
挂载ramdisk至/mnt下
# mount -t ext2 /dev/loop2 /mnt
㈢.准备lib库文件
# cd /mnt
# mkdir lib
# cd  /usr/local/arm/3.4.1/arm-linux/lib
# for file in libc libcrypt libdl libm libpthread libresolv libutil
> do
> cp $file-*.so /mnt/lib
> cp -d $file.so.[*0-9] /mnt/lib
> done
# cp -d ld*.so* /mnt/lib


㈣.复制busybox文件至ramdisk中:
# cp –rf  /busybox-1.2.2.1/_install/* /mnt/
这样在ramdisk中就有:sbin linuxrc bin
㈤.
# umount /dev/loop2
# losetup -d /dev/loop2
# gzip -9  ramdisk

这样ramdisk.gz就制作好了。
# cp ramdisk.gz /tftpboot

基本上我也是如法炮制, 不过我是直接拿上次nfs启动的文件系统的内容全部拷贝到这里,
注意拷贝链接文件时要加上参数-d, 同时参阅了hh bbs上的说要   
在ramdisk中建立console和null即可
cd /dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3

同时我的文件名字叫做today.ramfs.gz

试验: 在uboot中设置
setenv bootargs "console=ttySAC0 initrd=0x30800000,0x440000 root=/dev/ram init=/linuxrc"

setenv bootargs "console=ttySAC0 initrd=0x30800000,0x440000 root=/dev/rd/0 init=/linuxrc"
按Document/initrd.txt中说如果采用devfs,则应使用root=/dev/rd/0, 如不采用,则用/dev/ram  ,结果反复试验了一下, 两个效果是一样的。
uboot==>tftp 30008000 zImage;tftp 30800000 today.ramfs.gz;go 30008000

 发现:Uncompressing Linux......................................................................
就不动了, 查看了一下,内核没什么问题, 由昨天做nfs文件系统记起来了linuxrc文件, 一看是一个shell脚本,
就把busybox生成的linuxrc拷贝过来,覆盖掉。

                                                                                        
U-Boot 1.1.4 (Jan 13 2007 - 18:54:16)
                                                                                        
U-Boot code: 33F80000 -> 33F9DA78  BSS: -> 33FA20E8
RAM Configuration:
Bank #0: 30000000 64 MB
Nor Flash: 512 kB
Nand Flash:    64 MB
                                                                                        
In:    serial
Out:   serial
Err:   serial
hujun2410=> tftp 30008000 zImage;tftp 30800000 today.ramfs.gz;go 30008000
TFTP from server 59.69.74.87; our IP address is 59.69.75.186
Filename 'zImage'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
done
Bytes transferred = 1326596 (143e04 hex)
TFTP from server 59.69.74.87; our IP address is 59.69.75.186
Filename 'today.ramfs.gz'.
Load address: 0x30800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################################
done
Bytes transferred = 2839962 (2b559a hex)
## Starting application at 0x30008000 ...
Uncompressing Linux......................................................................Linux version 2.6.14 (root@hujunlinux) (gcc version 3.4.1) #12 Sun Jan 14 13:16:14 EST 27CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
Machine: SMDK2410
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: "console=ttySAC0 initrd=0x30800000,0x2b308e root=/dev/ram init=/lin"irq: clearing pending ext status 00000800
irq: clearing subpending status 00000002
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 59292KB available (2090K code, 462K data, 112K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
softlockup thread 0 started up.
Freeing initrd memory: 2764K
NET: Registered protocol family 16
USB Control, (c) 2006 sbc2410
S3C2410: Initialising architecture
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
NetWinder Floating Point Emulator V0.97 (double precision)
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: devfs_debug: 0x0
devfs: boot_options: 0x1
Initializing Cryptographic API
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
Console: switching to colour frame buffer device 80x25
fb0: Virtual frame buffer device, using 1024K of video memory
S3C2410 RTC, (c) 2004 Simtec Electronics
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
nbd: registered device at major 43
usbcore: registered new driver ub
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
pSMDK2410_ETH_IO=0x11000000,vSMDK2410_ETH_IO=0xe0000000
eth0: CS8900A rev E at 0xe0000300 irq=52, no eeprom , addr: 08: 0:3E:26:0A:5B
NFTL driver: nftlcore.c $Revision: 1.97 $, nftlmount.c $Revision: 1.40 $
usbmon: debugfs is not available
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: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.14 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 driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
RAMDISK: Compressed image found at block 0
RAMDISK: incomplete write (-28 != 32768) 4194304
RAMDISK: ran out of compressed data
invalid compressed format (err=1)
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "" or unknown-block(2,0)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
 
出现上面情况,查阅资料才知道是因为没有修改
Driver device  ->
   Block device ->
(4096)Default RAM disk size (kbytes)
改4096为8192


NET: Registered protocol family 1
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Mounted devfs on /dev
                                                                                                  
Please press Enter to activate this console.
                                                                                                  
                                                                                                  
BusyBox v1.2.1 (2007.01.13-23:04+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
                                                                                                  
[root@hjembed /]# ls
bin      etc      lib      mnt      sbin     usr
dev      hello    linuxrc  proc     tmp      var
[root@hjembed /]# ./hello
hello,world
[root@hjembed /]# ping
ping: : Unknown host
[root@hjembed /]# ifconfig
[root@hjembed /]# mount
devfs on /dev type devfs (rw)
/dev/root.old on / type ext2 (rw,nogrpid)
none on /dev type devfs (rw)
none on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
tmpfs on /dev/shm type tmpfs (rw)


这里不知为何ping 不通, 而


[root@hujunlinux myuboot]# cd /public/today_ramfs/
[root@hujunlinux today_ramfs]# ls
fs/  today.ramfs.gz
[root@hujunlinux today_ramfs]# ls fs/
[root@hujunlinux today_ramfs]# gunzip today.ramfs.gz
[root@hujunlinux today_ramfs]# mount -o loop today.ramfs   fs/
[root@hujunlinux today_ramfs]# cd fs
[root@hujunlinux fs]# ls
bin/  dev/  etc/  hello*  lib/  linuxrc@  mnt/  proc/  sbin/  tmp/  usr/  var/
[root@hujunlinux fs]# ls lib
ld-2.3.2.so*        libm.so@                libpthread.so        libstdc++.so@
ld-linux.so.2@      libm.so.6@              libpthread.so.0@     libstdc++.so.6@
libc-2.3.2.so*      libnss_dns-2.3.2.so*    libpthread.so_orig   libstdc++.so.6.0.1*
libcrypt-2.3.2.so*  libnss_dns.so@          libresolv-2.3.2.so*  libutil-2.3.2.so*
libcrypt.so@        libnss_dns.so.2@        libresolv.so@        libutil.so@
libcrypt.so.1@      libnss_files-2.3.2.so*  libresolv.so.2@      libutil.so.1@
libc.so             libnss_files.so@        librt-2.3.2.so*      yaffs.o*
libc.so.6@          libnss_files.so.2@      librt.so@
libm-2.3.2.so*      libpthread-0.10.so*     librt.so.1@
[root@hujunlinux fs]# ls /public/myroot_nfs/lib/
ld-2.3.2.so*        libm.so@                libpthread.so        libstdc++.so@
ld-linux.so.2@      libm.so.6@              libpthread.so.0@     libstdc++.so.6@
libc-2.3.2.so*      libnss_dns-2.3.2.so*    libpthread.so_orig   libstdc++.so.6.0.1*
libcrypt-2.3.2.so*  libnss_dns.so@          libresolv-2.3.2.so*  libutil-2.3.2.so*
libcrypt.so@        libnss_dns.so.2@        libresolv.so@        libutil.so@
libcrypt.so.1@      libnss_files-2.3.2.so*  libresolv.so.2@      libutil.so.1@
libc.so             libnss_files.so@        librt-2.3.2.so*      yaffs.o*
libc.so.6@          libnss_files.so.2@      librt.so@
libm-2.3.2.so*      libpthread-0.10.so*     librt.so.1@
[root@hujunlinux fs]#

库是一样的,resolve.txt 中也指定了nameserver,为何不解析呢?

试了一下,telnet到板子也是可以的。ftp也可以。
 [root@hjembed /]# wget  ftp://59.69.74.87/hello.txt
Connecting to 59.69.74.87[59.69.74.87]:21
hello.txt            100% |*****************************|    21    --:--:-- ETA
[root@hjembed /]#


IP-Config: Complete:
      device=eth0, addr=59.69.74.199, mask=255.0.0.0, gw=59.69.74.1,
     host=matrix4, domain=, nis-domain=arm9.net,
     bootserver=59.69.74.87, rootserver=59.69.74.87, rootpath=
Looking up port of RPC 100003/2 on 59.69.74.87
Looking up port of RPC 100005/1 on 59.69.74.87
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 112K
                                                                                                  
Please press Enter to activate this console.
                                                                                                  
                                                                                                  
BusyBox v1.2.1 (2007.01.13-23:04+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
                                                                                                  
[root@hjembed /]# ping
PING (211.94.144.100): 56 data bytes
                                                                                                  
--- ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
[root@hjembed /]#



 
阅读(14016) | 评论(13) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-05-16 21:18:42

你好,看了你的这篇文章,对我帮助特别大,我就是按照你的方法一点一点做的,最后也成功了,非常感谢你将自己的成果分享给大家! 但我还有一个问题想请教一下,因为咱们做的zImage和ramdisk.gz都是通过tftp直接传到ram,并在ram中运行的,而ram是掉电后就丢失数据的,所以,每次启动系统后,对系统做的修改,比如添加一些文件等,掉电重启后就没有了,如果想要保存的话应该怎么做呢? 非常感谢!!!!

chinaunix网友2008-05-16 21:18:42

你好,看了你的这篇文章,对我帮助特别大,我就是按照你的方法一点一点做的,最后也成功了,非常感谢你将自己的成果分享给大家! 但我还有一个问题想请教一下,因为咱们做的zImage和ramdisk.gz都是通过tftp直接传到ram,并在ram中运行的,而ram是掉电后就丢失数据的,所以,每次启动系统后,对系统做的修改,比如添加一些文件等,掉电重启后就没有了,如果想要保存的话应该怎么做呢? 非常感谢!!!!

chinaunix网友2008-05-16 21:18:24

你好,看了你的这篇文章,对我帮助特别大,我就是按照你的方法一点一点做的,最后也成功了,非常感谢你将自己的成果分享给大家! 但我还有一个问题想请教一下,因为咱们做的zImage和ramdisk.gz都是通过tftp直接传到ram,并在ram中运行的,而ram是掉电后就丢失数据的,所以,每次启动系统后,对系统做的修改,比如添加一些文件等,掉电重启后就没有了,如果想要保存的话应该怎么做呢? 非常感谢!!!!

chinaunix网友2008-05-16 21:18:24

你好,看了你的这篇文章,对我帮助特别大,我就是按照你的方法一点一点做的,最后也成功了,非常感谢你将自己的成果分享给大家! 但我还有一个问题想请教一下,因为咱们做的zImage和ramdisk.gz都是通过tftp直接传到ram,并在ram中运行的,而ram是掉电后就丢失数据的,所以,每次启动系统后,对系统做的修改,比如添加一些文件等,掉电重启后就没有了,如果想要保存的话应该怎么做呢? 非常感谢!!!!