[Tinyos-commits] CVS: tinyos-1.x/tos/platform/pc eeprom.c,1.3,1.4

Jonathan Hui jwhui at users.sourceforge.net
Sun Jul 10 22:47:25 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/platform/pc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32375

Modified Files:
	eeprom.c 
Log Message:
- Initialize newly created eeprom files with all 1's to better match
the true initial conditions of most flash chips used on motes.



Index: eeprom.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/platform/pc/eeprom.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** eeprom.c	27 Apr 2004 23:24:09 -0000	1.3
--- eeprom.c	11 Jul 2005 05:47:22 -0000	1.4
***************
*** 59,63 ****
    int rval;
    char val = 0;
!   
    local_filename = file;
    numMotes = motes;
--- 59,68 ----
    int rval;
    char val = 0;
! 
!   uint8_t buf[1024];
!   uint32_t addr;
! 
!   memset(buf, 0xff, 1024);
! 
    local_filename = file;
    numMotes = motes;
***************
*** 74,78 ****
      return -1;
    }
! 
    rval = (int)lseek(local_fd, (moteSize * numMotes), SEEK_SET);
    if (rval < 0) {
--- 79,83 ----
      return -1;
    }
! /*
    rval = (int)lseek(local_fd, (moteSize * numMotes), SEEK_SET);
    if (rval < 0) {
***************
*** 84,87 ****
--- 89,119 ----
      dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n");
    }
+ */
+ 
+   rval = (int)lseek(local_fd, (moteSize * numMotes), SEEK_SET);
+   if (rval < 0) {
+     dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n");
+   }
+ 
+   rval = read(local_fd, &val, 1);
+   if (rval < 0) {
+     dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n");
+   }
+ 
+   if ( !val ) {
+ 
+     rval = (int)lseek(local_fd, 0, SEEK_SET);
+     if (rval < 0) {
+       dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n");
+     }    
+ 
+     for ( addr = 0; addr <= moteSize * numMotes; addr += 1024 ) {
+       rval = write(local_fd, buf, 1024);
+       if (rval < 0) {
+ 	dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n");
+       }
+     }
+   }
+ 
    initialized = 1;
    



More information about the Tinyos-commits mailing list