]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Add support for MicaZ to Deluge T2.
authorrazvanm <razvanm>
Sat, 2 Jun 2007 00:09:14 +0000 (00:09 +0000)
committerrazvanm <razvanm>
Sat, 2 Jun 2007 00:09:14 +0000 (00:09 +0000)
24 files changed:
apps/tests/deluge/Blink/BlinkAppC.nc
apps/tests/deluge/Blink/burn
apps/tests/deluge/Blink/volumes-at45db.xml [new file with mode: 0644]
apps/tests/deluge/GoldenImage/volumes-at45db.xml [new file with mode: 0644]
apps/tests/deluge/SerialBlink/volumes-at45db.xml [new file with mode: 0644]
doc/html/deluge-t2-manual.html
doc/pdf/deluge-t2-manual.pdf
tools/tinyos/misc/Makefile.am
tools/tinyos/misc/tinyos.py
tools/tinyos/misc/tos-deluge
tos/lib/TOSBoot/TOSBootM.nc
tos/lib/net/Deluge/DelugeC.nc
tos/lib/net/Deluge/DelugePageTransfer.h
tos/lib/net/Deluge/DelugeStorage.nc [new file with mode: 0644]
tos/lib/net/Deluge/DelugeStorageC.nc
tos/lib/net/Deluge/DelugeStorageP.nc
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerC.nc
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc
tos/lib/net/Deluge/extra/NetProgC.nc
tos/lib/net/Deluge/extra/NetProgM.nc
tos/lib/net/Deluge/extra/avr/InternalFlashC.nc [new file with mode: 0644]
tos/lib/net/Deluge/extra/mica2/NetProg_platform.h [new file with mode: 0644]
tos/lib/net/Deluge/extra/micaz/InternalFlash.h [new file with mode: 0644]
tos/lib/net/Deluge/extra/micaz/TOSBoot_platform.h [new file with mode: 0644]

index dae60f6a047f87a0f6950a9512685dc2ebdf1eda..4cdad48b2f0b41b3de98df0941dc493d75066e5a 100644 (file)
@@ -42,7 +42,10 @@ configuration BlinkAppC
 }
 implementation
 {
-  components MainC, BlinkC, LedsC, DelugeC;
+  components MainC, BlinkC, LedsC;
+#ifdef DELUGE
+  components DelugeC;
+#endif
   components new TimerMilliC() as Timer0;
 
   BlinkC -> MainC.Boot;
index 8bb82a3091aec06136ceaac8bfa29bc07b26ec7e..1418e38229ece16570862c88e1008bb1b01f1f84 100755 (executable)
@@ -1,21 +1,36 @@
 #!/bin/bash
 
-if [ $# -ne 1 ]; then
-  echo "Usage: $0 /dev/ttyUSB0"
+if [ $# -ne 2 ]; then
+  echo "Usage: $0 <port> <platform>"
+  echo "<port>       For example, /dev/ttyUSB0"
+  echo "<platform>   \"micaz\", \"telosb\""
+  exit 2
+fi
+
+if [ $2 != 'micaz' -a $2 != 'telosb' ]; then
+  echo "\"$2\" is not a supported platform"
   exit 2
 fi
 
 PORT=$1
+PLATFORM=$2
+
 make clean
 
 echo ==================== Compile and load Blink ====================
-make telosb install bsl,$PORT
+if [ $PLATFORM == 'micaz' ]
+then
+  CFLAGS=-DDELUGE_BASESTATION make $PLATFORM install mib510,$PORT
+elif [ $PLATFORM == 'telosb' ]
+then
+  CFLAGS=-DDELUGE_BASESTATION make $PLATFORM install bsl,$PORT
+fi
 
 echo ==================== Compile a new Blink ====================
-CFLAGS=-DBLINK_REVERSE make telosb 
+CFLAGS=-DBLINK_REVERSE\ -DDELUGE_BASESTATION make $PLATFORM 
 
 echo ==================== Upload the image ====================
-../../../../tools/tinyos/misc/tos-deluge $PORT -i 0 build/telosb/tos_image.xml
+../../../../tools/tinyos/misc/tos-deluge $PORT $PLATFORM -i 0 build/$PLATFORM/tos_image.xml
 
 echo ==================== Reboot ====================
-../../../../tools/tinyos/misc/tos-deluge $PORT -r 0 
+../../../../tools/tinyos/misc/tos-deluge $PORT $PLATFORM -r 0 
diff --git a/apps/tests/deluge/Blink/volumes-at45db.xml b/apps/tests/deluge/Blink/volumes-at45db.xml
new file mode 100644 (file)
index 0000000..afc864a
--- /dev/null
@@ -0,0 +1,4 @@
+<volume_table>
+  <volume name="DELUGE0" size="65536"/>
+  <volume name="DELUGE1" size="65536"/>
+</volume_table>
\ No newline at end of file
diff --git a/apps/tests/deluge/GoldenImage/volumes-at45db.xml b/apps/tests/deluge/GoldenImage/volumes-at45db.xml
new file mode 100644 (file)
index 0000000..afc864a
--- /dev/null
@@ -0,0 +1,4 @@
+<volume_table>
+  <volume name="DELUGE0" size="65536"/>
+  <volume name="DELUGE1" size="65536"/>
+</volume_table>
\ No newline at end of file
diff --git a/apps/tests/deluge/SerialBlink/volumes-at45db.xml b/apps/tests/deluge/SerialBlink/volumes-at45db.xml
new file mode 100644 (file)
index 0000000..afc864a
--- /dev/null
@@ -0,0 +1,4 @@
+<volume_table>
+  <volume name="DELUGE0" size="65536"/>
+  <volume name="DELUGE1" size="65536"/>
+</volume_table>
\ No newline at end of file
index 94b0de528558e26dfc41fcda192491d185884f27..e865db12251a151b15e000fddcc4e19263664099 100644 (file)
@@ -22,7 +22,7 @@ Deluge T2 - Programming Manual
 <p></p>
 <div align=center>
 Chieh-Jan Mike Liang<br>
-Razvan Musaloiu-E.<p>May 25, 2007</p>
+Razvan Musaloiu-E.<p>June 1, 2007</p>
 </div>
 <p></p>
 <p>
@@ -45,14 +45,37 @@ Having said that, it would 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 and tested on Tmote Sky 
-(<i>telosb</i>) only. In addition, Deluge T2 comes with 2 flash volumes by 
+platform support. Deluge T2 has been developed on Tmote Sky (<i>telosb</i>) 
+and MicaZ only. In addition, Deluge T2 comes with 2 flash volumes by 
 default. However, more volumes can be added, if necessary. There are 
-also minor details that will be improved in future releases.</p>
+also some minor details that will be improved in future releases.</p>
 <p>
 </p>
 <a name="node_sec_2"></a>
-<h1>2&nbsp;&nbsp;Quick Start</h1>
+<h1>2&nbsp;&nbsp;Tools Installation</h1>
+<p>Deluge T2 requires a few Python scripts that not yet included in the
+official <code class=verbatim>tinyos-tools</code> RPM package. On the CVS, the scripts are
+located in <code class=verbatim>tinyos-2.x/tools/tinyos/misc</code>. The steps to install
+them are the following:</p>
+<p>
+</p>
+<pre class=verbatim>  % cd $TOSROOT
+  % ./Bootstrap
+      ...
+  % ./configure
+      ...
+  % cd tinyos/misc
+  % make ; make install
+      ...
+</pre><p></p>
+<p>
+By default, the files will be installed in <code class=verbatim>/usr/local/bin</code>. If
+desired, the <code class=verbatim>--prefix</code> parameter from <code class=verbatim>configure</code> can be
+used to indicate a different path. </p>
+<p>
+</p>
+<a name="node_sec_3"></a>
+<h1>3&nbsp;&nbsp;Quick Start</h1>
 <p></p>
 <p>
 This section introduces the basics of reprogramming with an example. In 
@@ -68,7 +91,7 @@ For example,
 Then, we run the <code class=verbatim>burn</code> script provided in <code class=verbatim>tinyos-2.x/apps/tests/deluge/Blink</code>.
 For example,
 </p>
-<pre class=verbatim>   % ./burn /dev/ttyUSB0
+<pre class=verbatim>   % ./burn /dev/ttyUSB0 telosb
 </pre><p>
 This <code class=verbatim>burn</code> script programs the directly-connected mote with one 
 version of Blink. Then, it injects and reprograms the mote with another 
@@ -76,7 +99,7 @@ version of Blink. At this point, you can try to retrieve program image
 versioning information. The script to interface with the mote is 
 provided in <code class=verbatim>tinyos-2.x/tools/tinyos/misc</code>. For example,
 </p>
-<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 -p 0
+<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -p 0
 </pre><p>
 You should see something similar to the output below.
 </p>
@@ -99,11 +122,11 @@ You should see something similar to the output below.
 </pre><p></p>
 <p>
 The usage of <code class=verbatim>tos-deluge</code> is available by running the script without 
-any arguments, and it will be discussed in section <a href="#node_sec_4">4</a>.</p>
+any arguments, and it will be discussed in section <a href="#node_sec_5">5</a>.</p>
 <p>
 </p>
-<a name="node_sec_3"></a>
-<h1>3&nbsp;&nbsp;Reprogramming a Network</h1>
+<a name="node_sec_4"></a>
+<h1>4&nbsp;&nbsp;Reprogramming a Network</h1>
 <p></p>
 <p>
 This section illustrates the procedure to reprogram a network. 
@@ -111,8 +134,8 @@ Specifically, we will see how program images are injected and how
 versioning information is retrieved.</p>
 <p>
 </p>
-<a name="node_sec_3.1"></a>
-<h2>3.1&nbsp;&nbsp;Setting Up the Motes</h2>
+<a name="node_sec_4.1"></a>
+<h2>4.1&nbsp;&nbsp;Setting Up the Motes</h2>
 <p>We first install both TOSBoot and a program that runs Deluge T2. For 
 simplicity, we use the golden image as the program. The golden image is 
 provided in <code class=verbatim>tinyos-2.x/apps/tests/deluge/GoldenImage</code>, and it does 
@@ -126,14 +149,14 @@ act as a base station, which requires an additional component to accept
 user commands from the serial port. Normally, only one mote in the 
 network needs to be the base station, and other motes are reprogrammed 
 over-the-air. If error occurs when running the command above, you might 
-need to compile TOSBoot as shown in section <a href="#node_sec_2">2</a>. 
+need to compile TOSBoot as shown in section <a href="#node_sec_3">3</a>. 
 Deluge T2 makes sure the mote ID remain persistent over image 
 reprogramming. You can test the installation by interacting with the 
 mote through <code class=verbatim>tos-deluge</code>.</p>
 <p>
 </p>
-<a name="node_sec_3.2"></a>
-<h2>3.2&nbsp;&nbsp;Preparing Your Application</h2>
+<a name="node_sec_4.2"></a>
+<h2>4.2&nbsp;&nbsp;Preparing Your Application</h2>
 <p>In most cases, the only two files you need to modify are the top-level
 wiring file and the Makefile. You need to make sure <code class=verbatim>DelugeC</code>
 component is included. In addition, the Makefile should have the
@@ -148,12 +171,12 @@ example,
 </pre><p></p>
 <p>
 </p>
-<a name="node_sec_3.3"></a>
-<h2>3.3&nbsp;&nbsp;Injecting Your Application</h2>
+<a name="node_sec_4.3"></a>
+<h2>4.3&nbsp;&nbsp;Injecting Your Application</h2>
 <p>Before a program image is disseminated in the network, we need to first 
 inject it to the base station. For example,
 </p>
-<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 -i 1 apps/Blink/build/telosb/tos_image.xml
+<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -i 1 apps/Blink/build/telosb/tos_image.xml
 </pre><p>
 You should see something similar to the output below.</p>
 <p>
@@ -184,13 +207,13 @@ You should see something similar to the output below.</p>
 </pre><p></p>
 <p>
 </p>
-<a name="node_sec_3.4"></a>
-<h2>3.4&nbsp;&nbsp;Reprogramming with New Image</h2>
+<a name="node_sec_4.4"></a>
+<h2>4.4&nbsp;&nbsp;Reprogramming with New Image</h2>
 <p>After you decide which program image you want to reprogram, you can 
 first test on the base station by issuing the reboot command. For 
 example,
 </p>
-<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 -r 1
+<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -r 1
 </pre><p>
 After a few moments, the mote will begin quickly flashing the LEDs to 
 signify the reprogramming process.</p>
@@ -198,7 +221,7 @@ signify the reprogramming process.</p>
 Now, you can have the base station disseminate a program image to the rest of 
 the network. For example,
 </p>
-<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 -d 1
+<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 
@@ -207,8 +230,8 @@ network to get the new program image. Upon receiving the complete image
 over-the-air, each node automatically reboots and reprograms itself.</p>
 <p>
 </p>
-<a name="node_sec_4"></a>
-<h1>4&nbsp;&nbsp;Deluge T2 Python Toolchain</h1>
+<a name="node_sec_5"></a>
+<h1>5&nbsp;&nbsp;Deluge T2 Python Toolchain</h1>
 <p></p>
 <p>
 Different from Deluge 2.0, Deluge T2 toolchain is written in Python. 
@@ -216,49 +239,49 @@ However, as demonstrated in the previous section, the usage is very
 similar.</p>
 <p>
 </p>
-<a name="node_sec_4.1"></a>
-<h2>4.1&nbsp;&nbsp;-p -ping</h2>
+<a name="node_sec_5.1"></a>
+<h2>5.1&nbsp;&nbsp;-p -ping</h2>
 <p>This command is useful for checking the status of program images on a 
 mote. It provides information such as program name, compile time, size 
 of the image, and so on.</p>
 <p>
 </p>
-<a name="node_sec_4.2"></a>
-<h2>4.2&nbsp;&nbsp;-i -inject</h2>
+<a name="node_sec_5.2"></a>
+<h2>5.2&nbsp;&nbsp;-i -inject</h2>
 <p>This command creates a program image from the supplied 
 <code class=verbatim>tos_image.xml</code> file, and it injects the image into specified 
 volume on the mote. All versioning information is kept on the mote, so 
 no state is stored on the PC.</p>
 <p>
 </p>
-<a name="node_sec_4.3"></a>
-<h2>4.3&nbsp;&nbsp;-r -reboot</h2>
+<a name="node_sec_5.3"></a>
+<h2>5.3&nbsp;&nbsp;-r -reboot</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>
 <p>
 </p>
-<a name="node_sec_4.4"></a>
-<h2>4.4&nbsp;&nbsp;-d -dissemination</h2>
+<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>
 </p>
-<a name="node_sec_4.5"></a>
-<h2>4.5&nbsp;&nbsp;-e -erase</h2>
+<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>
 <p>
 </p>
-<a name="node_sec_4.6"></a>
-<h2>4.6&nbsp;&nbsp;-s -reset</h2>
+<a name="node_sec_5.6"></a>
+<h2>5.6&nbsp;&nbsp;-s -reset</h2>
 <p>This command resets versioning information of a specific image on the 
 directly connected mote.</p>
 <p>
 </p>
 <div align=right class=colophon>
-<i>Last modified: Friday, May 25th, 2007<br>
+<i>Last modified: Friday, June 1st, 2007<br>
 HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 2004-09-11</a></i>
 </div>
 </body>
index e50622d95a6364a04e9f34756e5657dfffc81280..0305fa58f834a4f95eb4bc8a1fcb259f2a6b4e03 100644 (file)
Binary files a/doc/pdf/deluge-t2-manual.pdf and b/doc/pdf/deluge-t2-manual.pdf differ
index 264b53dcdc56a7a4669f9a9967afe5adb4b30988..61303b5b05b6c0d314ea6d6109d8c57f99ac461f 100644 (file)
@@ -24,7 +24,11 @@ bin_SCRIPTS = tos-ident-flags \
              tos-write-image \
              tos-check-env \
              tos-storage-stm25p \
-             tos-storage-at45db
-             
+             tos-storage-at45db \
+             tos-build-deluge-image \
+             tos-deluge
 
 bin_PROGRAMS = tos-serial-debug
+
+pythondir = $(bindir)
+python_DATA = tinyos.py
index 22c9c94e0edba6e6b4c78bcd5cacf65816fc7af5..b2b25478f1530e16f5ed8035d548f03cce0a9081 100644 (file)
@@ -23,6 +23,10 @@ import struct, time, serial, socket
 # @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
 # @author Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
 
+###############################################################################
+# TinyOS 2 Python Serial Module
+###############################################################################
+
 class Serial:
     HDLC_FLAG_BYTE = 0x7e
     HDLC_CTLESC_BYTE = 0x7d
@@ -36,12 +40,28 @@ class Serial:
     SERIAL_PROTO_PACKET_ACK = 68
     SERIAL_PROTO_PACKET_NOACK = 69
     SERIAL_PROTO_PACKET_UNKNOWN = 255
-  
-    __s = None       # An instance of serial.Serial object
+    
+    __s = None        # An instance of serial.Serial object
     __debug = False   # Debug mode
     
+    __baud_rate = {}
+    
     def __init__(self, port, baudrate):
-       self.__s = serial.Serial(port, baudrate, rtscts=0, timeout=0.5)
+        __baud_rate = {'telos': 115200, 'telosb': 115200, 
+                       'tmote': 115200, 'micaz': 57600, 
+                       'mica2': 57600, 'mica2dot': 19200, 
+                       'eyes': 115200, 'intelmote2': 115200}
+        
+        # Converts baud rate from platform name to value, if necessary
+        try:
+            int(baudrate)
+        except:
+            baudrate = __baud_rate.get(baudrate)
+        
+        if not baudrate == None:
+            self.__s = serial.Serial(port, baudrate, rtscts=0, timeout=0.5)
+        else:
+            raise ValueError, 'Invalid baud rate'
     
     def __format_packet(self, packet):
         return " ".join(["%02x" % p for p in packet]) + " | " + \
@@ -186,9 +206,10 @@ class Serial:
                     print "Failed to send the packet!" 
                 else:
                     print "Timeout waiting for ACK... Retry"
-                        
+                    
         return False
     
+    # Sets whether debugging message will in this module will be printed
     def set_debug(self, debug):
         self.__debug = debug
 
index 813ae73e5fb123b1895c7a46d039d4eefccf79b4..88e132b02ca0c7e0f5dba4be5b571756f7b79856 100755 (executable)
@@ -28,7 +28,7 @@
 #
 # A command line utility to interact with nodes via a direct serial connection.
 # For the usage menu, please run this tool without any arguments. For example, 
-# "./tos-deluge.py"
+# "./tos-deluge"
 ###############################################################################
 
 import sys, os, stat, struct, subprocess
@@ -57,8 +57,9 @@ ERROR_SUCCESS = 0   # T2-compatible
 ERROR_FAIL    = 1   # T2-compatible
 
 # Deluge-specific parameters
+DELUGE_PLATFORMS       = ["telosb", "micaz"]   # Currently supported platforms
 DELUGE_MAX_PAGES       = 128
-DELUGE_METADATA_OFFSET = 0
+DELUGE_METADATA_OFFSET = 0   # Location offset in the image
 DELUGE_METADATA_SIZE   = 16
 DELUGE_IDENT_OFFSET    = 16 + (2 * DELUGE_MAX_PAGES)
 DELUGE_IDENT_SIZE      = 16 + 16 + 16 + 16 + 4 + 4 + 4 + 4   # Metadata size in binary 
@@ -374,49 +375,57 @@ def op_reset(s, img_num):
     return True
       
 def print_usage():
-    print "Usage: %s <device> <-p|-i|-r|-d|-e|-s> image_number [options]" % sys.argv[0]
+    print "Usage: %s <device_port> <baud_rate> <-p|-i|-r|-d|-e|-s> image_number [options]" % sys.argv[0]
+    print "  <baud_rate>\n     Either the platform name or the baud rate value"
+    print "      -------------------"
+    print "      | micaz  |  57600 |"
+    print "      ---------+---------"
+    print "      | telosb | 115200 |"
+    print "      -------------------"
+    print ""
     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 "      [options]: tos_image.xml file path"
     print "  -r --reboot\n     Reboot and reprogram 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"
 
 # ======== MAIN ======== #
-num_req_arg = 4   # Minimum number of required arguments for this script
+num_req_arg = 5   # Minimum number of required arguments for this script
 if len(sys.argv) >= num_req_arg:
+    # Checks for valid image number format
     try:
-        sys.argv[3] = int(sys.argv[3])
+        sys.argv[4] = int(sys.argv[4])
     except:
-        print "ERROR: Volume ID is not valid"
+        print "ERROR: Image number is not valid"
         os._exit(-1)
     
     # Initializes serial port communication
     try:
-        s = tinyos.Serial(sys.argv[1], 115200)
-        s.set_debug(False)   # Disables debug msg
+        s = tinyos.Serial(sys.argv[1], sys.argv[2])
+        s.set_debug(False)
     except:
-        print "ERROR: Unable to initialize serial port connection"
+        print "ERROR: Unable to initialize serial port connection to", sys.argv[1]
         os._exit(-1)
     
-    if sys.argv[2] in ["-p", "--ping"]:
+    if sys.argv[3] in ["-p", "--ping"]:
         print "Pinging node ..."
-        op_ping(s, sys.argv[3]) 
-    elif sys.argv[2] in ["-i", "--inject"] and len(sys.argv) == (num_req_arg + 1):
+        op_ping(s, sys.argv[4]) 
+    elif sys.argv[3] in ["-i", "--inject"] and len(sys.argv) == (num_req_arg + 1):
         print "Pinging node ..."
-        op_inject(s, sys.argv[3], sys.argv[4])
-    elif sys.argv[2] in ["-r", "--reboot"]:
-        if op_reprog(s, sys.argv[3]):
+        op_inject(s, sys.argv[4], sys.argv[5])
+    elif sys.argv[3] in ["-r", "--reboot"]:
+        if op_reprog(s, sys.argv[4]):
             print "Command sent"
-    elif sys.argv[2] in ["-d", "--dissemination"]:
-        if op_diss(s, sys.argv[3]):
+    elif sys.argv[3] in ["-d", "--dissemination"]:
+        if op_diss(s, sys.argv[4]):
             print "Command sent"
-    elif sys.argv[2] in ["-e", "--erase"]:
-        if op_erase(s, sys.argv[3]):
-            print "Image number %d erased" % sys.argv[3]
-    elif sys.argv[2] in ["-s", "--reset"]:
-        if op_reset(s, sys.argv[3]):
+    elif sys.argv[3] in ["-e", "--erase"]:
+        if op_erase(s, sys.argv[4]):
+            print "Image number %d erased" % sys.argv[4]
+    elif sys.argv[3] in ["-s", "--reset"]:
+        if op_reset(s, sys.argv[4]):
             print "Successfully reset image versioning information"
     else:
         print_usage()
index b5098a1ad91e884ceba4f6bed17f620efab61e6f..8b4eba708f0080c0111486375f9f545e785e393c 100644 (file)
@@ -136,12 +136,19 @@ implementation {
     secLength = extFlashReadAddr();
     curAddr = curAddr + 8;
 
-    // check that the image starts on the correct boundary
+#if defined(PLATFORM_TELOSB)
     if (intAddr != TOSBOOT_END) {
+#elif defined(PLATFORM_MICAZ)
+    if (intAddr != 0) {
+#else
+  #error "Target platform is not currently supported by Deluge T2"
+#endif
       call ExtFlash.stopRead();
       return R_INVALID_IMAGE_ERROR;
     }
-
+    
+    call ExtFlash.stopRead();   // MIKE_LIANG
+    
     while ( secLength ) {
       
       pageAddr = newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE;
@@ -151,8 +158,10 @@ implementation {
       do {
 
        // check if secLength is all ones
-       if ( secLength == 0xffffffff )
+       if ( secLength == 0xffffffff ) {
+         call ExtFlash.stopRead();   // MIKE_LIANG
          return FAIL;
+       }
 
        buf[(uint16_t)intAddr % TOSBOOT_INT_PAGE_SIZE] = call ExtFlash.readByte();
        intAddr++; curAddr++;
@@ -173,9 +182,9 @@ implementation {
 
       // write out page
       if (call ProgFlash.write(pageAddr*TOSBOOT_INT_PAGE_SIZE, buf,
-                              TOSBOOT_INT_PAGE_SIZE) == FAIL)
+                              TOSBOOT_INT_PAGE_SIZE) == FAIL) {
        return R_PROGRAMMING_ERROR;
-
+      }
     }
 
     return R_SUCCESS;
@@ -200,7 +209,7 @@ implementation {
       startupLeds();
       runApp();
     }
-
+    
     // get current value of counter
     call IntFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args));
 
@@ -213,8 +222,9 @@ implementation {
       // if the golden image is invalid, forget about reprogramming
       // if an error happened during reprogramming, reboot and try again
       //   not much else we can do :-/
-      if (programImage(TOSBOOT_GOLDEN_IMG_ADDR) == R_PROGRAMMING_ERROR)
+      if (programImage(TOSBOOT_GOLDEN_IMG_ADDR) == R_PROGRAMMING_ERROR) {
        call Hardware.reboot();
+      }
     }
     else {
       // update gesture counter
index 957f98c0b2811f403ac7bd5b114700d549c679d2..f27d9070be4c547aa809047f2f0fd25a9359bb73 100644 (file)
@@ -39,10 +39,10 @@ implementation
   DelugeP.ReprogNotify -> FlashVolumeManagerC;
   FlashVolumeManagerC.BlockRead[0] -> DelugeStorageC.BlockRead[0];
   FlashVolumeManagerC.BlockWrite[0] -> DelugeStorageC.BlockWrite[0];
-  FlashVolumeManagerC.StorageMap[0] -> DelugeStorageC.StorageMap[0];
+  FlashVolumeManagerC.DelugeStorage[0] -> DelugeStorageC.DelugeStorage[0];
   FlashVolumeManagerC.BlockRead[1] -> DelugeStorageC.BlockRead[1];
   FlashVolumeManagerC.BlockWrite[1] -> DelugeStorageC.BlockWrite[1];
-  FlashVolumeManagerC.StorageMap[1] -> DelugeStorageC.StorageMap[1];
+  FlashVolumeManagerC.DelugeStorage[1] -> DelugeStorageC.DelugeStorage[1];
 #endif
   
   components ObjectTransferC;
index 6654f732101060ed35e27e6d2d16aaf8c6a560bb..44455b56a7382a81dd34f4ebe509734462a4735a 100644 (file)
 #ifndef DELUGEPAGETRANSFER_H
 #define DELUGEPAGETRANSFER_H
 
-#include "extra/telosb/TOSBoot_platform.h"
+#if defined(PLATFORM_TELOSB)
+  #include "extra/telosb/TOSBoot_platform.h"
+#elif defined(PLATFORM_MICAZ)
+  #include "extra/micaz/TOSBoot_platform.h"
+#else
+  #error "Target platform is not currently supported by Deluge T2"
+#endif
+
 #include <message.h>
 
 #define AM_DELUGEADVMSG  161
diff --git a/tos/lib/net/Deluge/DelugeStorage.nc b/tos/lib/net/Deluge/DelugeStorage.nc
new file mode 100644 (file)
index 0000000..15f1ed0
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * Copyright (c) 2005-2006 Arch Rock Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * - Redistributions of source code must retain the above copyright\r
+ *   notice, this list of conditions and the following disclaimer.\r
+ * - Redistributions in binary form must reproduce the above copyright\r
+ *   notice, this list of conditions and the following disclaimer in the\r
+ *   documentation and/or other materials provided with the\r
+ *   distribution.\r
+ * - Neither the name of the Arch Rock Corporation nor the names of\r
+ *   its contributors may be used to endorse or promote products derived\r
+ *   from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE\r
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r
+ * OF THE POSSIBILITY OF SUCH DAMAGE\r
+ */\r
+\r
+/**\r
+ * An abstraction to map volume addresses to physical addresses.\r
+ *\r
+ * @author Jonathan Hui <jhui@archrock.com>\r
+ * @version $Revision$ $Date$\r
+ */\r
+\r
+/**\r
+ * The same as StorageMap interface for STM25P.\r
+ *\r
+ * @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>\r
+ * @author Razvan Musaloiu-E. <razvanm@cs.jhu.edu>\r
+ */\r
+\r
+interface DelugeStorage {\r
+\r
+  /**\r
+   * Get the physical address of a volume address.\r
+   *\r
+   * @param addr the volume addres.\r
+   * @return the physical address.\r
+   */\r
+  command storage_addr_t getPhysicalAddress(storage_addr_t addr);\r
+}\r
index 31f76351b26bb530c896b6375956d3bdf607c01b..f5adb54ffc71a68fb6e376c304a720782df8845f 100644 (file)
@@ -31,7 +31,7 @@ configuration DelugeStorageC
   provides {
     interface BlockRead[uint8_t img_num];
     interface BlockWrite[uint8_t img_num];
-    interface StorageMap[uint8_t img_num];
+    interface DelugeStorage[uint8_t img_num];
     interface DelugeMetadata;
     
     interface Notify<uint8_t>;
@@ -40,22 +40,34 @@ configuration DelugeStorageC
 
 implementation
 {
-  components new BlockStorageC(VOLUME_DELUGE0) as BlockStorageC_0;
-  components new BlockStorageC(VOLUME_DELUGE1) as BlockStorageC_1;
   components DelugeStorageP;
 
-  BlockRead[0] = DelugeStorageP.BlockRead[0];
-  BlockWrite[0] = DelugeStorageP.BlockWrite[0];
-  StorageMap[0] = BlockStorageC_0;
-  BlockRead[1] = DelugeStorageP.BlockRead[1];
-  BlockWrite[1] = DelugeStorageP.BlockWrite[1];
-  StorageMap[1] = BlockStorageC_1;
+  BlockRead[VOLUME_DELUGE0] = DelugeStorageP.BlockRead[VOLUME_DELUGE0];
+  BlockWrite[VOLUME_DELUGE0] = DelugeStorageP.BlockWrite[VOLUME_DELUGE0];
+  BlockRead[VOLUME_DELUGE1] = DelugeStorageP.BlockRead[VOLUME_DELUGE1];
+  BlockWrite[VOLUME_DELUGE1] = DelugeStorageP.BlockWrite[VOLUME_DELUGE1];
   DelugeMetadata = DelugeStorageP.DelugeMetadata;
+  components new BlockStorageC(VOLUME_DELUGE0) as BlockStorageC_0;
+  components new BlockStorageC(VOLUME_DELUGE1) as BlockStorageC_1;
+  DelugeStorageP.SubBlockRead[VOLUME_DELUGE0] -> BlockStorageC_0;
+  DelugeStorageP.SubBlockWrite[VOLUME_DELUGE0] -> BlockStorageC_0;
+  DelugeStorageP.SubBlockRead[VOLUME_DELUGE1] -> BlockStorageC_1;
+  DelugeStorageP.SubBlockWrite[VOLUME_DELUGE1] -> BlockStorageC_1;
+  
+#if defined(PLATFORM_TELOSB)
+  DelugeStorageP.StorageMap[VOLUME_DELUGE0] -> BlockStorageC_0;
+  DelugeStorageP.StorageMap[VOLUME_DELUGE1] -> BlockStorageC_1;
+#elif defined(PLATFORM_MICAZ)
+  components At45dbStorageManagerC;
+  DelugeStorageP.At45dbVolume[VOLUME_DELUGE0] -> At45dbStorageManagerC.At45dbVolume[VOLUME_DELUGE0];
+  DelugeStorageP.At45dbVolume[VOLUME_DELUGE1] -> At45dbStorageManagerC.At45dbVolume[VOLUME_DELUGE1];
+#else
+  #error "Target platform is not currently supported by Deluge T2"
+#endif
 
-  DelugeStorageP.SubBlockRead[0] -> BlockStorageC_0;
-  DelugeStorageP.SubBlockWrite[0] -> BlockStorageC_0;
-  DelugeStorageP.SubBlockRead[1] -> BlockStorageC_1;
-  DelugeStorageP.SubBlockWrite[1] -> BlockStorageC_1;
+  DelugeStorage[VOLUME_DELUGE0] = DelugeStorageP.DelugeStorage[VOLUME_DELUGE0];
+  DelugeStorage[VOLUME_DELUGE1] = DelugeStorageP.DelugeStorage[VOLUME_DELUGE1];
   
   components LedsC, MainC;
   DelugeStorageP.Leds -> LedsC;
index 2bdb5f0b1c0f371624f6b091f0094478a9ea285b..67c9f6ccda39493924d887f41515a1505b1ca3db 100644 (file)
@@ -33,10 +33,16 @@ module DelugeStorageP
     interface BlockWrite as SubBlockWrite[uint8_t img_num];
     interface Boot;
     interface Leds;
+#if defined(PLATFORM_TELOSB)
+    interface StorageMap[uint8_t img_num];
+#elif defined(PLATFORM_MICAZ)
+    interface At45dbVolume[volume_id_t img_num];
+#endif
   }
   provides {
     interface BlockRead[uint8_t img_num];
     interface BlockWrite[uint8_t img_num];
+    interface DelugeStorage[uint8_t img_num];
     interface DelugeMetadata;
     
     interface Notify<uint8_t>;
@@ -170,6 +176,23 @@ implementation
     signal BlockWrite.syncDone[img_num](error);
   }
 
+  command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr)
+  {
+    storage_addr_t p_addr = 0xFFFFFFFF;
+    
+    #if defined(PLATFORM_TELOSB)
+      p_addr = call StorageMap.getPhysicalAddress[img_num](addr);
+    #elif defined(PLATFORM_MICAZ)
+      at45page_t page = call At45dbVolume.remap[img_num]((addr >> AT45_PAGE_SIZE_LOG2));
+      at45pageoffset_t offset = addr & ((1 << AT45_PAGE_SIZE_LOG2) - 1);
+      p_addr = page;
+      p_addr = p_addr << AT45_PAGE_SIZE_LOG2;
+      p_addr += offset;
+    #endif
+    
+    return p_addr;
+  }
+
   default event void BlockRead.readDone[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
   default event void BlockRead.computeCrcDone[uint8_t img_num](storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error) {}
   default event void BlockWrite.writeDone[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
@@ -185,4 +208,10 @@ implementation
   
   command error_t Notify.enable() { return SUCCESS; }
   command error_t Notify.disable() { return SUCCESS; }
+  
+#if defined(PLATFORM_TELOSB)
+  default command storage_addr_t StorageMap.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0xFFFFFFFF; }
+#elif defined(PLATFORM_MICAZ)
+  default command at45page_t At45dbVolume.remap[volume_id_t volid](at45page_t volumePage) { return 0xFFFF; };
+#endif
 }
index b8a25f12b3af396e43430c597a183a4a4298daa6..f05d8310aae5f05a8873572eff6ec62cc5a7e814 100644 (file)
@@ -34,7 +34,7 @@ generic configuration FlashVolumeManagerC(am_id_t AMId)
   uses {
     interface BlockRead[uint8_t img_num];
     interface BlockWrite[uint8_t img_num];
-    interface StorageMap[uint8_t img_num];
+    interface DelugeStorage[uint8_t img_num];
   }
 }
 
@@ -47,13 +47,13 @@ implementation
   
   FlashVolumeManagerP.BlockRead[0] = BlockRead[0];
   FlashVolumeManagerP.BlockWrite[0] = BlockWrite[0];
-  FlashVolumeManagerP.StorageMap[0] = StorageMap[0];
+  FlashVolumeManagerP.DelugeStorage[0] = DelugeStorage[0];
   FlashVolumeManagerP.BlockRead[1] = BlockRead[1];
   FlashVolumeManagerP.BlockWrite[1] = BlockWrite[1];
-  FlashVolumeManagerP.StorageMap[1] = StorageMap[1];
+  FlashVolumeManagerP.DelugeStorage[1] = DelugeStorage[1];
   FlashVolumeManagerP.SerialAMSender -> SerialAMSenderC;
   FlashVolumeManagerP.SerialAMReceiver -> SerialAMReceiverC;
-  FlashVolumeManagerP.Leds -> NoLedsC;
+  FlashVolumeManagerP.Leds -> LedsC;
 
 #ifdef DELUGE  
   components NetProgC, new TimerMilliC();
index f31c71603a0ee55ca7a95fd4d28006dacbf66ea0..e57052770c004166c088cee82c10741edb949d47 100644 (file)
@@ -34,7 +34,7 @@ generic module FlashVolumeManagerP()
   uses {
     interface BlockRead[uint8_t img_num];
     interface BlockWrite[uint8_t img_num];
-    interface StorageMap[uint8_t img_num];
+    interface DelugeStorage[uint8_t img_num];
     interface AMSend as SerialAMSender;
     interface Receive as SerialAMReceiver;
     interface Leds;
@@ -119,6 +119,13 @@ implementation
   }
   
   event void BlockWrite.eraseDone[uint8_t img_num](error_t error)
+  {
+    if (state == S_ERASE) {
+      call BlockWrite.sync[img_num]();
+    }
+  }
+  
+  event void BlockWrite.syncDone[uint8_t img_num](error_t error)
   {
     if (state == S_ERASE) {
       state = S_IDLE;
@@ -126,8 +133,6 @@ implementation
     }
   }
   
-  event void BlockWrite.syncDone[uint8_t img_num](error_t error) {}
-  
   event void SerialAMSender.sendDone(message_t* msg, error_t error) {}
   
   event message_t* SerialAMReceiver.receive(message_t* msg, void* payload, uint8_t len)
@@ -136,44 +141,55 @@ implementation
     SerialReqPacket *srpkt = (SerialReqPacket *)payload;
     SerialReplyPacket *serialMsg_payload =
                               (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg);
+    uint8_t img_num = 0xFF;
+    
+    // Converts the image number that the user wants to the real image number
+    switch (srpkt->img_num) {
+      case 0:
+        img_num = VOLUME_DELUGE0;
+        break;
+      case 1:
+        img_num = VOLUME_DELUGE1;
+        break;
+    }
     
     switch (srpkt->msg_type) {
       case SERIALMSG_ERASE:    // === Erases a volume ===
         state = S_ERASE;
-        error = call BlockWrite.erase[srpkt->img_num]();
+        error = call BlockWrite.erase[img_num]();
         break;
       case SERIALMSG_WRITE:    // === Writes to a volume ===
         state = S_WRITE;
         memcpy(buffer, srpkt->data, srpkt->len);
-        error = call BlockWrite.write[srpkt->img_num](srpkt->offset,
+        error = call BlockWrite.write[img_num](srpkt->offset,
                                                       buffer,
                                                       srpkt->len);
         break;
       case SERIALMSG_READ:     // === Reads a portion of a volume ===
         state = S_READ;
-        error = call BlockRead.read[srpkt->img_num](srpkt->offset,
+        error = call BlockRead.read[img_num](srpkt->offset,
                                                     serialMsg_payload->data,
                                                     srpkt->len);
         break;
       case SERIALMSG_CRC:      // === Computes CRC over a portion of a volume ===
         state = S_CRC;
-        error = call BlockRead.computeCrc[srpkt->img_num](srpkt->offset,
+        error = call BlockRead.computeCrc[img_num](srpkt->offset,
                                                           srpkt->len, 0);
         break;
       case SERIALMSG_ADDR:     // === Gets the physical starting address of a volume ===
        *(nx_uint32_t*)(&serialMsg_payload->data) =
-                             (uint32_t)call StorageMap.getPhysicalAddress[srpkt->img_num](0);
+                             (uint32_t)call DelugeStorage.getPhysicalAddress[img_num](0);
        sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
         break;
 #ifdef DELUGE
       case SERIALMSG_REPROG:   // === Reboots and reprograms ===
         state = S_REPROG;
         sendReply(SUCCESS, sizeof(SerialReplyPacket));
-        img_num_reboot = srpkt->img_num;
+        img_num_reboot = img_num;
        call Timer.startOneShot(1024);
        break;
       case SERIALMSG_DISS:     // === Starts disseminating a volume ===
-       signal Notify.notify(srpkt->img_num);   // Notifies Deluge to start disseminate
+       signal Notify.notify(img_num);   // Notifies Deluge to start disseminate
        sendReply(SUCCESS, sizeof(SerialReplyPacket));
        break;
 #endif
@@ -205,5 +221,5 @@ implementation
   default command error_t BlockRead.read[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
   default command error_t BlockRead.computeCrc[uint8_t img_num](storage_addr_t addr, storage_len_t len, uint16_t crc) { return FAIL; }
 
-  default command storage_addr_t StorageMap.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
+  default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
 }
index f88966181c924910d3c72cae08e144aa3f91b4c3..255d2c9b7d72592f2db4f8892c78fee3a34d98f4 100644 (file)
@@ -46,9 +46,12 @@ implementation {
   NetProg = NetProgM;
 
   MainC.SoftwareInit -> NetProgM.Init;
-  NetProgM.StorageMap[0] -> DelugeStorageC.StorageMap[0];
-  NetProgM.StorageMap[1] -> DelugeStorageC.StorageMap[1];
+  NetProgM.DelugeStorage[VOLUME_DELUGE0] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE0];
+  NetProgM.DelugeStorage[VOLUME_DELUGE1] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE1];
   NetProgM.DelugeMetadata -> DelugeStorageC;
   NetProgM.IFlash -> IFlash;
   NetProgM.Crc -> CrcP;
+  
+  components LedsC;
+  NetProgM.Leds -> LedsC;
 }
index 998a5fdb925ad75569f9e1f1ce7a58a017b312cf..93bed42cc8ec49aa145b1717e863e78e9d5cd87b 100644 (file)
@@ -37,10 +37,11 @@ module NetProgM {
     interface Init;
   }
   uses {
-    interface StorageMap[uint8_t img_num];
+    interface DelugeStorage[uint8_t img_num];
     interface InternalFlash as IFlash;
     interface Crc;
     interface DelugeMetadata;
+    interface Leds;
   }
 }
 
@@ -103,7 +104,7 @@ implementation {
     atomic {
       writeTOSinfo();
       
-      args.imageAddr = call StorageMap.getPhysicalAddress[img_num](0);
+      args.imageAddr = call DelugeStorage.getPhysicalAddress[img_num](0);
       args.gestureCount = 0xff;
       args.noReprogram = FALSE;
       call IFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args));
@@ -122,6 +123,6 @@ implementation {
     return FAIL;
   }
 
-  default command storage_addr_t StorageMap.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0xFFFFFFFF; }
+  default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0xFFFFFFFF; }
 
 }
diff --git a/tos/lib/net/Deluge/extra/avr/InternalFlashC.nc b/tos/lib/net/Deluge/extra/avr/InternalFlashC.nc
new file mode 100644 (file)
index 0000000..ac24b50
--- /dev/null
@@ -0,0 +1,65 @@
+// $Id$
+
+/*                                                                     tab:2
+ *
+ *
+ * "Copyright (c) 2000-2005 The Regents of the University  of California.  
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#include "InternalFlash.h"
+
+module InternalFlashC {
+  provides interface InternalFlash;
+}
+
+implementation {
+
+  command error_t InternalFlash.write(void* addr, void* buf, uint16_t size) {
+
+    uint8_t *addrPtr = (uint8_t*)addr;
+    uint8_t *bufPtr = (uint8_t*)buf;
+
+    for ( ; size; size-- )
+      eeprom_write_byte(addrPtr++, *bufPtr++);
+
+    while(!eeprom_is_ready());
+
+    return SUCCESS;
+
+  }
+
+  command error_t InternalFlash.read(void* addr, void* buf, uint16_t size) {
+
+    uint8_t *addrPtr = (uint8_t*)addr;
+    uint8_t *bufPtr = (uint8_t*)buf;
+
+    for ( ; size; size-- )
+      *bufPtr++ = eeprom_read_byte(addrPtr++);
+
+    return SUCCESS;
+
+  }
+
+}
diff --git a/tos/lib/net/Deluge/extra/mica2/NetProg_platform.h b/tos/lib/net/Deluge/extra/mica2/NetProg_platform.h
new file mode 100644 (file)
index 0000000..165cdef
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$\r
+\r
+/*                                                                      tab:2\r
+ *\r
+ *\r
+ * "Copyright (c) 2000-2005 The Regents of the University  of California.  \r
+ * All rights reserved.\r
+ *\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation for any purpose, without fee, and without written agreement is\r
+ * hereby granted, provided that the above copyright notice, the following\r
+ * two paragraphs and the author appear in all copies of this software.\r
+ * \r
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT\r
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF\r
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * \r
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\r
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."\r
+ *\r
+ */\r
+\r
+/**\r
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>\r
+ */\r
+\r
+#ifndef __NETPROG_PLATFORM_H__\r
+#define __NETPROG_PLATFORM_H__\r
+\r
+enum {\r
+  IFLASH_TOS_INFO_ADDR = 0xfe0,  // 6 bytes\r
+  IFLASH_NODE_DESC_ADDR = 0xfe6, // 10 bytes\r
+};\r
+\r
+void netprog_reboot() {\r
+  wdt_enable(1);\r
+  while(1);\r
+}\r
+\r
+#endif\r
diff --git a/tos/lib/net/Deluge/extra/micaz/InternalFlash.h b/tos/lib/net/Deluge/extra/micaz/InternalFlash.h
new file mode 100644 (file)
index 0000000..95ec7cd
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$
+
+/*                                                                      tab:4
+ *
+ *
+ * "Copyright (c) 2000-2004 The Regents of the University  of California.  
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * InternalFlash.h - Internal flash implementation for the avr
+ * platform.
+ *
+ * Valid address range is 0x0 - 0xFFF.
+ *
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __INTERNAL_FLASH_H__
+#define __INTERNAL_FLASH_H__
+
+#include <avr/eeprom.h>
+
+#endif
diff --git a/tos/lib/net/Deluge/extra/micaz/TOSBoot_platform.h b/tos/lib/net/Deluge/extra/micaz/TOSBoot_platform.h
new file mode 100644 (file)
index 0000000..736bb2e
--- /dev/null
@@ -0,0 +1,47 @@
+// $Id$
+
+/*                                                                      tab:2
+ * "Copyright (c) 2000-2005 The Regents of the University  of California.  
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * @author  Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __TOSBOOT_PLATFORM_H__
+#define __TOSBOOT_PLATFORM_H__
+
+enum {
+  // address of TOSBoot args in internal flash
+  TOSBOOT_ARGS_ADDR = 0xff0,
+  // number of resets to force golden image
+  TOSBOOT_GESTURE_MAX_COUNT = 3,
+  // address of the golden image in external flash
+  TOSBOOT_GOLDEN_IMG_ADDR = 0x0L,
+  // size of each internal program flash page
+  TOSBOOT_INT_PAGE_SIZE = SPM_PAGESIZE,
+};
+
+enum {
+  DELUGE_MIN_ADV_PERIOD_LOG2 = 9,
+  DELUGE_QSIZE = 2,
+};
+
+#endif