]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
This commit from Chieh-Jan (Mike) Liang contains the following:
authorrazvanm <razvanm>
Wed, 11 Jul 2007 18:53:38 +0000 (18:53 +0000)
committerrazvanm <razvanm>
Wed, 11 Jul 2007 18:53:38 +0000 (18:53 +0000)
- 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.

doc/html/deluge-t2-manual.html
doc/pdf/deluge-t2-manual.pdf
tools/tinyos/misc/tos-deluge
tos/lib/net/Deluge/DelugeP.nc
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc
tos/lib/net/Deluge/ObjectTransferP.nc

index 3dd87e3f7224797f52ed44837174f6a2f34e9f9f..6bc5bc7506682a75203049b2f3944ceb30827f7a 100644 (file)
@@ -25,7 +25,7 @@ Deluge T2 - Programming Manual
 <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>
@@ -42,10 +42,10 @@ Hui, and Deluge 2.0 is the most recent version. Documentations on Deluge
 <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>) 
@@ -230,8 +230,8 @@ This command instructs the base station to notify the whole network of
 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>
@@ -242,8 +242,7 @@ to reprogram the network. For example,
 <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>
@@ -262,33 +261,38 @@ no state is stored on the PC.</p>
 <p>
 </p>
 <a name="node_sec_5.3"></a>
-<h2>5.3&nbsp;&nbsp;-r -reboot</h2>
+<h2>5.3&nbsp;&nbsp;-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&nbsp;&nbsp;-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&nbsp;&nbsp;-e -erase</h2>
-<p>This command erases a flash volume on the directly connected mote.</p>
+<h2>5.5&nbsp;&nbsp;-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&nbsp;&nbsp;-s -reset</h2>
+<h2>5.6&nbsp;&nbsp;-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&nbsp;&nbsp;-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>
index 98025dd39fd42b80389aee3f60d8ffe01859eb4d..f51e79b73b113b397e6f96680a15eb30db3f649a 100644 (file)
Binary files a/doc/pdf/deluge-t2-manual.pdf and b/doc/pdf/deluge-t2-manual.pdf differ
index ae1bb1aa31d35e944682426b925adf0f3d0eb0aa..aedea410150606b18c53b3918897ffab750d4859 100755 (executable)
@@ -53,6 +53,7 @@ MSG_READ      = 2
 MSG_REPROG    = 5
 MSG_DISS      = 6
 MSG_REPROG_BS = 7
+MSG_SYNC      = 8
 
 ERROR_SUCCESS = 0   # T2-compatible
 ERROR_FAIL    = 1   # T2-compatible
@@ -243,6 +244,21 @@ def op_erase(s, img_num):
     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, []))
@@ -331,14 +347,15 @@ def op_inject(s, img_num, tos_image_xml):
     # 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
 
@@ -408,6 +425,9 @@ def op_reset(s, img_num):
     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
 
index d7312f12a9d31a5bf7fe039f62f5d06ae70f6286..01aad620ffc468b6a721478cb4b3d81a5730f707 100644 (file)
@@ -47,7 +47,9 @@ module DelugeP
 
 implementation
 {
-  //uint8_t img_num;
+  uint32_t recv_uid = 0xffffffff;
+  uint16_t recv_size = 0xffff;
+  uint8_t recv_imgNum = 0xff;
   
   /**
    * Starts the radio
@@ -56,7 +58,7 @@ implementation
   {
     call RadioSplitControl.start();
   }
-
+  
 #ifdef DELUGE_BASESTATION
   /**
    * Starts disseminating image information
@@ -104,14 +106,20 @@ implementation
   {
     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);
         }
         
@@ -133,11 +141,7 @@ implementation
   
   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);
   }
 
   /**
@@ -146,17 +150,6 @@ implementation
   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();
     }
   }
index 9ca55a4508bb7897c02fcec49c0aebd0df895d95..35c1a188830a6a8ffbfa4a4428942a422437c7bf 100644 (file)
@@ -35,6 +35,7 @@
 #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;
index 216c00d2f9685dfd93ac91b57d4ca6d3e117f12c..2021f2e0a6ca549b01b1fa6e4b7d796b183677b3 100644 (file)
@@ -58,6 +58,7 @@ implementation
     S_READ,
     S_CRC,
     S_REPROG,
+    S_SYNC,
   };
   
   message_t serialMsg;
@@ -130,7 +131,7 @@ implementation
   
   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));
     }
@@ -180,6 +181,9 @@ implementation
           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) =
index 777a6cfab0d225a102051821b45d8abeb4f4b40d..ab92c554a6952aa9eeaf22f2bf6fba32da215ae0 100644 (file)
@@ -111,8 +111,8 @@ implementation
       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]();
     }
   }
@@ -248,9 +248,11 @@ implementation
         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();
+        }
       }
     }
   }