]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tools/tinyos/misc/tos-deluge
Replace the erase with a write in tos-deluge to avoid the erase inconsistencies on...
[tinyos-2.x.git] / tools / tinyos / misc / tos-deluge
index 9ec58283e567b4eb881f462fd37870558679048a..1277ba5df2be3172653c6264c5577421cb2dee4a 100755 (executable)
@@ -70,7 +70,7 @@ class FMReqPacket(tos.Packet):
         tos.Packet.__init__(self,
                             [('cmd',    'int',  1),
                              ('imgNum', 'int',  1),
-                             ('offset', 'int',  2),
+                             ('offset', 'int',  4),
                              ('length', 'int',  2),
                              ('data',   'blob', None)],
                             packet)
@@ -185,9 +185,20 @@ def read(imgNum, offset, length):
     return r
 
 def erase(imgNum):
-    sreqpkt = FMReqPacket((FM_CMD_ERASE, imgNum, 0, 0, []))
+    # 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")
+
+    sreqpkt = FMReqPacket((FM_CMD_WRITE, imgNum, 0, 0, []))
+    sreqpkt.data = [0xFF] * DELUGE_IDENT_SIZE
+    sreqpkt.length = DELUGE_IDENT_SIZE
     success = am.write(sreqpkt, FM_AMID)
-    return handleResponse(success, "ERROR: Unable to erase the flash volume")
+    result = handleResponse(success, "ERROR: Unable to erase the flash volume")
+    if not result: return False;
+    return sync(imgNum)
 
 def sync(imgNum):
     sreqpkt = FMReqPacket((FM_CMD_SYNC, imgNum, 0, 0, []))