- tos-deluge now syncs the flash volume after writing the image and updating the image version number.
- Update section 5 for the new reboot/reprogram command.
<p></p>
<div align=center>
Chieh-Jan Mike Liang<br>
-Razvan Musaloiu-E.<p>July 9, 2007</p>
+Razvan Musaloiu-E.<p>July 11, 2007</p>
</div>
<p></p>
<p>
<a href="http://www.cs.berkeley.edu/~jwhui/research/deluge/">http://www.cs.berkeley.edu/~jwhui/research/deluge/</a>.</p>
<p>
Deluge T2 is an effort to port Deluge 2.0 from TinyOS 1 to TinyOS 2.
-Since the code from Deluge 2.0 is reused as much as possible, the
-behavior and the usage of Deluge T2 should be similar to Deluge 2.0.
-Having said that, it would be helpful to read the Deluge 2.0 manual and
-related documentations.</p>
+Although the code from Deluge 2.0 is reused as much as possible, the
+behavior and the usage of Deluge T2 are not entirely identical to Deluge
+2.0. Having said that, it would still be helpful to read the Deluge 2.0
+manual and related documentations.</p>
<p>
Deluge T2 is still in experimental phase. One current limitation is
platform support. Deluge T2 has been developed on Tmote Sky (<i>telosb</i>)
the availability of a new program image. This notification is currently
done via TinyOS dissemination service, and it triggers all motes in the
network to get the new program image. After all motes receive the image
-over-the-air, you can instruct the base station to disseminate a command
-to reprogram the network. For example,
+over-the-air, you can instruct the base station to disseminate the
+command to reprogram in the network. For example,
</p>
<pre class=verbatim> % tos-deluge /dev/ttyUSB0 telosb -r 1
</pre><p></p>
<p></p>
<p>
Different from Deluge 2.0, Deluge T2 toolchain is written in Python.
-However, as demonstrated in the previous section, the usage is very
-similar.</p>
+However, as demonstrated in the previous section, the usage is similar.</p>
<p>
</p>
<a name="node_sec_5.1"></a>
<p>
</p>
<a name="node_sec_5.3"></a>
-<h2>5.3 -r -reboot</h2>
+<h2>5.3 -b -reprogram_bs</h2>
<p>This command sets up the mote to reprogram itself after reboot, and then
-it reboots the mote. This command is applicable only to the directly
-connected mote.</p>
+it reboots the mote. This command is applicable only to the base station
+mote.</p>
<p>
</p>
<a name="node_sec_5.4"></a>
<h2>5.4 -d -dissemination</h2>
-<p>This command instructs the directly connected mote to disseminate an
-image to the network. This image is specified by the volume ID. Upon
-successfully receiving an image, motes in the network automatically
-reprogram themselves.</p>
+<p>This command instructs the base station mote to disseminate an image to
+the network. This image is specified by the volume ID.</p>
<p>
</p>
<a name="node_sec_5.5"></a>
-<h2>5.5 -e -erase</h2>
-<p>This command erases a flash volume on the directly connected mote.</p>
+<h2>5.5 -r -reprogram</h2>
+<p>This command instructs the base station mote to disseminate the
+command to reprogram in the network. This command does not reprogram the
+base station mote. The image is specified by the volume ID.</p>
<p>
</p>
<a name="node_sec_5.6"></a>
-<h2>5.6 -s -reset</h2>
+<h2>5.6 -e -erase</h2>
+<p>This command erases a flash volume on the base station mote.</p>
+<p>
+</p>
+<a name="node_sec_5.7"></a>
+<h2>5.7 -s -reset</h2>
<p>This command resets versioning information of a specific image on the
-directly connected mote.</p>
+base station mote.</p>
<p>
</p>
<p></p>
-<div align=right class=colophon>Last modified: Monday, July 9th, 2007 8:43:40pm<br><div align=right class=advertisement>HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 20050501</a></div></div>
+<div align=right class=colophon>Last modified: Wednesday, July 11th, 2007 2:26:06pm<br><div align=right class=advertisement>HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 20050501</a></div></div>
</div>
</body>
</html>
MSG_REPROG = 5
MSG_DISS = 6
MSG_REPROG_BS = 7
+MSG_SYNC = 8
ERROR_SUCCESS = 0 # T2-compatible
ERROR_FAIL = 1 # T2-compatible
print "ERROR: Unable to send the command"
return False
+def op_sync(s, img_num):
+ sreqpkt = SerialReqPacket((MSG_SYNC, img_num, 0, 0, []))
+ success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
+ if success == True:
+ packet = s.read_packet(SERIAL_AMGROUP, SERIAL_AMID)
+ sreplypkt = SerialReplyPacket(packet[1])
+ if sreplypkt.error == ERROR_SUCCESS:
+ return True
+ else:
+ print "ERROR: Unable to sync the flash volume"
+ return False
+
+ print "ERROR: Unable to send the command"
+ return False
+
# Writes to an image volume
def op_write(s, img_num, binary_stream):
sreqpkt = SerialReqPacket((MSG_WRITE, img_num, 0, 0, []))
# Writes the new binary image
if op_erase(s, img_num):
if op_write(s, img_num, p.stdout.read()):
- print "--------------------------------------------------"
- metadata = getMetaData(s, img_num)
- if not metadata == None:
- if verifyMetaData(metadata) == True:
- print "Replace image with:"
- print toStatusStr(2, metadata)
- print "--------------------------------------------------"
- return True
+ if op_sync(s, img_num):
+ print "--------------------------------------------------"
+ metadata = getMetaData(s, img_num)
+ if not metadata == None:
+ if verifyMetaData(metadata) == True:
+ print "Replace image with:"
+ print toStatusStr(2, metadata)
+ print "--------------------------------------------------"
+ return True
return False
if sreplypkt.error != ERROR_SUCCESS:
print "ERROR: Unable to write new versioning information"
return False
+ else:
+ if op_sync(s, img_num) == False:
+ return False
return True
implementation
{
- //uint8_t img_num;
+ uint32_t recv_uid = 0xffffffff;
+ uint16_t recv_size = 0xffff;
+ uint8_t recv_imgNum = 0xff;
/**
* Starts the radio
{
call RadioSplitControl.start();
}
-
+
#ifdef DELUGE_BASESTATION
/**
* Starts disseminating image information
{
const DelugeDissemination *delugeDis = call DisseminationValue.get();
DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
-
+
switch (delugeDis->msg_type) {
case DISSMSG_DISS:
if (imgDesc->uid == delugeDis->uid && imgDesc->uid != DELUGE_INVALID_UID) {
if (imgDesc->vNum < delugeDis->vNum) {
+ recv_uid = delugeDis->uid;
+ recv_size = delugeDis->size;
+ recv_imgNum = delugeDis->imgNum;
call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
}
} else {
+ recv_uid = delugeDis->uid;
+ recv_size = delugeDis->size;
+ recv_imgNum = delugeDis->imgNum;
call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
}
event void ObjectTransfer.receiveDone(error_t error)
{
- //call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
- call ObjectTransfer.stop();
-// if (error == SUCCESS) {
-// call NetProg.programImgAndReboot(img_num);
-// }
+ call ObjectTransfer.publish(recv_uid, recv_size, recv_imgNum);
}
/**
event void RadioSplitControl.startDone(error_t error)
{
if (error == SUCCESS) {
-// // Start publishing the current image
-// DelugeImgDesc *imgDesc;
-// DelugeNodeDesc nodeDesc;
-// call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
-// &nodeDesc,
-// sizeof(DelugeNodeDesc)); // Reads which image was just reprogrammed
-// imgDesc = call DelugeMetadata.getImgDesc(nodeDesc.imgNum);
-// if (nodeDesc.uid == imgDesc->uid && imgDesc->uid != DELUGE_INVALID_UID) {
-// call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
-// }
-
call StdControlDissemination.start();
}
}
#define SERIALMSG_REPROG 5
#define SERIALMSG_DISS 6
#define SERIALMSG_REPROG_BS 7
+#define SERIALMSG_SYNC 8
typedef nx_struct SerialReqPacket {
nx_uint8_t msg_type;
S_READ,
S_CRC,
S_REPROG,
+ S_SYNC,
};
message_t serialMsg;
event void BlockWrite.syncDone[uint8_t img_num](error_t error)
{
- if (state == S_ERASE) {
+ if (state == S_ERASE || state == S_SYNC) {
state = S_IDLE;
sendReply(error, sizeof(SerialReplyPacket));
}
error = call BlockRead.computeCrc[img_num](srpkt->offset,
srpkt->len, 0);
break;
+ case SERIALMSG_SYNC: // === Sync the flash ===
+ state = S_SYNC;
+ error = call BlockWrite.sync[img_num]();
#ifdef DELUGE
case SERIALMSG_ADDR: // === Gets the physical starting address of a volume ===
*(nx_uint32_t*)(&serialMsg_payload->data) =
resetTimer();
} else {
call DelugePageTransfer.setWorkingPage(DELUGE_INVALID_OBJID, DELUGE_INVALID_PGNUM);
- state = S_SYNC;
call ObjectTransfer.stop();
+ state = S_SYNC;
call BlockWrite.sync[cont_receive_img_num]();
}
}
setNextPage();
} else {
call DelugePageTransfer.setWorkingPage(curObjDesc.objid, curObjDesc.numPgsComplete);
- state = S_SYNC;
call ObjectTransfer.stop();
- call BlockWrite.sync[cont_receive_img_num]();
+ state = S_SYNC;
+ if (call BlockWrite.sync[cont_receive_img_num]() != SUCCESS) {
+ post signalObjRecvDone();
+ }
}
}
}