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.
def erase(imgNum):
# Note: the normal erase doesn't work properly on AT45DB. A
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
sreqpkt = FMReqPacket((FM_CMD_WRITE, imgNum, 0, 0, []))
sreqpkt.data = [0xFF] * DELUGE_IDENT_SIZE
sreqpkt.length = DELUGE_IDENT_SIZE
switch (request->cmd) {
case CMD_ERASE: // === Erases a volume ===
state = S_ERASE;
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]();
error = call BlockWrite.erase[imgNum]();
break;
case CMD_WRITE: // === Writes to a volume ===
state = S_WRITE;
break;
case CMD_WRITE: // === Writes to a volume ===
state = S_WRITE;