X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tools%2Ftinyos%2Fmisc%2Ftos-deluge;h=78b0f6625d78ad2a80602f595fc29c382c4bcad2;hb=7195b80d9bdc58ede68198716c5a619c6486278e;hp=9ec58283e567b4eb881f462fd37870558679048a;hpb=34d26870bda4aaaf1306b27f535b39ff3fc011f2;p=tinyos-2.x.git diff --git a/tools/tinyos/misc/tos-deluge b/tools/tinyos/misc/tos-deluge index 9ec58283..78b0f662 100755 --- a/tools/tinyos/misc/tos-deluge +++ b/tools/tinyos/misc/tos-deluge @@ -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,23 @@ def read(imgNum, offset, length): return r def erase(imgNum): + # Note: the normal erase doesn't work properly on AT45DB. A + # workaround is to do the normal erase (to make happy STM25P) + # and then overwrite the metadata (to make happy AT45DB). + sreqpkt = FMReqPacket((FM_CMD_ERASE, imgNum, 0, 0, [])) 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 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 + success = am.write(sreqpkt, FM_AMID) + 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, []))