[ELDK] mmap: first byte always wrong

Stefano Babic sbabic at denx.de
Fri Nov 26 09:03:34 CET 2010

On 11/26/2010 08:28 AM, Alberto Caballero wrote:
> Hi,


> At my project, I will have a data configuration file stored in the board
> Flash memory using an U-Boot filesystem image. At the initialization stage,
> I read the image from the Flash and store it in the Linux filesystem.
> Of course at the U-Boot prompt I am able to check that image header at Flash
> is correctly stored and all the bytes has the right values. I was wondering
> if this has something to do with first access to mapped memory.

You can try to read the flash at the required address twice and check if
the first byte is always wrong. However, with mmap() you are bypassing
the whole linux flash driver that it is responsible to provide the same
interface independently from the underlying hardware.

And again, I suppose you have NOR flash on board, because reading NAND
flash with mmap simply does not work...

> When Linux initializes it creates a series of MTD partitions by its own.

I do not think so. Linux creates partitions as you asked to do. Check
your DTS file (I assume you are using a recent kernel) and modify the
partition's size according to your requirement.

> Now
> the data in the Flash will be overlapped in two partitions so I will try to
> use just one of them.

Then it seems you have to adapt the configuration of the partitions.

> Regarding the mmap usage, I was able to check with another board with
> another PowerPC processor using ELDK also, and in this case there is no
> issue with Flash access.

This does not depend on ELDK. Reading directly the flash chip can work
on some hardware, but it could be unreliable with some other chips. For
example, you do not know which was the last operation issued on the
chip. If the flash driver has sent a CFI-Query, what you read is the
internal mapping of the chip. Using the MTD subsystem you are sure that
the flash driver will take care of all internal details.

Best regards,
Stefano Babic

DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de

More information about the eldk mailing list