]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Workaround the erase problems with AT45DB
authorrazvanm <razvanm>
Sat, 16 Jan 2010 10:02:29 +0000 (10:02 +0000)
committerrazvanm <razvanm>
Sat, 16 Jan 2010 10:02:29 +0000 (10:02 +0000)
The previous commit did not take in consideration that STM45P
requires the erase operation. The new strategy is to make the
FlashVolumeManager refuse the erase for AT45DB, and make the
tos-deluge attempt to overwrite of the metadata only when the
erase fails.

tools/tinyos/misc/tos-deluge
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc

index 1277ba5df2be3172653c6264c5577421cb2dee4a..7a215a0e474cd82ced693d022feef1351ea33016 100755 (executable)
@@ -186,12 +186,15 @@ def read(imgNum, offset, length):
 
 def erase(imgNum):
     # Note: the normal erase doesn't work properly on AT45DB. A
-    # workaroud is to overwrite the metadata of the Deluge image.
-    #
-    #sreqpkt = FMReqPacket((FM_CMD_ERASE, imgNum, 0, 0, []))
-    #success = am.write(sreqpkt, FM_AMID)
-    #return handleResponse(success, "ERROR: Unable to erase the flash volume")
+    # workaround is to do the normal erase (to make happy STM45P)
+    # and then overwrite the metadata (to make happy AT45DB).
 
+    sreqpkt = FMReqPacket((FM_CMD_ERASE, imgNum, 0, 0, []))
+    success = am.write(sreqpkt, FM_AMID)
+    result = handleResponse(success, "ERROR: Unable to erase the flash volume")
+    if result: return True;
+
+    print 'Attempt the workaround for AT45DB...'
     sreqpkt = FMReqPacket((FM_CMD_WRITE, imgNum, 0, 0, []))
     sreqpkt.data = [0xFF] * DELUGE_IDENT_SIZE
     sreqpkt.length = DELUGE_IDENT_SIZE
index e758e77a750356d8a7691d939a7f2d292dc87289..b91f194bee9f4ded4544df14a5b030819dd0ba19 100644 (file)
@@ -200,7 +200,11 @@ implementation
        switch (request->cmd) {
         case CMD_ERASE:    // === Erases a volume ===
           state = S_ERASE;
+#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC)
+          error = FAIL;
+#else
           error = call BlockWrite.erase[imgNum]();
+#endif
           break;
         case CMD_WRITE:    // === Writes to a volume ===
           state = S_WRITE;