From: razvanm Date: Wed, 11 Jul 2007 18:53:38 +0000 (+0000) Subject: This commit from Chieh-Jan (Mike) Liang contains the following: X-Git-Tag: release_tools_1_2_4_1~37 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=da393f0d6e7bca649d8d0ce0894cb1ad10ba4212 This commit from Chieh-Jan (Mike) Liang contains the following: - 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. --- diff --git a/doc/html/deluge-t2-manual.html b/doc/html/deluge-t2-manual.html index 3dd87e3f..6bc5bc75 100644 --- a/doc/html/deluge-t2-manual.html +++ b/doc/html/deluge-t2-manual.html @@ -25,7 +25,7 @@ Deluge T2 - Programming Manual

Chieh-Jan Mike Liang
-Razvan Musaloiu-E.

July 9, 2007

+Razvan Musaloiu-E.

July 11, 2007

@@ -42,10 +42,10 @@ Hui, and Deluge 2.0 is the most recent version. Documentations on Deluge http://www.cs.berkeley.edu/~jwhui/research/deluge/.

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.

+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.

Deluge T2 is still in experimental phase. One current limitation is platform support. Deluge T2 has been developed on Tmote Sky (telosb) @@ -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,

   % tos-deluge /dev/ttyUSB0 telosb -r 1
 

@@ -242,8 +242,7 @@ to reprogram the network. For example,

Different from Deluge 2.0, Deluge T2 toolchain is written in Python. -However, as demonstrated in the previous section, the usage is very -similar.

+However, as demonstrated in the previous section, the usage is similar.

@@ -262,33 +261,38 @@ no state is stored on the PC.

-

5.3  -r -reboot

+

5.3  -b -reprogram_bs

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.

+it reboots the mote. This command is applicable only to the base station +mote.

5.4  -d -dissemination

-

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.

+

This command instructs the base station mote to disseminate an image to +the network. This image is specified by the volume ID.

-

5.5  -e -erase

-

This command erases a flash volume on the directly connected mote.

+

5.5  -r -reprogram

+

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.

-

5.6  -s -reset

+

5.6  -e -erase

+

This command erases a flash volume on the base station mote.

+

+

+ +

5.7  -s -reset

This command resets versioning information of a specific image on the -directly connected mote.

+base station mote.

-
Last modified: Monday, July 9th, 2007 8:43:40pm
+
Last modified: Wednesday, July 11th, 2007 2:26:06pm
diff --git a/doc/pdf/deluge-t2-manual.pdf b/doc/pdf/deluge-t2-manual.pdf index 98025dd3..f51e79b7 100644 Binary files a/doc/pdf/deluge-t2-manual.pdf and b/doc/pdf/deluge-t2-manual.pdf differ diff --git a/tools/tinyos/misc/tos-deluge b/tools/tinyos/misc/tos-deluge index ae1bb1aa..aedea410 100755 --- a/tools/tinyos/misc/tos-deluge +++ b/tools/tinyos/misc/tos-deluge @@ -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 diff --git a/tos/lib/net/Deluge/DelugeP.nc b/tos/lib/net/Deluge/DelugeP.nc index d7312f12..01aad620 100644 --- a/tos/lib/net/Deluge/DelugeP.nc +++ b/tos/lib/net/Deluge/DelugeP.nc @@ -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(); } } diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h index 9ca55a45..35c1a188 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h @@ -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; diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc index 216c00d2..2021f2e0 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc @@ -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) = diff --git a/tos/lib/net/Deluge/ObjectTransferP.nc b/tos/lib/net/Deluge/ObjectTransferP.nc index 777a6cfa..ab92c554 100644 --- a/tos/lib/net/Deluge/ObjectTransferP.nc +++ b/tos/lib/net/Deluge/ObjectTransferP.nc @@ -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(); + } } } }