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] IO_Flash & DataFlash


Andrew Lunn wrote:

On Tue, Aug 31, 2004 at 12:06:20PM +0200, Savin Zlobec wrote:


Hi,

I'am writing a DataFlash driver and I would like to use it also through the io_flash API,
but it seems that the io_flash only supports 2^n block sizes (judging by the calculation
and usage of block_mask). DataFlash memory array is divided into 3 levels - sectors,
blocks and pages of wich none has 2^n size.


Supporting this in io_flash is probably just a matter of some ifdefs in read/program/erase
functions - is this correct ? But does anything else (RedBoot, jffs2, ...) also depend on
2^n block sizes ?



Hi Savin


I just committed these patches which means the the flash_v2 code
should not support arbitary size blocks. Please let me know if this
works for the DataFlash, i've only been able to test with a synthetic
flash driver.


Running some tests I've come across a problem with block alignment when flash
start address in not a multiple of its block size, the attached patch solves that by
calculating the block offset from relative position (to the flash start) not the absolute.
Included are also a couple of typo fixes.


savin

Index: devs/flash/atmel/at49xxxx/current/cdl/flash_atmel_at49xxxx.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/flash/atmel/at49xxxx/current/cdl/flash_atmel_at49xxxx.cdl,v
retrieving revision 1.3.2.1
diff -u -5 -r1.3.2.1 flash_atmel_at49xxxx.cdl
--- devs/flash/atmel/at49xxxx/current/cdl/flash_atmel_at49xxxx.cdl	5 Aug 2004 13:38:20 -0000	1.3.2.1
+++ devs/flash/atmel/at49xxxx/current/cdl/flash_atmel_at49xxxx.cdl	29 Sep 2004 14:05:13 -0000
@@ -55,11 +55,11 @@
     active_if	  CYGPKG_IO_FLASH
 
     active_if     CYGINT_DEVS_FLASH_ATMEL_AT49XXXX_REQUIRED
 
     implements    CYGHWR_IO_FLASH_DEVICE
-    implements    CYGHDR_IO_FLASH_DEVICE_LEGACY
+    implements    CYGHWR_IO_FLASH_DEVICE_LEGACY
     
     include_dir   cyg/io
     
     cdl_option    CYGHWR_DEVS_FLASH_ATMEL_AT49XXXX_ERASE_BUG_WORKAROUND {
         display       "AT91FR40162 erase bug workaround"
Index: io/flash/current/src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flash.c,v
retrieving revision 1.26.2.5
diff -u -5 -r1.26.2.5 flash.c
--- io/flash/current/src/flash.c	14 Sep 2004 16:04:54 -0000	1.26.2.5
+++ io/flash/current/src/flash.c	29 Sep 2004 14:05:26 -0000
@@ -512,11 +512,11 @@
     size = length;
     // Only one block at once
     if (size > block_size) size = block_size;
     
     // Writing from the middle of a block?
-    offset = (size_t)addr % block_size;
+    offset = (size_t)(addr - dev->start) % block_size;
     if (offset)
       size = MIN(block_size - offset, size);
     stat = dev->funs->flash_program(dev, addr, ram, size);
     stat = dev->funs->flash_hwr_map_error(dev,stat);
 #ifdef CYGSEM_IO_FLASH_VERIFY_PROGRAM
@@ -600,11 +600,11 @@
     size = length;
     // Only one block at once
     if (size > block_size) size = block_size;
     
     // Reading from the middle of a block?
-    offset = (size_t)addr % block_size;
+    offset = (size_t)(addr - dev->start) % block_size;
     if (offset)
       size = MIN(block_size - offset, size);
     if (dev->funs->flash_read) {
       stat = dev->funs->flash_read(dev, addr, ram, size);
       stat = dev->funs->flash_hwr_map_error(dev,stat);
Index: io/flash/current/src/legacy_dev.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/Attic/legacy_dev.c,v
retrieving revision 1.1.2.2
diff -u -5 -r1.1.2.2 legacy_dev.c
--- io/flash/current/src/legacy_dev.c	14 Sep 2004 16:04:54 -0000	1.1.2.2
+++ io/flash/current/src/legacy_dev.c	29 Sep 2004 14:05:26 -0000
@@ -179,18 +179,18 @@
 legacy_flash_read (struct cyg_flash_dev *dev, 
                    const cyg_flashaddr_t base, 
                    void* data, const size_t len)
 {
 #ifdef CYGSEM_IO_FLASH_READ_INDIRECT
-  typedef int code_fun(void *, void *, int, unsigned long, int);
+  typedef int code_fun(const cyg_flashaddr_t, void *, int, unsigned long, int);
   code_fun *_flash_read_buf;
   size_t block_size = dev->block_info[0].block_size;
   size_t block_mask = ~(block_mask -1);
 
   _flash_read_buf = (code_fun*) __anonymizer(&flash_read_buf);
   
-  return = (*_flash_read_buf)(base, data, len, block_mask, buffer_size);
+  return (*_flash_read_buf)(base, data, len, block_mask, block_size);
 #else
   memcpy(data,(void *)base, len);
   return CYG_FLASH_ERR_OK;
 #endif
 }

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