IO FLASH and caches

Edgar Grimberg edgar.grimberg@zylin.com
Fri Oct 16 07:41:00 GMT 2009


Hi,

The attached patch handles the case where the CPU cannot disable
caches and needs to provide an uncached address instead. The fix was
tested with a NIOS2 CPU.

Regards,
Edgar

-- 
Edgar Grimberg
System Developer
Zylin AS
ZY1000 JTAG Debugger http://www.zylin.com/zy1000.html
Phone: (+47) 51 63 25 00
-------------- next part --------------
Index: current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/ChangeLog,v
retrieving revision 1.53
diff -u -r1.53 ChangeLog
--- current/ChangeLog	1 Jul 2009 18:52:09 -0000	1.53
+++ current/ChangeLog	16 Oct 2009 07:36:48 -0000
@@ -1,3 +1,8 @@
+2009-10-16  Edgar Grimberg <edgar.grimberg@zylin.com>
+
+	* src/flash.c: Handles the case where the CPU cannot disable caches and needs 
+	to provide an uncached address instead
+
 2009-03-02  Sergei Gavrikov  <sergei.gavrikov@gmail.com>
 
 	* doc/flash.sgml: Fixed typos in a FLASH API listing.
Index: current/src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flash.c,v
retrieving revision 1.32
diff -u -r1.32 flash.c
--- current/src/flash.c	20 Feb 2009 22:06:15 -0000	1.32
+++ current/src/flash.c	16 Oct 2009 07:36:48 -0000
@@ -106,6 +106,12 @@
 #define CHECK_SOFT_WRITE_PROTECT(_addr_, _len_) CYG_EMPTY_STATEMENT
 #endif
 
+#ifdef CYGARC_UNCACHED_ADDRESS
+#	define UNCACHED_ADDRESS(_x_) CYGARC_UNCACHED_ADDRESS(_x_)
+#else
+#	define UNCACHED_ADDRESS(_x_) _x_
+#endif
+
 // Has the FLASH IO library been initialised?
 static bool init;
 
@@ -622,10 +628,14 @@
     stat = dev->funs->flash_program(dev, addr, ram, this_write);
 #ifdef CYGSEM_IO_FLASH_VERIFY_PROGRAM
     if (CYG_FLASH_ERR_OK == stat) // Claims to be OK
-      if (!dev->funs->flash_read && memcmp((void *)addr, ram, this_write) != 0) {                
+    {
+	 cyg_flashaddr_t unchached_addr;
+	 unchached_addr = UNCACHED_ADDRESS(addr);
+      if (!dev->funs->flash_read && memcmp((volatile void *)unchached_addr, ram, this_write) != 0) {
         stat = CYG_FLASH_ERR_DRV_VERIFY;
         CHATTER(dev, "V");
       }
+    }
 #endif
     if (CYG_FLASH_ERR_OK != stat) {
         if (err_address)


More information about the Ecos-patches mailing list