This is the mail archive of the ecos-patches@sources.redhat.com 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: [ECOS] Re: Flash device interface


On Freitag, 7. November 2003 17:02, Roland Caßebohm wrote:
> >
> > [ ... ]
> >
> > I don't think this is a way to go if you want to have byte access to
> > your flash.
> > You have a read/modify/erase/write cycle if your data is not block
> > alligned for every write -
> > a lot of work if you want to change just a byte of two, not to mention
> > the limited amount of
> > times you can do that with one flash chip.
> >
> > Using my block library should give you much better results.
> > It caches the blocks for you and writes only when block gets thrown out
> > of cache or you
> > request it. Beside that you have byte access and block access functions
> > and the cache size and
> > block size are configurable. You can write a simple filesystem on top of
> > that wich suits your needs,
> > and this is really simple if all what you need is file like access to
> > your flash region.
>
> This sounds very good, but I'm afraid I have no time anymore for this.
> Maybe in the future I will go on.
>
> But one thing still interests me, does anybody ever used the flash device
> interface (flashiodev.c) with real flash? I think it just can't work,
> because in the write function the flash would not be erased before
> programming.
>
> Thanks for your suggestion,
> Roland

Well I have noticed, that jffs2 uses the flashiodev.c interface and it works
because it erases the flash explicitly using CYG_IO_GET_CONFIG_FLASH_ERASE.

So, I have made my test changes to flashiodev.c back. The only thing I have
left is using flash_read() for reading FLASH instead of memcpy. Maybe this
is usefull for somebody, I attached the patch.

Roland
Index: io/flash/current/src/flashiodev.c
===================================================================
RCS file: /home/cassebohm/net/USERS/CVSROOT/VSprojects/ecos/packages/io/flash/current/src/flashiodev.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.2
diff -u -5 -p -r1.1.1.1 -r1.1.1.1.2.2
--- io/flash/current/src/flashiodev.c	29 Sep 2003 15:15:55 -0000	1.1.1.1
+++ io/flash/current/src/flashiodev.c	21 Nov 2003 14:52:33 -0000	1.1.1.1.2.2
@@ -119,26 +119,32 @@ flashiodev_lookup( struct cyg_devtab_ent
 
 static Cyg_ErrNo
 flashiodev_bread( cyg_io_handle_t handle, void *buf, cyg_uint32 *len,
                   cyg_uint32 pos)
 {
-	struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle;
-	struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv;
+    struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle;
+    struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv;
 
-	char *startpos = dev->start + pos;
+    Cyg_ErrNo err = ENOERR;
+    void *erraddr;
+    char *startpos = dev->start + pos;
 
 #ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
     char *endpos = startpos + *len - 1;
     char *flashend = MIN( (char *)flash_info.end, dev->end);
     if ( startpos < dev->start )
         return -EINVAL;
     if ( endpos > flashend )
         return -EINVAL;
 #endif
 
-    memcpy( buf, startpos, *len );
-    return ENOERR;
+    err = flash_read( startpos, 
+                     (void *)buf, *len, &erraddr );
+
+    if ( err )
+        err = -EIO; // just something sane
+    return err;
 } // flashiodev_bread()
 
 static Cyg_ErrNo
 flashiodev_bwrite( cyg_io_handle_t handle, const void *buf, cyg_uint32 *len,
                    cyg_uint32 pos )

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