[ECOS] io/flash problem/question

Mark Salter msalter@redhat.com
Tue Dec 17 14:43:00 GMT 2002


I'm porting RedBoot to a board which does not allow byte access
to flash. This caused a bus error in flash_erase.c where it checks
for an already erased block using byte sized accesses. I made the
following quick hack in my sandbox, but was wondering if this is
okay to check in. Ideally, we should have a flash access interface
and not access it directly with pointers. Also, don't some flash
use 0x00 for an erased value?

--Mark


Index: io/flash/current/src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flash.c,v
retrieving revision 1.20
diff -u -p -5 -r1.20 flash.c
--- io/flash/current/src/flash.c	23 May 2002 23:06:16 -0000	1.20
+++ io/flash/current/src/flash.c	17 Dec 2002 22:34:03 -0000
@@ -215,17 +215,16 @@ flash_erase(void *addr, int len, void **
     HAL_FLASH_CACHES_OFF(d_cache, i_cache);
     FLASH_Enable(block, end_addr);
     while (block < end_addr) {
         // Supply the blocksize for a gross check for erase success
         int i;
-        unsigned char *dp;
         bool erased = true;
-        unsigned short *tmp_block;
+        unsigned short *tmp_block, *dp;
 
-        dp = (unsigned char *)block;
-        for (i = 0;  i < flash_info.block_size;  i++) {
-            if (*dp++ != (unsigned char)0xFF) {
+        dp = block;
+        for (i = 0;  i < flash_info.block_size;  i += sizeof(*dp)) {
+            if (*dp++ != 0xFFFF) {
                 erased = false;
                 break;
             }
         }
         if (!erased) {

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



More information about the Ecos-discuss mailing list