]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Added DelugeT2 support for the tinynode platform.
authorrflury <rflury>
Tue, 10 Nov 2009 07:03:34 +0000 (07:03 +0000)
committerrflury <rflury>
Tue, 10 Nov 2009 07:03:34 +0000 (07:03 +0000)
21 files changed:
apps/tests/deluge/Blink/burn
support/make/tosboot.extra
tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerC.nc
tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerP.nc
tos/lib/net/Deluge/DelugePageTransfer.h
tos/lib/net/Deluge/extra/NetProgC.nc
tos/lib/net/Deluge/extra/NetProgM.nc
tos/lib/net/Deluge/extra/tinynode/NetProg_platform.h [new file with mode: 0644]
tos/lib/net/Deluge/extra/tinynode/README [new file with mode: 0644]
tos/lib/net/Deluge/extra/tinynode/ReprogramGuardC.nc [new file with mode: 0644]
tos/lib/net/Deluge/extra/tinynode/ReprogramGuardP.nc [new file with mode: 0644]
tos/lib/net/Deluge/extra/tinynode/TOSBoot_platform.h [new file with mode: 0644]
tos/lib/tosboot/Makefile
tos/lib/tosboot/TosBootP.nc
tos/lib/tosboot/tinynode/ExecC.nc [new file with mode: 0644]
tos/lib/tosboot/tinynode/ExtFlashC.nc [new file with mode: 0644]
tos/lib/tosboot/tinynode/PowerOffC.nc [new file with mode: 0644]
tos/lib/tosboot/tinynode/README [new file with mode: 0644]
tos/lib/tosboot/tinynode/TOSBoot_platform.h [new file with mode: 0644]
tos/lib/tosboot/tinynode/VoltageC.nc [new file with mode: 0644]
tos/lib/tosboot/tinynode/hardware.h [new file with mode: 0644]

index df748c386346b9012ed7c98099e6be0750a6b318..fa4a3b1e00e2ec128d919e3d25c425ac38ee765d 100755 (executable)
@@ -29,6 +29,7 @@ if [ ${PLATFORM} != 'micaz' -a \
      ${PLATFORM} != 'telosb' -a \
      ${PLATFORM} != 'iris' -a \
      ${PLATFORM} != 'mulle' -a \
+     ${PLATFORM} != 'tinynode' -a \
      ${PLATFORM} != 'epic' ]
 then
   echo "\"${PLATFORM}\" is not a supported platform"
index 125972677e9144df9640ad8dcb5c1a84752d1547..ddb928c01f387642c8e30dab41734d31b24a713a 100644 (file)
@@ -45,5 +45,14 @@ ifeq ($(BOOTLOADER),tosboot)
     AVR_FUSE_H ?= 0xda
   endif
 
+   ifeq ($(TARGETS),tinynode)
+               CFLAGS += -I$(DELUGE_EXTRA)/tinynode
+               CFLAGS += -I$(DELUGE_EXTRA) -I$(DELUGE_EXTRA)/msp430 -I$(DELUGE_EXTRA)/msp430f1611 
+     ifeq ($(filter docs,$(GOALS)),)
+                       CFLAGS += -Wl,--section-start=.text=0x4a00,--defsym=_reset_vector__=0x4000
+     endif
+               BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/tinynode/main.ihex
+   endif
+
 
 endif
index 1631e735fbd3b38a35000d607f72fcf350879212..d350aed9e0e49331107b50c27ddb0d33688fe367 100644 (file)
@@ -69,7 +69,7 @@ implementation
   BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE1]     -> BlockStorageC_1;
   BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE2]     -> BlockStorageC_2;
   BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE3]     -> BlockStorageC_3;
-#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE) || defined(PLATFORM_TINYNODE)
   components At45dbStorageManagerC;
   BlockStorageManagerP.At45dbVolume -> At45dbStorageManagerC;
 #endif
index 22d8fcd228600ce3fa402ecac454bd5102ff9058..3c0e34e85041e0e9017833adbae1de2eea754cd7 100644 (file)
@@ -37,7 +37,7 @@ generic module BlockStorageManagerP(uint8_t clients)
     interface VolumeId[uint8_t client];
 #if defined(PLATFORM_TELOSB)
     interface StorageMap as SubStorageMap[volume_id_t volume_id];
-#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE) || defined(PLATFORM_TINYNODE)
     interface At45dbVolume[volume_id_t volume_id];
 #endif
   }
@@ -180,7 +180,7 @@ implementation
     storage_addr_t p_addr = 0xFFFFFFFF;
 #if defined(PLATFORM_TELOSB)
     p_addr = call SubStorageMap.getPhysicalAddress[volume_id](addr);
-#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE) || defined(PLATFORM_TINYNODE)
     at45page_t page = call At45dbVolume.remap[volume_id]((addr >> AT45_PAGE_SIZE_LOG2));
     at45pageoffset_t offset = addr & ((1 << AT45_PAGE_SIZE_LOG2) - 1);
     p_addr = page;
index 8dc671a6708dd8cc392491734e79fee1be85d55c..49ed1e99f46e0545c36bf0ee9286b671226b97a7 100644 (file)
@@ -37,6 +37,8 @@
   #include "extra/micaz/TOSBoot_platform.h"
 #elif defined(PLATFORM_MULLE)
   #include "extra/mulle/TOSBoot_platform.h"
+#elif defined(PLATFORM_TINYNODE)
+  #include "extra/tinynode/TOSBoot_platform.h"
 #else
   #error "Target platform is not currently supported by Deluge T2"
 #endif
index da2b50e646a6535d5c584355f9c6d0b20f880f1f..79bad7651dd654b4bde4b9323cf9de1b9687ada2 100644 (file)
@@ -56,6 +56,8 @@ implementation {
   components ActiveMessageAddressC;
   NetProgM.setAmAddress -> ActiveMessageAddressC;
 
+#if !defined(PLATFORM_TINYNODE)
   components CC2420ControlP;
   NetProgM.CC2420Config -> CC2420ControlP;
+#endif
 }
index e77ebeedeb4b09780359cfa6b8eb8cc0dbe91055..fc054cff8fc0f13e00d657a1ca6da95241129eff 100644 (file)
@@ -40,7 +40,9 @@ module NetProgM {
     interface InternalFlash as IFlash;
     interface Crc;
     interface Leds;
+#if !defined(PLATFORM_TINYNODE)
     interface CC2420Config;
+#endif
     async command void setAmAddress(am_addr_t a);
     interface ReprogramGuard;
   }
@@ -60,9 +62,10 @@ implementation {
       TOS_NODE_ID = bootArgs.address;
       call setAmAddress(bootArgs.address);
     }
+#if !defined(PLATFORM_TINYNODE)
     call CC2420Config.setShortAddr(bootArgs.address);
     call CC2420Config.sync();
-    
+#endif    
     return SUCCESS;
   }
   
@@ -113,5 +116,7 @@ implementation {
     }
   }
 
+#if !defined(PLATFORM_TINYNODE)
   event void CC2420Config.syncDone(error_t error) {}
+#endif
 }
diff --git a/tos/lib/net/Deluge/extra/tinynode/NetProg_platform.h b/tos/lib/net/Deluge/extra/tinynode/NetProg_platform.h
new file mode 100644 (file)
index 0000000..8b80b52
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$
+
+/*
+ *
+ *
+ * "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 __NETPROG_PLATFORM_H__
+#define __NETPROG_PLATFORM_H__
+
+void netprog_reboot() {
+  WDTCTL = WDT_ARST_1_9; 
+  while(1);
+}
+
+#endif
diff --git a/tos/lib/net/Deluge/extra/tinynode/README b/tos/lib/net/Deluge/extra/tinynode/README
new file mode 100644 (file)
index 0000000..4b5cd7d
--- /dev/null
@@ -0,0 +1,15 @@
+Deluge T2 for TinyNode
+----------------------------------
+
+
+These files are needed by Deluge T2 to compile for the TinyNode platform. 
+
+Note: 
+
+Reprogramming fails if the voltage of the node is not above a given 
+threshold. Currently, this is set to 2.7V, which may be too high if 
+you run your mote on batteries. In this case, set the value of
+VTHRESH in the ReprogramGaurdP.nc file to a different value. 
+
+In case you wish not to test the voltage at all, modify ReprogramGuardP.nc
+s.t. the command okToProgram() posts readDone with SUCCESS. 
\ No newline at end of file
diff --git a/tos/lib/net/Deluge/extra/tinynode/ReprogramGuardC.nc b/tos/lib/net/Deluge/extra/tinynode/ReprogramGuardC.nc
new file mode 100644 (file)
index 0000000..9f25e50
--- /dev/null
@@ -0,0 +1,13 @@
+configuration ReprogramGuardC
+{
+  provides interface ReprogramGuard;
+}
+
+implementation
+{
+  components ReprogramGuardP;
+  components new VoltageC();
+  
+  ReprogramGuard = ReprogramGuardP;
+  ReprogramGuardP.Voltage -> VoltageC;
+}
diff --git a/tos/lib/net/Deluge/extra/tinynode/ReprogramGuardP.nc b/tos/lib/net/Deluge/extra/tinynode/ReprogramGuardP.nc
new file mode 100644 (file)
index 0000000..2a3b010
--- /dev/null
@@ -0,0 +1,18 @@
+module ReprogramGuardP {
+  provides interface ReprogramGuard;
+  uses interface Read<uint16_t> as Voltage;
+}
+
+implementation {
+  enum {
+    VTHRESH = 0xE66, // 2.7V
+  };
+
+  command error_t ReprogramGuard.okToProgram() {
+    return call Voltage.read();
+  }
+
+  event void Voltage.readDone(error_t result, uint16_t val) {
+    signal ReprogramGuard.okToProgramDone(result == SUCCESS && val > VTHRESH);
+  }
+}
diff --git a/tos/lib/net/Deluge/extra/tinynode/TOSBoot_platform.h b/tos/lib/net/Deluge/extra/tinynode/TOSBoot_platform.h
new file mode 100644 (file)
index 0000000..87e1756
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$
+
+/*
+ * "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 {
+  TOSBOOT_ARGS_ADDR = 0x70,      // address of TOSBoot args in internal flash
+  TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image
+  TOSBOOT_GOLDEN_IMG_ADDR = 0x0L, // address of the golden image in external flash
+  TOSBOOT_INT_PAGE_SIZE = 512L,  // size of each internal program flash page
+};
+
+#endif
index 1dcd46aa00636dc9cfc9d83d06700fc763829c25..3399b0eae127eca4bbda581cf7b8893ebe49fb25 100644 (file)
@@ -86,6 +86,15 @@ ifeq ($(MAKECMDGOALS),mulle)
   CFLAGS += -I../net/Deluge/extra/m16c62p
 endif
 
+ifeq ($(MAKECMDGOALS),tinynode)
+  CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00
+  CFLAGS += -Itinynode -Imsp430 -Imsp430f1611 -Iat45db -Ilib
+  CFLAGS += -I../net/Deluge
+  POST_BUILD_EXTRA_DEPS += strip_iv 
+endif
+
+
+
 strip_iv: FORCE
        @echo "    removing interrupt vector from binary"
        msp430-objcopy -j .text -j .data -O ihex $(BUILDDIR)/main.exe $(BUILDDIR)/main.ihex
index 9340772c065b7de49a72e2ffcb0db00ee8347369..83367056725ded4fe6d47a6d519b7ca552bec317 100644 (file)
@@ -145,7 +145,7 @@ implementation {
     secLength = extFlashReadAddr();
     curAddr = curAddr + 8;
 
-#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC)
+#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE)
     if (intAddr != TOSBOOT_END) {
 #elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS)
     if (intAddr != 0) {
diff --git a/tos/lib/tosboot/tinynode/ExecC.nc b/tos/lib/tosboot/tinynode/ExecC.nc
new file mode 100644 (file)
index 0000000..0dee182
--- /dev/null
@@ -0,0 +1,45 @@
+// $Id$
+
+/*
+ * "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>
+ */
+
+module ExecC {
+  provides {
+    interface Exec;
+  }
+}
+
+implementation {
+
+  command void Exec.exec() {
+
+    //goto *(void*)(TOSBOOT_END);
+
+    typedef void __attribute__((noreturn)) (*tosboot_exec)();
+    ((tosboot_exec)TOSBOOT_END)();
+
+  }
+
+}
diff --git a/tos/lib/tosboot/tinynode/ExtFlashC.nc b/tos/lib/tosboot/tinynode/ExtFlashC.nc
new file mode 100644 (file)
index 0000000..859e040
--- /dev/null
@@ -0,0 +1,160 @@
+// $Id$
+
+/*
+ *
+ *
+ * "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>
+ * @author Roland Flury <roland.flury@shockfish.com>
+ */
+
+module ExtFlashC {
+  provides {
+    interface Init;
+    interface StdControl;
+    interface ExtFlash;
+  }
+}
+
+/**
+ * Simple reader module to access the Atmel at45db041 flash chip
+ */
+implementation {
+
+  uint32_t addr;
+
+  command error_t Init.init() {
+
+    TOSH_SET_FLASH_CS_PIN(); // inverted, deselect by default
+    TOSH_MAKE_FLASH_CS_OUTPUT();
+
+    TOSH_CLR_FLASH_CLK_PIN();
+    TOSH_MAKE_FLASH_CLK_OUTPUT();
+
+    TOSH_SET_FLASH_OUT_PIN();
+    TOSH_MAKE_FLASH_OUT_OUTPUT();      
+
+    TOSH_MAKE_FLASH_IN_INPUT();
+
+               TOSH_SET_FLASH_RESET_PIN(); // inverted
+               TOSH_MAKE_FLASH_RESET_OUTPUT();
+
+    return SUCCESS; 
+  }
+
+  command error_t StdControl.start() { return SUCCESS; }
+  command error_t StdControl.stop() { return SUCCESS; }
+       
+       /**
+        * Write a Byte over the SPI bus and receive a Byte
+        *
+        * upon calling this function, /CS must be CLR
+        */
+  uint8_t SPIByte(uint8_t out) {
+    uint8_t in = 0;
+    uint8_t i;
+
+    for ( i = 0; i < 8; i++, out <<= 1 ) {
+      // write bit
+      if (out & 0x80) {
+                               TOSH_SET_FLASH_OUT_PIN();
+                       } else {
+                               TOSH_CLR_FLASH_OUT_PIN();
+                       }
+                       
+      // clock
+      TOSH_SET_FLASH_CLK_PIN();
+                       
+      // read bit
+      in <<= 1;
+      if (TOSH_READ_FLASH_IN_PIN()) {
+                               in |= 1;
+                       }
+                       
+      // clock
+      TOSH_CLR_FLASH_CLK_PIN();
+    }
+
+    return in;
+  }
+
+
+
+       /**
+        * Initializes the flash to read Byte after Byte starting
+        * from the given address. 
+        *
+        * Subsequent calls to readByte() will return the Bytes 
+        * starting from the specified address. 
+        *
+        * stopRead() terminates this process and disables the Flash. 
+        */
+  command void ExtFlash.startRead(uint32_t newAddr) {
+    uint8_t  cmdBuf[4];
+    uint8_t  i;
+
+               // we're using "Waveform 1 - Inactive Clock Polarity Low"
+               // see p.7 of data sheet
+    TOSH_CLR_FLASH_CLK_PIN(); 
+    TOSH_CLR_FLASH_CS_PIN(); // select the flash
+
+    addr = newAddr;
+
+               // we only use 256 Bytes per block (of 264 Bytes)
+    cmdBuf[0] = 0x52; // command for reading data starting at the following address
+    cmdBuf[1] = (addr >> 15) & 0xff; // 4 LSbits 
+    cmdBuf[2] = (addr >> 7) & 0xfe;  // 7 MSbits with the above 4 bits describe page to read
+    cmdBuf[3] = addr & 0xff;         // Offset to Byte in page to read
+
+               // transmit read command
+    for(i = 0; i < 4; i++) {
+      SPIByte(cmdBuf[i]);
+               }
+               // transmit 4 Bytes "don't care" as to spec
+    for(i = 0; i < 4; i++) {
+      SPIByte(0x0);
+               }
+    
+               // need to do one additional clock transition before reading
+               TOSH_SET_FLASH_CLK_PIN();
+               TOSH_CLR_FLASH_CLK_PIN();
+  }
+
+  command uint8_t ExtFlash.readByte() {
+               uint8_t b = SPIByte(0); // write anything, read Byte
+               addr++;
+               if(0 == (addr & 0xFF)) {
+                       // we've just read the last Byte from a page
+                       // initialize the Flash to continue reading on the new page
+      call ExtFlash.stopRead();
+      call ExtFlash.startRead(addr);
+               } 
+               return b;
+  }
+
+  command void ExtFlash.stopRead() {
+    TOSH_SET_FLASH_CS_PIN(); // disble Flash & tri-state the OUT-pin
+  }
+
+}
diff --git a/tos/lib/tosboot/tinynode/PowerOffC.nc b/tos/lib/tosboot/tinynode/PowerOffC.nc
new file mode 100644 (file)
index 0000000..a230222
--- /dev/null
@@ -0,0 +1,89 @@
+// $Id$
+
+/*
+ *
+ *
+ * "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."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+module PowerOffC {
+  provides {
+    interface Init;
+    interface StdControl;
+  }
+  uses {
+    interface Leds;
+    interface StdControl as SubControl;
+  }
+}
+
+implementation {
+
+  void haltsystem() {
+
+    uint16_t _lpmreg;
+
+    TOSH_SET_PIN_DIRECTIONS();
+
+    call SubControl.stop();
+
+    call Leds.glow(0x7, 0x0);
+
+    _lpmreg = LPM4_bits;
+    _lpmreg |= SR_GIE;
+
+    __asm__ __volatile__( "bis  %0, r2" : : "m" ((uint16_t)_lpmreg) );
+
+  }
+
+  command error_t Init.init() {
+    return SUCCESS;
+  }
+
+  command error_t StdControl.start() {
+
+    int i;
+
+    // wait a short period for things to stabilize
+    for ( i = 0; i < 4; i++ ) {
+      wait(0xffff);
+               }
+
+               // TinyNode: we don't have a user button
+
+    // if user button is pressed, power down
+    //if (!TOSH_READ_USERINT_PIN()) {
+               //haltsystem(); 
+               //}
+
+    return SUCCESS;
+
+  }
+
+  command error_t StdControl.stop() {
+    return SUCCESS;
+  }
+
+}
diff --git a/tos/lib/tosboot/tinynode/README b/tos/lib/tosboot/tinynode/README
new file mode 100644 (file)
index 0000000..86792ef
--- /dev/null
@@ -0,0 +1,15 @@
+Deluge T2 for TinyNode
+----------------------------------
+
+
+These files are needed by Deluge T2 to compile for the TinyNode platform. 
+
+Note: 
+
+Reprogramming fails if the voltage of the node is not above a given 
+threshold. Currently, this is set to 2.7V, which may be too high if 
+you run your mote on batteries. In this case, set the value of
+VTHRESH in the hardware.h file to a different value. 
+
+In case you wish not to test the voltage at all, modify VoltageC.nc
+s.t. the command Voltage.okToProgram() returns always TRUE. 
\ No newline at end of file
diff --git a/tos/lib/tosboot/tinynode/TOSBoot_platform.h b/tos/lib/tosboot/tinynode/TOSBoot_platform.h
new file mode 100644 (file)
index 0000000..9bcc776
--- /dev/null
@@ -0,0 +1,43 @@
+// $Id$
+
+/*
+ * "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 {
+  TOSBOOT_ARGS_ADDR = 0x70,      // address of TOSBoot args in internal flash
+  TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image
+  TOSBOOT_GOLDEN_IMG_ADDR = 0x0L, // address of the golden image in external flash
+  TOSBOOT_INT_PAGE_SIZE = 512L,  // size of each internal program flash page
+};
+
+enum {
+  DELUGE_MIN_ADV_PERIOD_LOG2 = 9,
+  DELUGE_QSIZE = 1,
+};
+
+#endif
diff --git a/tos/lib/tosboot/tinynode/VoltageC.nc b/tos/lib/tosboot/tinynode/VoltageC.nc
new file mode 100644 (file)
index 0000000..7a30610
--- /dev/null
@@ -0,0 +1,68 @@
+// $Id$
+
+/*
+ *
+ *
+ * "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."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+module VoltageC {
+  provides {
+    interface Voltage;
+  }
+}
+
+implementation {
+
+  command bool Voltage.okToProgram() {
+
+               /** original code form the msp430 folder */
+    int i;
+
+    // Turn on and set up ADC12 with REF_1_5V
+    ADC12CTL0 = ADC12ON | SHT0_2 | REFON;
+    // Use sampling timer
+    ADC12CTL1 = SHP;
+    // Set up to sample voltage
+    ADC12MCTL0 = EOS | SREF_1 | INCH_11;
+    // Delay for reference start-up
+    for ( i=0; i<0x3600; i++ );
+
+    // Enable conversions
+    ADC12CTL0 |= ENC;
+    // Start conversion
+    ADC12CTL0 |= ADC12SC;
+    // Wait for completion
+    while ((ADC12IFG & BIT0) == 0);
+
+    // Turn off ADC12
+    ADC12CTL0 &= ~ENC;
+    ADC12CTL0 = 0;
+
+    // Check if voltage is greater than 2.7V
+    return ( ADC12MEM0 > VTHRESH );
+  }
+
+}
diff --git a/tos/lib/tosboot/tinynode/hardware.h b/tos/lib/tosboot/tinynode/hardware.h
new file mode 100644 (file)
index 0000000..4164dc4
--- /dev/null
@@ -0,0 +1,84 @@
+// $Id$
+
+/*
+ *
+ *
+ * "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>
+ * @author Roland Flury <roland.flury@shockfish.com>
+ */
+
+#ifndef __HARDWARE_H__
+#define __HARDWARE_H__
+
+#include "msp430hardware.h"
+
+// internal flash is 16 bits in width
+typedef uint16_t in_flash_addr_t;
+// external flash is 32 bits in width
+typedef uint32_t ex_flash_addr_t;
+
+void wait(uint16_t t) {
+  for(; t > 0; t--);
+}
+enum {
+  VTHRESH = 0xE66, // 2.7V - threshold for reprogramming the node, if voltage is below, don't reprogram
+};
+
+// LEDs
+TOSH_ASSIGN_PIN(RED_LED2, 1, 5);               // on tinynode
+TOSH_ASSIGN_PIN(RED_LED, 1, 6);        // external
+TOSH_ASSIGN_PIN(GREEN_LED, 2, 3);
+TOSH_ASSIGN_PIN(YELLOW_LED, 2, 4);
+
+// FLASH at45db041
+TOSH_ASSIGN_PIN(FLASH_CS, 4, 7); // inverted
+TOSH_ASSIGN_PIN(FLASH_RESET, 4, 6); // inverted
+TOSH_ASSIGN_PIN(FLASH_CLK, 3, 3);
+TOSH_ASSIGN_PIN(FLASH_OUT, 3, 1); // MOSI - master OUT slave IN
+TOSH_ASSIGN_PIN(FLASH_IN, 3, 2); // MISO - master IN slave OUT
+
+void TOSH_SET_PIN_DIRECTIONS(void) {
+       
+       // FLASH at45db041
+  TOSH_SET_FLASH_CS_PIN(); // inverted 
+  TOSH_MAKE_FLASH_CS_OUTPUT();
+  TOSH_MAKE_FLASH_OUT_OUTPUT();
+  TOSH_MAKE_FLASH_CLK_OUTPUT();
+       TOSH_MAKE_FLASH_IN_INPUT();
+       TOSH_SET_FLASH_RESET_PIN(); // inverted
+       TOSH_MAKE_FLASH_RESET_OUTPUT();
+
+       // LEDs
+       TOSH_CLR_RED_LED2_PIN();
+       TOSH_CLR_RED_LED_PIN();
+       TOSH_CLR_YELLOW_LED_PIN();
+       TOSH_CLR_GREEN_LED_PIN();
+       TOSH_MAKE_RED_LED2_OUTPUT();            
+       TOSH_MAKE_RED_LED_OUTPUT();             
+       TOSH_MAKE_YELLOW_LED_OUTPUT();          
+       TOSH_MAKE_GREEN_LED_OUTPUT();           
+}
+
+#endif