Chinaunix首页 | 论坛 | 博客
  • 博客访问: 355853
  • 博文数量: 120
  • 博客积分: 4010
  • 博客等级: 上校
  • 技术积分: 1810
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-11 17:50
文章分类

全部博文(120)

文章存档

2008年(120)

我的朋友

分类:

2008-04-22 21:28:01

原文地址

ramdisk_ks.gz

Nicolas Pitre
Mon, 5 Feb 2001 17:05:31 -0500 (EST)

  • Previous message:
  • Next message:
  • Messages sorted by:

On Mon, 5 Feb 2001, Emmons, Christopher D wrote:

> I am confused over the entire ramdisk concept for embedded systems.  I think
> several on this list wouldn't mind an explanation on why a large ramdisk
> (>8192k, I assume) is "insane."
> Example Scenario:  I want to put a music player and a few large song files
> on my assabet.  These files take up 10 megs alone without any sort of
> filesystem, etc.  Now, being a novice, I see two options: (1) create a large
> ramdisk of say, 16 megs {the option I thought was a good idea} or (2) create
> several ramdisks, one with the kernel and basic OS, and another 1 or 2 for
> the files {I have no idea how I would do this if it is even practical}.

First, a ramdisk uses ram.  If you have 8MB ramdisk, you loose 8MB of
precious memory.  If you have 16MB ramdisk, the half of your memory is
locked down by your filesystem.  This is utterly wasteful, especially since
that same data is also available in flash memory already where you're
probably copying this whole chunk of data from anyway.  If one's goal was
rather to really upload such a ramdisk over the serial port then my
suggestion would be for any such person to invest his time into gardening
instead.

A ramdisk is pretty handy for testing and/or temporary/limited tasks, like
having a minimum environment to easily upload more serious stuff into the
flash by using a network link, or to mount the real filesystem via NFS, etc.
But it is quite a bad idea to run embedded systems out of a ramdisk,
especially when you have the same data in flash already!

Instead, you should use the MTD drivers to access flash data directly.  If
your Assabet has only 4MB of flash, then replace them with bigger parts
(they are socketed so that's easy to do).  Look at
drivers/mtd/sa1100-flash.c to see how you can partition your flash so to
leave your boot firmware in a partition of its own.  Then you may use any
kind of filesystem in your flash partitions, even cramfs if compression is
required.  The MTD layer has a block interface driver that can present flash
partitions just as if they were hard disk partitions.  Get familiar with
this, make it work for you, and see how much free ram you then have!  The
kernel is quite smart at moving what it really needs into ram, uncompressing
it on the fly if needed, and dropping unused content from ram when ram is
required by some other applications.  This is simply not possible with a
ramdisk.

When you've reached that point, then you may consider another structural
level, the best I found so far, which consist of using two flash partitions:
the first one being a single flash sector long to hold your bootloader, and
the second one spaning onto the entire remaining flash using JFFS
(Journaling Flash File System).  For partitions that contained compressed
filesystems before, you just need to use the loopback block interface to
access them while holding their images into the JFFS partition.  Even the
kernel zImage can be stored into that partition and be booted by the
bootloader from there (John Dorsey made a patch for Compaq's bootldr to do
just that).  This is how you will get the most efficient and secure usage of
your flash memory.  If you still need more filesystem space then consider
bigger flash or networked filesystems.

Also note that for volatile storage purpose like /tmp you should consider
using ramfs since the flash has a limited number of write cycles.

Now PLEASE let's stop those jumbo ramdisk discussion since this is really
not the way to do things, OK?


Nicolas
HHARM2410标配有16M的FLASH和64M的SDRAM,所以可以支持很多的大应用。目前提供支持的有minigui和microwin,且均已经很好的支持并集成了触摸屏功能。

需要修改内核的一个配置
cd kernel
make menuconfig
Block devices --->
< > Normal PC floppy disk support
< > XT hard disk support
<*> Loopback device support
< > Network block device support
<*> RAM disk support
(8192) Default RAM disk size
[*] Initial RAM disk (initrd) support
上面原来的值4096,改为8192即可支持大到8M的RAMDISK。

如何使用ramdisk?

就是要把ramdisk.image.gz解压后mount -o loop 到一个目录上,这样就可以看到ramdisk里面的文件系统内容,这时再把你的新编译的busybox的可执行文件复制到这个目录的bin目录下面覆盖原来的,再umount这个目录,再gzip压缩,这样你所作的改动就被带到这个新生成的ramdisk.image.gz文件里面了,然后你烧写这个文件就可以看到新世界了。
简单命令序列:注意要自己调整目录路径
gunzip ramdisk.image.gz
mkdir tmnt
mount -o loop ramdisk.image tmnt
cp -f busybox tmnt/bin
umount tmnt
gzip ramdisk.image
关于RAMDISK的大小问题,有两个概念,一个是ramdisk在内存中解压后的容量,例如我们常说的8M、4M、6M的RAMDISK,它耗用的是板子SDRAM的空间;还有一个就是压缩后的ramdisk.image.gz文件的大小,它耗用的是板子的FLASH的空间。例如8M的RAMDISK,根据里面空间的占用率,里面填的文件、目录内容越多,压缩出来的ramdisk.image.gz的文件就越大,例如会达到3MB以上,但HHARM2410对压缩后文件大于3MB的ramdisk支持不是很好,所以建议不要将我们标配的8MB 的ramdisk里面加的内容太多,导致ramdisk.image.gz过大,一般的,可将一些大的应用程序移到其它的文件系统里面去,例如cramfs等,RAMDISK里面空余的空间可留给系统启动后用于保存一些采集的数据以及计算的一些临时文件等。

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