- Add a new command to reprogram the network (instead of motes automatically reprogram after they receive an image).
- Update the documentation to reflect the new command.
- Add README.txt files for the examples.
--- /dev/null
+README for apps/tests/deluge/Blink\r
+Author/Contact:\r
+\r
+Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>\r
+Razvan Musaloiu-E. <razvanm@cs.jhu.edu>\r
+\r
+Description:\r
+\r
+This is a sample application referenced in the Deluge T2 manual to show \r
+some of the basics in reprogramming.\r
+\r
+The burn script performs the following tasks on the basestation:\r
+ 1) Compile and load the program normally.\r
+ 2) Compile another version of blink that blinks differently.\r
+ 3) Upload the new blink to flash volume 0.\r
+ 4) Instruct the mote to reprogram with the new blink.\r
+\r
+Alternatively, you can reprogram the whole network (non-basestation \r
+motes) by first uploading the image to the base station. Then, tell the \r
+base station to disseminate the image. For example,\r
+\r
+ tos-deluge /dev/ttyUSB0 telosb -d 0\r
+ \r
+Finally, after the image has been disseminated, instruct the base \r
+station to disseminate the command to reprogram. For example,\r
+\r
+ tos-deluge /dev/ttyUSB0 telosb -r 0\r
+\r
+For a more detailed discussion on Deluge T2, please refer to the Deluge \r
+T2 manual.\r
+\r
+Prerequisites:\r
+\r
+Python 2.4 with pySerial\r
+\r
+References:\r
+\r
+The Deluge T2 manual is available under $TOS_DIR/doc/html/.\r
--- /dev/null
+README for apps/tests/deluge/GoldenImage
+Author/Contact:
+
+Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
+
+Description:
+
+This is a sample application for Deluge T2. The application is similar
+to Null, but it includes Deluge T2.
+
+You can reprogram the whole network (non-basestation motes) by first
+uploading the image to the base station. Then, tell the base station to
+disseminate the image. Example:
+
+ tos-deluge /dev/ttyUSB0 telosb -d 0
+
+Finally, after the image has been disseminated, instruct the base
+station to disseminate the command to reprogram. Example:
+
+ tos-deluge /dev/ttyUSB0 telosb -r 0
+
+For a more detailed discussion on Deluge T2, please refer to the Deluge
+T2 manual.
+
+Prerequisites:
+
+Python 2.4 with pySerial
+
+References:
+
+The Deluge T2 manual is available under $TOS_DIR/doc/html/.
--- /dev/null
+README for apps/tests/deluge/SerialBlink
+Author/Contact:
+
+Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
+
+Description:
+
+This is a sample application for Deluge T2. The program blinks and send
+a serial msg every second.
+
+You can reprogram the whole network (non-basestation motes) by first
+uploading the image to the base station. Then, tell the base station to
+disseminate the image. Example:
+
+ tos-deluge /dev/ttyUSB0 telosb -d 0
+
+Finally, after the image has been disseminated, instruct the base
+station to disseminate the command to reprogram. Example:
+
+ tos-deluge /dev/ttyUSB0 telosb -r 0
+
+For a more detailed discussion on Deluge T2, please refer to the Deluge
+T2 manual.
+
+Prerequisites:
+
+Python 2.4 with pySerial
+
+References:
+
+The Deluge T2 manual is available under $TOS_DIR/doc/html/.
.title {
font-size: 200%;
font-weight: normal;
+ margin-top: 2.8em;
+ text-align: center;
}
.partheading {
list-style-type: upper-alpha;
}
- /*
- .verbatim {
- color: #4d0000;
- }
- */
-
tt i {
font-family: serif;
}
font-family: serif;
}
+ /*
+ .verbatim {
+ color: #4d0000;
+ }
+ */
+
.scheme em {
- font-family: serif;
color: black;
+ font-family: serif;
}
.scheme {
.colophon {
color: gray;
font-size: 80%;
+ font-style: italic;
text-align: right;
}
.colophon a {
color: gray;
}
-
\ No newline at end of file
<meta name=robots content="index,follow">
</head>
<body>
+<div id=title>
+<p></p>
<p>
</p>
</p>
-<h1 class=title align=center><br><br>Deluge T2 - Programming Manual</h1>
+<h1 class=title>Deluge T2 - Programming Manual</h1>
<p></p>
<div align=center>
Chieh-Jan Mike Liang<br>
-Razvan Musaloiu-E.<p>June 21, 2007</p>
+Razvan Musaloiu-E.<p>July 9, 2007</p>
</div>
<p></p>
<p>
first test on the base station by issuing the reboot command. For
example,
</p>
-<pre class=verbatim> % tos-deluge /dev/ttyUSB0 telosb -r 1
+<pre class=verbatim> % tos-deluge /dev/ttyUSB0 telosb -b 1
</pre><p>
After a few moments, the mote will begin quickly flashing the LEDs to
signify the reprogramming process.</p>
<pre class=verbatim> % tos-deluge /dev/ttyUSB0 telosb -d 1
</pre><p>
This command instructs the base station to notify the whole network of
-the availablility of a new program image. This notification is currently
+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. Upon receiving the complete image
-over-the-air, each node automatically reboots and reprograms itself.</p>
+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,
+</p>
+<pre class=verbatim> % tos-deluge /dev/ttyUSB0 telosb -r 1
+</pre><p></p>
<p>
</p>
<a name="node_sec_5"></a>
directly connected mote.</p>
<p>
</p>
-<div align=right class=colophon>
-<i>Last modified: Thursday, June 21st, 2007<br>
-HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 2004-09-11</a></i>
+<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>
</body>
</html>
SERIAL_DATA_LENGTH = 28 - 1 - 1 - 2 - 2
# Serial message types
-MSG_ERASE = 0
-MSG_WRITE = 1
-MSG_READ = 2
-MSG_REPROG = 5
-MSG_DISS = 6
+MSG_ERASE = 0
+MSG_WRITE = 1
+MSG_READ = 2
+MSG_REPROG = 5
+MSG_DISS = 6
+MSG_REPROG_BS = 7
ERROR_SUCCESS = 0 # T2-compatible
ERROR_FAIL = 1 # T2-compatible
return False
-# Requests the mote to reboot and reprogram itself
-def op_reprog(s, img_num):
+# Requests the base station to reprogram itself
+def op_reprog_bs(s, img_num):
if getMetaData(s, img_num) == None:
print "ERROR: No proper Deluge image found!"
else:
- sreqpkt = SerialReqPacket((MSG_REPROG, img_num, 0, 0, []))
+ sreqpkt = SerialReqPacket((MSG_REPROG_BS, 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)
if sreplypkt.error == ERROR_SUCCESS:
return True
else:
- print "ERROR: Unable to reboot the mote"
+ print "ERROR: Unable to reprogram the base station"
return False
print "ERROR: Unable to send the command"
return False
+# Requests the network to reprogram with the specified image number
+def op_reprog(s, img_num):
+ sreqpkt = SerialReqPacket((MSG_REPROG, 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 reprogram the network"
+ return False
+
+ print "ERROR: Unable to send the command"
+
# Requests the mote to disseminate an image
def op_diss(s, img_num):
if getMetaData(s, img_num) == None:
print " -p --ping\n Provide status of the image in the external flash"
print " -i --inject\n Inject a compiled TinyOS application"
print " [options]: tos_image.xml file path"
- print " -r --reboot\n Reboot and reprogram the directly-connected mote"
+ print " -r --reprogram\n Reprogram the network"
+ print " -b --reprogram_bs\n Reprogram only the directly-connected mote"
print " -d --dissemination\n Disseminate the image in the external flash to the network"
print " -e --erase\n Erase an image in the external flash"
print " -s --reset\n Reset the versioning information for a given image"
elif sys.argv[3] in ["-i", "--inject"] and len(sys.argv) == (num_req_arg + 1):
print "Pinging node ..."
op_inject(s, sys.argv[4], sys.argv[5])
- elif sys.argv[3] in ["-r", "--reboot"]:
+ elif sys.argv[3] in ["-r", "--reprogram"]:
if op_reprog(s, sys.argv[4]):
print "Command sent"
+ elif sys.argv[3] in ["-b", "--reprogram_bs"]:
+ if op_reprog_bs(s, sys.argv[4]):
+ print "Command sent"
elif sys.argv[3] in ["-d", "--dissemination"]:
if op_diss(s, sys.argv[4]):
print "Command sent"
#include "DelugeMetadata.h"
+#define DISSMSG_DISS 0
+#define DISSMSG_REPROG 1
+
enum {
DELUGE_INVALID_UID = 0xffffffff,
DELUGE_NUM_VOLUMES = 2,
};
typedef nx_struct DelugeDissemination {
+ nx_uint8_t msg_type;
nx_uint32_t uid; // unique id of image
nx_uint16_t vNum; // version num of image
nx_uint8_t imgNum; // image number
components SerialStarterC;
components new FlashVolumeManagerC(0xAB);
- DelugeP.ReprogNotify -> FlashVolumeManagerC;
+ DelugeP.DissNotify -> FlashVolumeManagerC.DissNotify;
+ DelugeP.ReprogNotify -> FlashVolumeManagerC.ReprogNotify;
FlashVolumeManagerC.BlockRead[VOLUME_DELUGE0] -> DelugeStorageC.BlockRead[VOLUME_DELUGE0];
FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE0] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE0];
FlashVolumeManagerC.DelugeStorage[VOLUME_DELUGE0] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE0];
};
typedef nx_struct DelugeAdvMsg {
- nx_uint16_t sourceAddr;
- nx_uint8_t version; // Deluge Version
- nx_uint8_t type;
+ nx_uint16_t sourceAddr;
+ nx_uint8_t version; // Deluge Version
+ nx_uint8_t type;
DelugeObjDesc objDesc;
- nx_uint8_t reserved;
+ nx_uint8_t reserved;
} DelugeAdvMsg;
typedef nx_struct DelugeReqMsg {
- nx_uint16_t dest;
- nx_uint16_t sourceAddr;
- nx_object_id_t objid;
- nx_page_num_t pgNum;
- nx_uint8_t requestedPkts[DELUGE_PKT_BITVEC_SIZE];
+ nx_uint16_t dest;
+ nx_uint16_t sourceAddr;
+ nx_object_id_t objid;
+ nx_page_num_t pgNum;
+ nx_uint8_t requestedPkts[DELUGE_PKT_BITVEC_SIZE];
} DelugeReqMsg;
typedef nx_struct DelugeDataMsg {
nx_object_id_t objid;
- nx_page_num_t pgNum;
- nx_uint8_t pktNum;
- nx_uint8_t data[DELUGE_PKT_PAYLOAD_SIZE];
+ nx_page_num_t pgNum;
+ nx_uint8_t pktNum;
+ nx_uint8_t data[DELUGE_PKT_PAYLOAD_SIZE];
} DelugeDataMsg;
#endif
interface SplitControl as RadioSplitControl;
#ifdef DELUGE_BASESTATION
+ interface Notify<uint8_t> as DissNotify;
interface Notify<uint8_t> as ReprogNotify;
#endif
}
implementation
{
- uint8_t img_num;
+ //uint8_t img_num;
/**
* Starts the radio
/**
* Starts disseminating image information
*/
- event void ReprogNotify.notify(uint8_t new_img_num)
+ event void DissNotify.notify(uint8_t new_img_num)
{
- DelugeDissemination delugeDis;
- DelugeImgDesc *imgDesc;
-
- imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
+ DelugeImgDesc* imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
if (imgDesc->uid != DELUGE_INVALID_UID) {
+ DelugeDissemination delugeDis;
+
call ObjectTransfer.stop();
call Leds.led0Toggle();
- img_num = new_img_num;
delugeDis.uid = imgDesc->uid;
delugeDis.vNum = imgDesc->vNum;
- delugeDis.imgNum = img_num;
+ delugeDis.imgNum = new_img_num;
delugeDis.size = imgDesc->size;
+ delugeDis.msg_type = DISSMSG_DISS;
- call DisseminationUpdate.change(&delugeDis); // Disseminates image information
+ call DisseminationUpdate.change(&delugeDis); // Disseminates command
call ObjectTransfer.publish(delugeDis.uid,
delugeDis.size,
delugeDis.imgNum); // Prepares to publish image data
}
}
+
+ event void ReprogNotify.notify(uint8_t new_img_num)
+ {
+ DelugeDissemination delugeDis;
+
+ call Leds.led2Toggle();
+
+ delugeDis.uid = 0;
+ delugeDis.vNum = 0;
+ delugeDis.imgNum = new_img_num;
+ delugeDis.size = 0;
+ delugeDis.msg_type = DISSMSG_REPROG;
+
+ call DisseminationUpdate.change(&delugeDis); // Disseminates command
+ }
#endif
/**
const DelugeDissemination *delugeDis = call DisseminationValue.get();
DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
- if (imgDesc->uid == delugeDis->uid) {
- if (imgDesc->vNum < delugeDis->vNum) {
- img_num = delugeDis->imgNum; // Note which image number to boot
- call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
- }
- } else {
- img_num = delugeDis->imgNum; // Note which image number to boot
- call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
+ switch (delugeDis->msg_type) {
+ case DISSMSG_DISS:
+ if (imgDesc->uid == delugeDis->uid && imgDesc->uid != DELUGE_INVALID_UID) {
+ if (imgDesc->vNum < delugeDis->vNum) {
+ call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
+ }
+ } else {
+ call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
+ }
+
+ break;
+ case DISSMSG_REPROG:
+ if (imgDesc->uid != DELUGE_INVALID_UID) {
+ DelugeNodeDesc nodeDesc;
+ call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
+ &nodeDesc,
+ sizeof(DelugeNodeDesc)); // Reads which image was just reprogrammed
+ if (nodeDesc.uid != imgDesc->uid || nodeDesc.vNum != imgDesc->vNum) {
+ call NetProg.programImgAndReboot(delugeDis->imgNum);
+ }
+ }
+
+ break;
}
}
-
- /**
- * Reboots and reprograms with the newly received image
- */
+
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);
- }
+// if (error == SUCCESS) {
+// call NetProg.programImgAndReboot(img_num);
+// }
}
/**
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);
- }
+// // 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();
}
#ifndef FLASHVOLUMEMANAGER_H
#define FLASHVOLUMEMANAGER_H
-#define SERIALMSG_ERASE 0
-#define SERIALMSG_WRITE 1
-#define SERIALMSG_READ 2
-#define SERIALMSG_CRC 3
-#define SERIALMSG_ADDR 4
-#define SERIALMSG_REPROG 5
-#define SERIALMSG_DISS 6
+#define SERIALMSG_ERASE 0
+#define SERIALMSG_WRITE 1
+#define SERIALMSG_READ 2
+#define SERIALMSG_CRC 3
+#define SERIALMSG_ADDR 4
+#define SERIALMSG_REPROG 5
+#define SERIALMSG_DISS 6
+#define SERIALMSG_REPROG_BS 7
typedef nx_struct SerialReqPacket {
nx_uint8_t msg_type;
generic configuration FlashVolumeManagerC(am_id_t AMId)
{
#ifdef DELUGE
- provides interface Notify<uint8_t>;
+ provides interface Notify<uint8_t> as DissNotify;
+ provides interface Notify<uint8_t> as ReprogNotify;
#endif
uses {
interface BlockRead[uint8_t img_num];
FlashVolumeManagerP.Timer -> TimerMilliC;
FlashVolumeManagerP.DelugeStorage[VOLUME_DELUGE0] = DelugeStorage[VOLUME_DELUGE0];
FlashVolumeManagerP.DelugeStorage[VOLUME_DELUGE1] = DelugeStorage[VOLUME_DELUGE1];
- Notify = FlashVolumeManagerP.Notify;
+ DissNotify = FlashVolumeManagerP.DissNotify;
+ ReprogNotify = FlashVolumeManagerP.ReprogNotify;
#endif
}
generic module FlashVolumeManagerP()
{
#ifdef DELUGE
- provides interface Notify<uint8_t>;
+ provides {
+ interface Notify<uint8_t> as DissNotify;
+ interface Notify<uint8_t> as ReprogNotify;
+ }
#endif
uses {
interface BlockRead[uint8_t img_num];
(uint32_t)call DelugeStorage.getPhysicalAddress[img_num](0);
sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
break;
- case SERIALMSG_REPROG: // === Reboots and reprograms ===
+ case SERIALMSG_REPROG_BS: // === Reprograms only the base station ===
state = S_REPROG;
sendReply(SUCCESS, sizeof(SerialReplyPacket));
img_num_reboot = img_num;
call Timer.startOneShot(1024);
break;
case SERIALMSG_DISS: // === Starts disseminating a volume ===
- signal Notify.notify(img_num); // Notifies Deluge to start disseminate
+ signal DissNotify.notify(img_num); // Notifies Deluge to start disseminate
+ sendReply(SUCCESS, sizeof(SerialReplyPacket));
+ break;
+ case SERIALMSG_REPROG: // === Reprograms the network (except the base station) ===
+ signal ReprogNotify.notify(img_num);
sendReply(SUCCESS, sizeof(SerialReplyPacket));
break;
#endif
call NetProg.programImgAndReboot(img_num_reboot);
}
- command error_t Notify.enable() { return SUCCESS; }
- command error_t Notify.disable() { return SUCCESS; }
+ command error_t DissNotify.enable() { return SUCCESS; }
+ command error_t DissNotify.disable() { return SUCCESS; }
+ command error_t ReprogNotify.enable() { return SUCCESS; }
+ command error_t ReprogNotify.disable() { return SUCCESS; }
default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
#endif
} else {
call DelugePageTransfer.setWorkingPage(DELUGE_INVALID_OBJID, DELUGE_INVALID_PGNUM);
state = S_SYNC;
+ call ObjectTransfer.stop();
call BlockWrite.sync[cont_receive_img_num]();
}
}
error_t error;
call ObjectTransfer.stop();
- state = S_STOPPED;
//call StatsCollector.startStatsCollector();
cont_receive_new_objid = new_objid;
{
call Timer.stop();
call DelugePageTransfer.stop();
+ state = S_STOPPED;
//call StatsCollector.stopStatsCollector();
- state = S_STOPPED;
curObjDesc.objid = DELUGE_INVALID_OBJID;
curObjDesc.numPgs = DELUGE_INVALID_PGNUM;
curObjDesc.numPgsComplete = DELUGE_INVALID_PGNUM;
+ advTimers.periodLog2 = 0;
return SUCCESS;
}
} else {
call DelugePageTransfer.setWorkingPage(curObjDesc.objid, curObjDesc.numPgsComplete);
state = S_SYNC;
+ call ObjectTransfer.stop();
call BlockWrite.sync[cont_receive_img_num]();
}
}
event void BlockWrite.syncDone[uint8_t img_num](error_t error)
{
if (state == S_SYNC) {
- if (error != SUCCESS) {
- call Leds.led2On();
- }
post signalObjRecvDone();
}
}
}
event void Timer.fired()
- {
+ {
updateTimers();
if (advTimers.overheard == 0) {
imgDesc = call DelugeMetadata.getImgDesc(img_num);
nodeDesc.uid = imgDesc->uid;
nodeDesc.imgNum = img_num;
+ nodeDesc.vNum = imgDesc->vNum;
call IFlash.write((uint8_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
// reboot