[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclinux-dev
Subject:    RE: [uClinux-dev] uCLinux and memory mapping large files.
From:       "Gavin Lambert" <gavinl () compacsort ! com>
Date:       2007-04-30 0:56:03
Message-ID: 004f01c78ac2$56151820$0502a8c0 () gavinlpc
[Download RAW message or body]

Quoth Nick Vaughan [n.vaughan@codestuff.net]:
> I was wondering whether anyone out there would be able to
> provide me with some information about memory mapping in
> uCLinux. I have done a fair bit of searching for information
> and so far i understand that there is some support for mmap()
> in the uCLinux kernel however i have so far been unable to get it to
> work. 

Most of the information is in linux-2.6.x/Documentation/nommu-mmap.txt.
There are a few articles discussing things as well, but some changes
were made to how it works mid-to-late last year (or thereabouts), and
most of the articles predate that :)

> I am currently trying to port this application to an embedded
> platform which currently runs uCLinux. The hardware in
> question is the KB9202B from KwikByte and consists of an Arm
> core with 64MB SDRAM. It also has a SD/MMC card reader which
> is where i would like to store the data file. The application
> only needs read access to the data.
>
> I have read (http://www.linuxjournal.com/article/7221) that
> memory mapping is possible if the filesystem from which the
> mapped file comes from is ROMFS and the mapping is readonly.
> If this is the case, would it be feasible to store my data
> file on an SD card using ROMFS and memory map this into the address
> space? 

No.  SD cards are block devices and their data is not held in RAM
constantly (nor are they memory-bus-accessible themselves), which means
that a virtual layer would be required to cache or fetch the data
whenever it needs to be accessed, and without an MMU that option is not
available.

Essentially the difference between the two systems is that with an MMU a
driver can intercept all reads and writes to a given memory mapping --
without an MMU a driver will only be called to set up the mapping, and
all reads/writes happen outside the driver's control.

If you only need it in one application, then you should just allocate a
sufficiently large buffer and read the entire file into RAM (or modify
the app to use regular file I/O instead of memory mapping).  If you need
it in multiple applications (or if you want to keep the modifications to
the original app minimal), then you should first copy the file from the
SD card into a tmpfs or ramdisk directory (which will put it into RAM)
and then map it from there.

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic