This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: blib_get_block() uses blocks instead of bytes? flashiodev_bread() uses bytes instead of blocks?


On Fri, Nov 25, 2005 at 03:20:58PM -0800, Garth Zeglin wrote:
> Dear ecos-discuss,
> 
> In summary: 
>   It appears that blib_get_block() is calling
> cyg_io_bread()
>   with a length argument of 1, intending to read one
> block; however
>   cyg_io_bread expects a length parameter in bytes.
> 
>   It appears that flashiodev_bread() is treating the
> 'pos' parameter
>   in units of bytes, but that it is supplied in units
> of blocks.
> 
> Am I correct that this is a bug?  I'm asking here
> first in case there
> is something obvious I am missing. 

There is something none-obvious you are missing :-(

It is a bug, but a different bug to what you have found.

You are the first to try to put a fatfs on top of flash. Hence you
found the bug. Normally fatfs is put on top of a disk. The disk
bread/bwrite functions do work in blocks. The length is the number of
blocks and the pos is in units of blocks.

The flash block driver however is using bytes!

As you said, it is not well documented and the documentation you
pointed at also is not consistent with the disk implementation. It
says len is in bytes, but disk_bread() uses len in blocks.

In my opinion, the pos should be in blocks. If it was in bytes we are
going to have problems with big disks, since pos is only 32bits
long. len could be either, but it is easier to fix the documentation
than change the code and do lots of tests.

This however does not solve your problem. First off, i hope you
realise your fatfs can only be read only! 

The flash bwrite function does not erase the page before writting, so
writes are going to fail if the flash contains something. Also, fatfs
assumes blocks are 512 bytes in size. If you flash device has bigger
than 512 byte pages, doing a page erase is going to corrupt your
filesystem. In order to make a fatfs writable on flash you will need
to insert another layer. This would have to handle the erases and
differences between block sizes and page sizes. blib actually already
allows this. If you call cyg_blib_create() instead of
cyg_blib_io_create() you can specify the read and write functions.

The eCos maintainers need to have a discussion about what a block read
and write should do and if we want to modify the flash code to
implement it.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]