}
implementation
{
- components MainC, BlinkC, LedsC, DelugeC;
+ components MainC, BlinkC, LedsC;
+#ifdef DELUGE
+ components DelugeC;
+#endif
components new TimerMilliC() as Timer0;
BlinkC -> MainC.Boot;
#!/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
--- /dev/null
+<volume_table>
+ <volume name="DELUGE0" size="65536"/>
+ <volume name="DELUGE1" size="65536"/>
+</volume_table>
\ No newline at end of file
--- /dev/null
+<volume_table>
+ <volume name="DELUGE0" size="65536"/>
+ <volume name="DELUGE1" size="65536"/>
+</volume_table>
\ No newline at end of file
--- /dev/null
+<volume_table>
+ <volume name="DELUGE0" size="65536"/>
+ <volume name="DELUGE1" size="65536"/>
+</volume_table>
\ No newline at end of file
<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>
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 Quick Start</h1>
+<h1>2 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 Quick Start</h1>
<p></p>
<p>
This section introduces the basics of reprogramming with an example. In
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
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>
</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 Reprogramming a Network</h1>
+<a name="node_sec_4"></a>
+<h1>4 Reprogramming a Network</h1>
<p></p>
<p>
This section illustrates the procedure to reprogram a network.
versioning information is retrieved.</p>
<p>
</p>
-<a name="node_sec_3.1"></a>
-<h2>3.1 Setting Up the Motes</h2>
+<a name="node_sec_4.1"></a>
+<h2>4.1 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
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 Preparing Your Application</h2>
+<a name="node_sec_4.2"></a>
+<h2>4.2 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
</pre><p></p>
<p>
</p>
-<a name="node_sec_3.3"></a>
-<h2>3.3 Injecting Your Application</h2>
+<a name="node_sec_4.3"></a>
+<h2>4.3 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>
</pre><p></p>
<p>
</p>
-<a name="node_sec_3.4"></a>
-<h2>3.4 Reprogramming with New Image</h2>
+<a name="node_sec_4.4"></a>
+<h2>4.4 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>
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
over-the-air, each node automatically reboots and reprograms itself.</p>
<p>
</p>
-<a name="node_sec_4"></a>
-<h1>4 Deluge T2 Python Toolchain</h1>
+<a name="node_sec_5"></a>
+<h1>5 Deluge T2 Python Toolchain</h1>
<p></p>
<p>
Different from Deluge 2.0, Deluge T2 toolchain is written in Python.
similar.</p>
<p>
</p>
-<a name="node_sec_4.1"></a>
-<h2>4.1 -p -ping</h2>
+<a name="node_sec_5.1"></a>
+<h2>5.1 -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 -i -inject</h2>
+<a name="node_sec_5.2"></a>
+<h2>5.2 -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 -r -reboot</h2>
+<a name="node_sec_5.3"></a>
+<h2>5.3 -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 -d -dissemination</h2>
+<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>
</p>
-<a name="node_sec_4.5"></a>
-<h2>4.5 -e -erase</h2>
+<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>
<p>
</p>
-<a name="node_sec_4.6"></a>
-<h2>4.6 -s -reset</h2>
+<a name="node_sec_5.6"></a>
+<h2>5.6 -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>
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
# @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
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]) + " | " + \
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
#
# 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
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
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()
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;
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++;
// 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;
startupLeds();
runApp();
}
-
+
// get current value of counter
call IntFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args));
// 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
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;
#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
--- /dev/null
+/*\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
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>;
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;
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>;
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) {}
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
}
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];
}
}
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();
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;
}
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;
}
}
- 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)
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
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; }
}
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;
}
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;
}
}
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));
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; }
}
--- /dev/null
+// $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;
+
+ }
+
+}
--- /dev/null
+// $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
--- /dev/null
+// $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
--- /dev/null
+// $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