From: R. Steve McKown Date: Mon, 7 Dec 2009 21:54:47 +0000 (-0700) Subject: Changes so this checkout exactly matches CVS at -r release_tinyos_2_0_2_2. X-Git-Tag: tinyos/2.0.2.2 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=b9d9b45472ac2b5043943979487ae619a70bf6e6 Changes so this checkout exactly matches CVS at -r release_tinyos_2_0_2_2. --- diff --git a/tos/lib/TOSBoot/Deluge.h b/tos/lib/TOSBoot/Deluge.h new file mode 100644 index 00000000..b6aa2873 --- /dev/null +++ b/tos/lib/TOSBoot/Deluge.h @@ -0,0 +1,142 @@ +// $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 + */ + +#ifndef __DELUGE_H__ +#define __DELUGE_H__ + +#include "DelugeMetadata.h" +#include "TOSBoot.h" + +#ifndef DELUGE_NUM_IMAGES +#define DELUGE_NUM_IMAGES 3 +#endif + +enum { + DELUGE_VERSION = 2, + DELUGE_MAX_ADV_PERIOD_LOG2 = 22, + DELUGE_NUM_NEWDATA_ADVS_REQUIRED = 2, + DELUGE_NUM_MIN_ADV_PERIODS = 2, + DELUGE_MAX_NUM_REQ_TRIES = 1, + DELUGE_REBOOT_DELAY = 4, + DELUGE_FAILED_SEND_DELAY = 16, + DELUGE_MIN_DELAY = 16, + DELUGE_PKTS_PER_PAGE = 48, + DELUGE_PKT_PAYLOAD_SIZE = 23, + DELUGE_DATA_OFFSET = 128, + DELUGE_IDENT_SIZE = 128, + DELUGE_INVALID_ADDR = (0x7fffffffL), + DELUGE_MAX_REQ_DELAY = (0x1L << (DELUGE_MIN_ADV_PERIOD_LOG2-1)), + DELUGE_NACK_TIMEOUT = (DELUGE_MAX_REQ_DELAY >> 0x1), + DELUGE_BYTES_PER_PAGE = (DELUGE_PKTS_PER_PAGE*DELUGE_PKT_PAYLOAD_SIZE), + DELUGE_PKT_BITVEC_SIZE = (((DELUGE_PKTS_PER_PAGE-1) / 8) + 1), + DELUGE_MAX_IMAGE_SIZE = (128L*1024L), + DELUGE_MAX_PAGES = 128, + DELUGE_CRC_SIZE = sizeof(uint16_t), + DELUGE_CRC_BLOCK_SIZE = DELUGE_MAX_PAGES*DELUGE_CRC_SIZE, + DELUGE_GOLDEN_IMAGE_NUM = 0x0, + DELUGE_INVALID_VNUM = -1, + DELUGE_INVALID_IMGNUM = 0xff, + DELUGE_INVALID_PKTNUM = 0xff, + DELUGE_INVALID_PGNUM = 0xff, +}; + +#include "Storage.h" + +struct deluge_image_t { + imgnum_t imageNum; + volume_id_t volumeId; +}; + +typedef struct DelugeAdvTimer { + uint32_t timer : 32; + uint8_t periodLog2 : 8; + bool overheard : 1; + uint8_t newAdvs : 7; +} DelugeAdvTimer; + +typedef struct DelugeNodeDesc { + imgvnum_t vNum; + uint32_t uid; + imgnum_t imgNum; + uint8_t reserved; + uint16_t crc; +} DelugeNodeDesc; + +enum { + DELUGE_VOLUME_ID_0 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 2 + DELUGE_VOLUME_ID_1 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 3 + DELUGE_VOLUME_ID_2 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 4 + DELUGE_VOLUME_ID_3 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 5 + DELUGE_VOLUME_ID_4 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 6 + DELUGE_VOLUME_ID_5 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 7 + DELUGE_VOLUME_ID_6 = unique("StorageManager"), +#if DELUGE_NUM_IMAGES >= 8 + DELUGE_VOLUME_ID_7 = unique("StorageManager"), +#endif +#endif +#endif +#endif +#endif +#endif +#endif +}; + +static const struct deluge_image_t DELUGE_IMAGES[DELUGE_NUM_IMAGES] = { + { DELUGE_VOLUME_ID_0, 0xDF }, +#if DELUGE_NUM_IMAGES >= 2 + { DELUGE_VOLUME_ID_1, 0xD0 }, +#if DELUGE_NUM_IMAGES >= 3 + { DELUGE_VOLUME_ID_2, 0xD1 }, +#if DELUGE_NUM_IMAGES >= 4 + { DELUGE_VOLUME_ID_3, 0xD2 }, +#if DELUGE_NUM_IMAGES >= 5 + { DELUGE_VOLUME_ID_4, 0xD3 }, +#if DELUGE_NUM_IMAGES >= 6 + { DELUGE_VOLUME_ID_5, 0xD4 }, +#if DELUGE_NUM_IMAGES >= 7 + { DELUGE_VOLUME_ID_6, 0xD5 }, +#if DELUGE_NUM_IMAGES >= 8 + { DELUGE_VOLUME_ID_7, 0xD6 }, +#endif +#endif +#endif +#endif +#endif +#endif +#endif +}; + +#endif diff --git a/tos/lib/TOSBoot/Exec.nc b/tos/lib/TOSBoot/Exec.nc new file mode 100644 index 00000000..3d42c0d9 --- /dev/null +++ b/tos/lib/TOSBoot/Exec.nc @@ -0,0 +1,4 @@ + +interface Exec { + command void exec(); +} diff --git a/tos/lib/TOSBoot/ExtFlash.nc b/tos/lib/TOSBoot/ExtFlash.nc new file mode 100644 index 00000000..a45e8e79 --- /dev/null +++ b/tos/lib/TOSBoot/ExtFlash.nc @@ -0,0 +1,35 @@ +// $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 + */ + +interface ExtFlash { + command void startRead(uint32_t addr); + command uint8_t readByte(); + command void stopRead(); +} diff --git a/tos/lib/TOSBoot/Hardware.nc b/tos/lib/TOSBoot/Hardware.nc new file mode 100644 index 00000000..879c0447 --- /dev/null +++ b/tos/lib/TOSBoot/Hardware.nc @@ -0,0 +1,34 @@ +// $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 + */ + +interface Hardware { + command void init(); + command void reboot(); +} diff --git a/tos/lib/TOSBoot/Leds.nc b/tos/lib/TOSBoot/Leds.nc new file mode 100644 index 00000000..c672d1be --- /dev/null +++ b/tos/lib/TOSBoot/Leds.nc @@ -0,0 +1,35 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +interface Leds { + command void set(uint8_t ledsOn); + command void flash(uint8_t a); + command void glow(uint8_t a, uint8_t b); +} diff --git a/tos/lib/TOSBoot/Makefile b/tos/lib/TOSBoot/Makefile new file mode 100644 index 00000000..56924184 --- /dev/null +++ b/tos/lib/TOSBoot/Makefile @@ -0,0 +1,72 @@ +# $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 +# + +COMPONENT=TOSBoot +TINYOS_NP= + +PFLAGS += -DNESC_BUILD_BINARY + +# ifeq ($(MAKECMDGOALS),mica2) +# CFLAGS += -DTOSBOOT_START=0x1f000 -DTOSBOOT_END=0x20000 +# CFLAGS += -Wl,--section-start=.text=0x1f000 +# CFLAGS += -Iat45db -Iavr -Imica2 -Ilib +# endif + +# ifeq ($(MAKECMDGOALS),mica2dot) +# CFLAGS += -DTOSBOOT_START=0x1f000 -DTOSBOOT_END=0x20000 +# CFLAGS += -Wl,--section-start=.text=0x1f000 +# CFLAGS += -Iat45db -Iavr -Imica2dot -Ilib +# endif + +ifeq ($(MAKECMDGOALS),micaz) + CFLAGS += -DTOSBOOT_START=0x1f000 -DTOSBOOT_END=0x20000 + CFLAGS += -Wl,--section-start=.text=0x1f000 + CFLAGS += -Iat45db -Iavr -Imicaz -Ilib + CFLAGS += -I../net/Deluge +endif + +# ifeq ($(MAKECMDGOALS),telosa) +# CFLAGS += -DTOSBOOT_START=0x1100 -DTOSBOOT_END=0x1a00 +# CFLAGS += -Iat45db -Imsp430 -Itelos -Ilib +# POST_BUILD_EXTRA_DEPS += strip_iv +# endif + +ifeq ($(MAKECMDGOALS),telosb) + CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00 + CFLAGS += -Imsp430 -Istm25p -Itelosb -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 + +include $(MAKERULES) diff --git a/tos/lib/TOSBoot/ProgFlash.nc b/tos/lib/TOSBoot/ProgFlash.nc new file mode 100644 index 00000000..6b67bbb1 --- /dev/null +++ b/tos/lib/TOSBoot/ProgFlash.nc @@ -0,0 +1,33 @@ +// $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 + */ + +interface ProgFlash { + command error_t write(in_flash_addr_t addr, uint8_t* buf, in_flash_addr_t len); +} diff --git a/tos/lib/TOSBoot/TOSBoot.h b/tos/lib/TOSBoot/TOSBoot.h new file mode 100644 index 00000000..ab5524b5 --- /dev/null +++ b/tos/lib/TOSBoot/TOSBoot.h @@ -0,0 +1,39 @@ +// $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 + */ + +#ifndef __TOSBOOT_H__ +#define __TOSBOOT_H__ + +#include "TOSBoot_platform.h" + +typedef struct tosboot_args_t { + uint32_t imageAddr; + uint8_t gestureCount; + bool noReprogram; +} tosboot_args_t; + +#endif diff --git a/tos/lib/TOSBoot/TOSBoot.nc b/tos/lib/TOSBoot/TOSBoot.nc new file mode 100644 index 00000000..d08429b7 --- /dev/null +++ b/tos/lib/TOSBoot/TOSBoot.nc @@ -0,0 +1,61 @@ +// $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 + */ + +includes Deluge; +includes TOSBoot; + +configuration TOSBoot { +} +implementation { + + components + TOSBootM, + ExecC, + ExtFlashC, + HardwareC, + InternalFlashC as IntFlash, + LedsC, + PluginC, + ProgFlashM as ProgFlash, + VoltageC; + + TOSBootM.SubInit -> ExtFlashC; + TOSBootM.SubControl -> ExtFlashC.StdControl; + TOSBootM.SubControl -> PluginC; + + TOSBootM.Exec -> ExecC; + TOSBootM.ExtFlash -> ExtFlashC; + TOSBootM.Hardware -> HardwareC; + TOSBootM.IntFlash -> IntFlash; + TOSBootM.Leds -> LedsC; + TOSBootM.ProgFlash -> ProgFlash; + TOSBootM.Voltage -> VoltageC; + +} diff --git a/tos/lib/TOSBoot/TOSBootM.nc b/tos/lib/TOSBoot/TOSBootM.nc new file mode 100644 index 00000000..b5098a1a --- /dev/null +++ b/tos/lib/TOSBoot/TOSBootM.nc @@ -0,0 +1,259 @@ +/* + * "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." + * + * Copyright (c) 2007 Johns Hopkins University. + * All rights reserved. + * + */ + +/** + * @author Jonathan Hui + * @author Chieh-Jan Mike Liang + * @author Razvan Musaloiu-E. + */ + +includes crc; +includes hardware; + +module TOSBootM { + uses { + interface Exec; + interface ExtFlash; + interface Hardware; + interface InternalFlash as IntFlash; + interface Leds; + interface ProgFlash; + interface StdControl as SubControl; + interface Init as SubInit; + interface Voltage; + } +} +implementation { + + enum { + LEDS_LOWBATT = 1, + LEDS_GESTURE = 7, + }; + + enum { + R_SUCCESS, + R_INVALID_IMAGE_ERROR, + R_PROGRAMMING_ERROR, + }; + + void startupLeds() { + + uint8_t output = 0x7; + uint8_t i; + + for (i = 3; i; i--, output >>= 1 ) + call Leds.glow(output, output >> 1); + + } + + in_flash_addr_t extFlashReadAddr() { + in_flash_addr_t result = 0; + uint8_t i; + for ( i = 0; i < 4; i++ ) + result |= ((in_flash_addr_t)call ExtFlash.readByte() & 0xff) << (i*8); + return result; + } + + bool verifyImage(ex_flash_addr_t startAddr) { + + uint16_t crcTarget = 0, crcTmp = 0; + uint16_t addr, len; + pgnum_t numPgs; + uint8_t i; + + // read size of image + call ExtFlash.startRead(startAddr + offsetof(DelugeImgDesc,numPgs)); + numPgs = call ExtFlash.readByte(); + call ExtFlash.stopRead(); + + if (numPgs == 0 || numPgs == 0xff) + return FALSE; + + startAddr += DELUGE_METADATA_SIZE; + + addr = DELUGE_CRC_BLOCK_SIZE; + len = DELUGE_BYTES_PER_PAGE-DELUGE_CRC_BLOCK_SIZE; + + for ( i = 0; i < numPgs && crcTarget == crcTmp; i++ ) { + + // read crc + call ExtFlash.startRead(startAddr + i*sizeof(uint16_t)); + crcTarget = (uint16_t)(call ExtFlash.readByte() & 0xff); + crcTarget |= (uint16_t)(call ExtFlash.readByte() & 0xff) << 8; + call ExtFlash.stopRead(); + + // compute crc + call ExtFlash.startRead(startAddr + addr); + for ( crcTmp = 0; len; len-- ) + crcTmp = crcByte(crcTmp, call ExtFlash.readByte()); + call ExtFlash.stopRead(); + + addr = (uint16_t)(i+1)*DELUGE_BYTES_PER_PAGE; + len = DELUGE_BYTES_PER_PAGE; + } + + return (i == numPgs) && (crcTarget == crcTmp); + } + + error_t programImage(ex_flash_addr_t startAddr) { + + uint8_t buf[TOSBOOT_INT_PAGE_SIZE]; + uint16_t pageAddr, newPageAddr; + in_flash_addr_t intAddr; + in_flash_addr_t secLength; + ex_flash_addr_t curAddr; + + if (!verifyImage(startAddr)) + return R_INVALID_IMAGE_ERROR; + + curAddr = startAddr + DELUGE_METADATA_SIZE + DELUGE_CRC_BLOCK_SIZE + DELUGE_IDENT_SIZE; + + call ExtFlash.startRead(curAddr); + + intAddr = extFlashReadAddr(); + secLength = extFlashReadAddr(); + curAddr = curAddr + 8; + + // check that the image starts on the correct boundary + if (intAddr != TOSBOOT_END) { + call ExtFlash.stopRead(); + return R_INVALID_IMAGE_ERROR; + } + + while ( secLength ) { + + pageAddr = newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE; + + call ExtFlash.startRead(curAddr); + // fill in ram buffer for internal program flash sector + do { + + // check if secLength is all ones + if ( secLength == 0xffffffff ) + return FAIL; + + buf[(uint16_t)intAddr % TOSBOOT_INT_PAGE_SIZE] = call ExtFlash.readByte(); + intAddr++; curAddr++; + + if ( --secLength == 0 ) { + intAddr = extFlashReadAddr(); + secLength = extFlashReadAddr(); + curAddr = curAddr + 8; + } + + newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE; + + } while ( pageAddr == newPageAddr && secLength ); + call ExtFlash.stopRead(); + + call Leds.set(pageAddr); + + + // write out page + if (call ProgFlash.write(pageAddr*TOSBOOT_INT_PAGE_SIZE, buf, + TOSBOOT_INT_PAGE_SIZE) == FAIL) + return R_PROGRAMMING_ERROR; + + } + + return R_SUCCESS; + + } + + void runApp() { + call SubControl.stop(); + call Exec.exec(); + } + + void startupSequence() { + + tosboot_args_t args; + + // check voltage and make sure flash can be programmed + // if not, just run the app, can't check for gestures + // if we can't write to the internal flash anyway + if ( !call Voltage.okToProgram() ) { + // give user some time and count down LEDs + call Leds.flash(LEDS_LOWBATT); + startupLeds(); + runApp(); + } + + // get current value of counter + call IntFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args)); + + // increment gesture counter, see if it exceeds threshold + if ( ++args.gestureCount >= TOSBOOT_GESTURE_MAX_COUNT - 1 ) { + // gesture has been detected, display receipt of gesture on LEDs + call Leds.flash(LEDS_GESTURE); + + // load golden image from flash + // 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) + call Hardware.reboot(); + } + else { + // update gesture counter + call IntFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args)); + if ( !args.noReprogram ) { + // if an error happened during reprogramming, reboot and try again + // after two tries, try programming the golden image + if (programImage(args.imageAddr) == R_PROGRAMMING_ERROR) { + call Hardware.reboot(); + } + } + } + + // give user some time and count down LEDs + startupLeds(); + + // reset counter and reprogramming flag + args.gestureCount = 0xff; + args.noReprogram = TRUE; + call IntFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args)); + + runApp(); + + } + + int main() __attribute__ ((C, spontaneous)) { + + __nesc_disable_interrupt(); + + TOSH_SET_PIN_DIRECTIONS(); + call Hardware.init(); + + call SubInit.init(); + call SubControl.start(); + + startupSequence(); + + return 0; + + } + +} diff --git a/tos/lib/TOSBoot/Voltage.nc b/tos/lib/TOSBoot/Voltage.nc new file mode 100644 index 00000000..de4bbec1 --- /dev/null +++ b/tos/lib/TOSBoot/Voltage.nc @@ -0,0 +1,33 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +interface Voltage { + command bool okToProgram(); +} diff --git a/tos/lib/TOSBoot/at45db/ExtFlashC.nc b/tos/lib/TOSBoot/at45db/ExtFlashC.nc new file mode 100644 index 00000000..1d5d3c85 --- /dev/null +++ b/tos/lib/TOSBoot/at45db/ExtFlashC.nc @@ -0,0 +1,126 @@ +// $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 + */ + +module ExtFlashC { + provides { + interface Init; + interface StdControl; + interface ExtFlash; + } +} + +implementation { + + uint32_t addr; + + command error_t Init.init() { + TOSH_MAKE_FLASH_CS_OUTPUT(); + TOSH_SET_FLASH_CS_PIN(); + TOSH_MAKE_FLASH_CLK_OUTPUT(); + TOSH_CLR_FLASH_CLK_PIN(); + TOSH_MAKE_FLASH_OUT_OUTPUT(); + TOSH_SET_FLASH_OUT_PIN(); + TOSH_MAKE_FLASH_IN_INPUT(); + TOSH_CLR_FLASH_IN_PIN(); + return SUCCESS; + } + + command error_t StdControl.start() { return SUCCESS; } + command error_t StdControl.stop() { return SUCCESS; } + + 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; + + } + + command void ExtFlash.startRead(uint32_t newAddr) { + + uint8_t cmdBuf[4]; + uint8_t i; + + addr = newAddr; + + cmdBuf[0] = 0x68; + cmdBuf[1] = (addr >> 15) & 0xff; + cmdBuf[2] = (addr >> 7) & 0xfe; + cmdBuf[3] = addr & 0xff; + + TOSH_CLR_FLASH_CLK_PIN(); + TOSH_CLR_FLASH_CS_PIN(); + + for(i = 0; i < 4; i++) + SPIByte(cmdBuf[i]); + for(i = 0; i < 4; i++) + SPIByte(0x0); + + TOSH_SET_FLASH_CLK_PIN(); + TOSH_CLR_FLASH_CLK_PIN(); + + } + + command uint8_t ExtFlash.readByte() { + if (!(addr & 0xff)) { + call ExtFlash.stopRead(); + call ExtFlash.startRead(addr); + } + addr++; + return SPIByte(0); + } + + command void ExtFlash.stopRead() { + TOSH_SET_FLASH_CS_PIN(); + } + +} diff --git a/tos/lib/TOSBoot/avr/HardwareC.nc b/tos/lib/TOSBoot/avr/HardwareC.nc new file mode 100644 index 00000000..c48c89bc --- /dev/null +++ b/tos/lib/TOSBoot/avr/HardwareC.nc @@ -0,0 +1,46 @@ +// $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 + */ + +module HardwareC { + provides { + interface Hardware; + } +} + +implementation { + + command void Hardware.init() {} + + command void Hardware.reboot() { + wdt_enable(1); + while(1); + } + +} diff --git a/tos/lib/TOSBoot/avr/InternalFlashC.nc b/tos/lib/TOSBoot/avr/InternalFlashC.nc new file mode 100644 index 00000000..1d6d8fb8 --- /dev/null +++ b/tos/lib/TOSBoot/avr/InternalFlashC.nc @@ -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 + */ + +includes InternalFlash; + +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/TOSBoot/avr/ProgFlashM.nc b/tos/lib/TOSBoot/avr/ProgFlashM.nc new file mode 100644 index 00000000..8bada2d6 --- /dev/null +++ b/tos/lib/TOSBoot/avr/ProgFlashM.nc @@ -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 + */ + +module ProgFlashM { + provides { + interface ProgFlash; + } +} + +implementation { + +#include + + command error_t ProgFlash.write(in_flash_addr_t addr, uint8_t* buf, in_flash_addr_t len) { + + uint16_t* wordBuf = (uint16_t*)buf; + uint32_t i; + + if ( addr + len > TOSBOOT_START ) + return FAIL; + + boot_page_erase( addr ); + while( boot_rww_busy() ) + boot_rww_enable(); + + for ( i = 0; i < len; i += 2 ) + boot_page_fill( addr + i, *wordBuf++ ); + + boot_page_write( addr ); + + while ( boot_rww_busy() ) + boot_rww_enable(); + + return SUCCESS; + + } + +} diff --git a/tos/lib/TOSBoot/avr/boot.h b/tos/lib/TOSBoot/avr/boot.h new file mode 100644 index 00000000..08c89ce1 --- /dev/null +++ b/tos/lib/TOSBoot/avr/boot.h @@ -0,0 +1,498 @@ +/* Copyright (c) 2002, 2003, 2004 Eric B. Weddington + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef _AVR_BOOT_H_ +#define _AVR_BOOT_H_ 1 + +/** \defgroup avr_boot Bootloader Support Utilities + \code + #include + #include + \endcode + + The macros in this module provide a C language interface to the + bootloader support functionality of certain AVR processors. These + macros are designed to work with all sizes of flash memory. + + \note Not all AVR processors provide bootloader support. See your + processor datasheet to see if it provides bootloader support. + + \todo From email with Marek: On smaller devices (all except ATmega64/128), + __SPM_REG is in the I/O space, accessible with the shorter "in" and "out" + instructions - since the boot loader has a limited size, this could be an + important optimization. + + \par API Usage Example + The following code shows typical usage of the boot API. + + \code + #include + #include + + #define ADDRESS 0x1C000UL + + void boot_test(void) + { + unsigned char buffer[8]; + + cli(); + + // Erase page. + boot_page_erase((unsigned long)ADDRESS); + while(boot_rww_busy()) + { + boot_rww_enable(); + } + + // Write data to buffer a word at a time. Note incrementing address + // by 2. SPM_PAGESIZE is defined in the microprocessor IO header file. + for(unsigned long i = ADDRESS; i < ADDRESS + SPM_PAGESIZE; i += 2) + { + boot_page_fill(i, (i-ADDRESS) + ((i-ADDRESS+1) << 8)); + } + + // Write page. + boot_page_write((unsigned long)ADDRESS); + while(boot_rww_busy()) + { + boot_rww_enable(); + } + + sei(); + + // Read back the values and display. + // (The show() function is undefined and is used here as an example + // only.) + for(unsigned long i = ADDRESS; i < ADDRESS + 256; i++) + { + show(utoa(pgm_read_byte(i), buffer, 16)); + } + + return; + }\endcode */ + +#include +#include +#include +#include + +/* Check for SPM Control Register in processor. */ +#if defined (SPMCSR) +# define __SPM_REG SPMCSR +#elif defined (SPMCR) +# define __SPM_REG SPMCR +#else +# error AVR processor does not provide bootloader support! +#endif + +/** \ingroup avr_boot + \def BOOTLOADER_SECTION + + Used to declare a function or variable to be placed into a + new section called .bootloader. This section and its contents + can then be relocated to any address (such as the bootloader + NRWW area) at link-time. */ + +#define BOOTLOADER_SECTION __attribute__ ((section (".bootloader"))) + +/* Create common bit definitions. */ +#ifdef ASB +#define __COMMON_ASB ASB +#else +#define __COMMON_ASB RWWSB +#endif + +#ifdef ASRE +#define __COMMON_ASRE ASRE +#else +#define __COMMON_ASRE RWWSRE +#endif + +/* Define the bit positions of the Boot Lock Bits. */ + +#define BLB12 5 +#define BLB11 4 +#define BLB02 3 +#define BLB01 2 + +/** \ingroup avr_boot + \def boot_spm_interrupt_enable() + Enable the SPM interrupt. */ + +#define boot_spm_interrupt_enable() (__SPM_REG |= (uint8_t)_BV(SPMIE)) + +/** \ingroup avr_boot + \def boot_spm_interrupt_disable() + Disable the SPM interrupt. */ + +#define boot_spm_interrupt_disable() (__SPM_REG &= (uint8_t)~_BV(SPMIE)) + +/** \ingroup avr_boot + \def boot_is_spm_interrupt() + Check if the SPM interrupt is enabled. */ + +#define boot_is_spm_interrupt() (__SPM_REG & (uint8_t)_BV(SPMIE)) + +/** \ingroup avr_boot + \def boot_rww_busy() + Check if the RWW section is busy. */ + +#define boot_rww_busy() (__SPM_REG & (uint8_t)_BV(__COMMON_ASB)) + +/** \ingroup avr_boot + \def boot_spm_busy() + Check if the SPM instruction is busy. */ + +#define boot_spm_busy() (__SPM_REG & (uint8_t)_BV(SPMEN)) + +/** \ingroup avr_boot + \def boot_spm_busy_wait() + Wait while the SPM instruction is busy. */ + +#define boot_spm_busy_wait() do{}while(boot_spm_busy()) + +#define __BOOT_PAGE_ERASE (_BV(SPMEN) | _BV(PGERS)) +#define __BOOT_PAGE_WRITE (_BV(SPMEN) | _BV(PGWRT)) +#define __BOOT_PAGE_FILL _BV(SPMEN) +#define __BOOT_RWW_ENABLE (_BV(SPMEN) | _BV(__COMMON_ASRE)) +#define __BOOT_LOCK_BITS_SET (_BV(SPMEN) | _BV(BLBSET)) + +#define __BOOT_LOCK_BITS_MASK (_BV(BLB01) | _BV(BLB02) \ + | _BV(BLB11) | _BV(BLB12)) + +#define eeprom_busy_wait() do {} while (!eeprom_is_ready()) + +#define __boot_page_fill_normal(address, data) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r0, %3\n\t" \ + "movw r30, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + "clr r1\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_PAGE_FILL), \ + "r" ((uint16_t)address), \ + "r" ((uint16_t)data) \ + : "r0", "r30", "r31" \ + ); \ +}) + +#define __boot_page_fill_alternate(address, data)\ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r0, %3\n\t" \ + "movw r30, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + ".word 0xffff\n\t" \ + "nop\n\t" \ + "clr r1\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_PAGE_FILL), \ + "r" ((uint16_t)address), \ + "r" ((uint16_t)data) \ + : "r0", "r30", "r31" \ + ); \ +}) + +#define __boot_page_fill_extended(address, data) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r0, %4\n\t" \ + "movw r30, %A3\n\t" \ + "sts %1, %C3\n\t" \ + "sts %0, %2\n\t" \ + "spm\n\t" \ + "clr r1\n\t" \ + : "=m" (__SPM_REG), \ + "=m" (RAMPZ) \ + : "r" ((uint8_t)__BOOT_PAGE_FILL), \ + "r" ((uint32_t)address), \ + "r" ((uint16_t)data) \ + : "r0", "r30", "r31" \ + ); \ +}) + +#define __boot_page_erase_normal(address) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r30, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_PAGE_ERASE), \ + "r" ((uint16_t)address) \ + : "r30", "r31" \ + ); \ +}) + +#define __boot_page_erase_alternate(address) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r30, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + ".word 0xffff\n\t" \ + "nop\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_PAGE_ERASE), \ + "r" ((uint16_t)address) \ + : "r30", "r31" \ + ); \ +}) + +#define __boot_page_erase_extended(address) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r30, %A3\n\t" \ + "sts %1, %C3\n\t" \ + "sts %0, %2\n\t" \ + "spm\n\t" \ + : "=m" (__SPM_REG), \ + "=m" (RAMPZ) \ + : "r" ((uint8_t)__BOOT_PAGE_ERASE), \ + "r" ((uint32_t)address) \ + : "r30", "r31" \ + ); \ +}) + +#define __boot_page_write_normal(address) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r30, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_PAGE_WRITE), \ + "r" ((uint16_t)address) \ + : "r30", "r31" \ + ); \ +}) + +#define __boot_page_write_alternate(address) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r30, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + ".word 0xffff\n\t" \ + "nop\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_PAGE_WRITE), \ + "r" ((uint16_t)address) \ + : "r30", "r31" \ + ); \ +}) + +#define __boot_page_write_extended(address) \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "movw r30, %A3\n\t" \ + "sts %1, %C3\n\t" \ + "sts %0, %2\n\t" \ + "spm\n\t" \ + : "=m" (__SPM_REG), \ + "=m" (RAMPZ) \ + : "r" ((uint8_t)__BOOT_PAGE_WRITE), \ + "r" ((uint32_t)address) \ + : "r30", "r31" \ + ); \ +}) + +#define __boot_rww_enable() \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_RWW_ENABLE) \ + ); \ +}) + +#define __boot_rww_enable_alternate() \ +({ \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + ".word 0xffff\n\t" \ + "nop\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_RWW_ENABLE) \ + ); \ +}) + +#define __boot_lock_bits_set(lock_bits) \ +({ \ + uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "ldi r30, 1\n\t" \ + "ldi r31, 0\n\t" \ + "mov r0, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ + "r" (value) \ + : "r0", "r30", "r31" \ + ); \ +}) + +#define __boot_lock_bits_set_alternate(lock_bits) \ +({ \ + uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \ + boot_spm_busy_wait(); \ + eeprom_busy_wait(); \ + __asm__ __volatile__ \ + ( \ + "ldi r30, 1\n\t" \ + "ldi r31, 0\n\t" \ + "mov r0, %2\n\t" \ + "sts %0, %1\n\t" \ + "spm\n\t" \ + ".word 0xffff\n\t" \ + "nop\n\t" \ + : "=m" (__SPM_REG) \ + : "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ + "r" (value) \ + : "r0", "r30", "r31" \ + ); \ +}) + +/** \ingroup avr_boot + \def boot_page_fill(address, data) + + Fill the bootloader temporary page buffer for flash + address with data word. + + \note The address is a byte address. The data is a word. The AVR + writes data to the buffer a word at a time, but addresses the buffer + per byte! So, increment your address by 2 between calls, and send 2 + data bytes in a word format! The LSB of the data is written to the lower + address; the MSB of the data is written to the higher address.*/ + +/** \ingroup avr_boot + \def boot_page_erase(address) + + Erase the flash page that contains address. + + \note address is a byte address in flash, not a word address. */ + +/** \ingroup avr_boot + \def boot_page_write(address) + + Write the bootloader temporary page buffer + to flash page that contains address. + + \note address is a byte address in flash, not a word address. */ + +/** \ingroup avr_boot + \def boot_rww_enable() + + Enable the Read-While-Write memory section. */ + +/** \ingroup avr_boot + \def boot_lock_bits_set(lock_bits) + + Set the bootloader lock bits. */ + +/* Normal versions of the macros use 16-bit addresses. + Extended versions of the macros use 32-bit addresses. + Alternate versions of the macros use 16-bit addresses and require special + instruction sequences after LPM. + + FLASHEND is defined in the ioXXXX.h file. + USHRT_MAX is defined in . */ + +#if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \ + || defined(__AVR_ATmega323__) + +/* Alternate: ATmega161/163/323 and 16 bit address */ +#define boot_page_fill(address, data) __boot_page_fill_alternate(address, data) +#define boot_page_erase(address) __boot_page_erase_alternate(address) +#define boot_page_write(address) __boot_page_write_alternate(address) +#define boot_rww_enable() __boot_rww_enable_alternate() +#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits) + +#elif (FLASHEND > USHRT_MAX) && !defined(__USING_MINT8) + +/* Extended: >16 bit address */ +#define boot_page_fill(address, data) __boot_page_fill_extended(address, data) +#define boot_page_erase(address) __boot_page_erase_extended(address) +#define boot_page_write(address) __boot_page_write_extended(address) +#define boot_rww_enable() __boot_rww_enable() +#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set(lock_bits) + +#else + +/* Normal: 16 bit address */ +#define boot_page_fill(address, data) __boot_page_fill_normal(address, data) +#define boot_page_erase(address) __boot_page_erase_normal(address) +#define boot_page_write(address) __boot_page_write_normal(address) +#define boot_rww_enable() __boot_rww_enable() +#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set(lock_bits) + +#endif + +#endif /* _AVR_BOOT_H_ */ diff --git a/tos/lib/TOSBoot/crc.h b/tos/lib/TOSBoot/crc.h new file mode 100644 index 00000000..64391d3d --- /dev/null +++ b/tos/lib/TOSBoot/crc.h @@ -0,0 +1,56 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2003 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." + * + * Copyright (c) 2002-2003 Intel Corporation + * All rights reserved. + * + * This file is distributed under the terms in the attached INTEL-LICENSE + * file. If you do not find these files, copies can be found by writing to + * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, + * 94704. Attention: Intel License Inquiry. + */ + +/** + * Default CRC function. Note that avrmote has a much more efficient one. + * + * This CRC-16 function produces a 16-bit running CRC that adheres to the + * ITU-T CRC standard. + * + * The ITU-T polynomial is: G_16(x) = x^16 + x^12 + x^5 + 1 + * + */ + +uint16_t crcByte(uint16_t crc, uint8_t b) +{ + uint8_t i; + + crc = crc ^ b << 8; + i = 8; + do + if (crc & 0x8000) + crc = crc << 1 ^ 0x1021; + else + crc = crc << 1; + while (--i); + + return crc; +} diff --git a/tos/lib/TOSBoot/lib/ExecC.nc b/tos/lib/TOSBoot/lib/ExecC.nc new file mode 100644 index 00000000..f29fb8c9 --- /dev/null +++ b/tos/lib/TOSBoot/lib/ExecC.nc @@ -0,0 +1,45 @@ +// $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 + */ + +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/lib/LedsC.nc b/tos/lib/TOSBoot/lib/LedsC.nc new file mode 100644 index 00000000..476f76e0 --- /dev/null +++ b/tos/lib/TOSBoot/lib/LedsC.nc @@ -0,0 +1,80 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +module LedsC { + provides interface Leds; +} + +implementation { + + enum { + RED_BIT = 1, + GREEN_BIT = 2, + YELLOW_BIT = 4 + }; + + command void Leds.set(uint8_t ledsOn) { + if (ledsOn & GREEN_BIT) + TOSH_CLR_GREEN_LED_PIN(); + else + TOSH_SET_GREEN_LED_PIN(); + if (ledsOn & YELLOW_BIT ) + TOSH_CLR_YELLOW_LED_PIN(); + else + TOSH_SET_YELLOW_LED_PIN(); + if (ledsOn & RED_BIT) + TOSH_CLR_RED_LED_PIN(); + else + TOSH_SET_RED_LED_PIN(); + } + + command void Leds.flash(uint8_t a) { + uint8_t i, j; + for ( i = 3; i; i-- ) { + call Leds.set(a); + for ( j = 4; j; j-- ) + wait(0xffff); + call Leds.set(0); + for ( j = 4; j; j-- ) + wait(0xffff); + } + } + + command void Leds.glow(uint8_t a, uint8_t b) { + int i; + for (i = 1536; i > 0; i -= 4) { + call Leds.set(a); + wait(i); + call Leds.set(b); + wait(1536-i); + } + } + +} diff --git a/tos/lib/TOSBoot/micaz/ExecC.nc b/tos/lib/TOSBoot/micaz/ExecC.nc new file mode 100644 index 00000000..dc789acf --- /dev/null +++ b/tos/lib/TOSBoot/micaz/ExecC.nc @@ -0,0 +1,40 @@ +// $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 + */ + +module ExecC { + provides { + interface Exec; + } +} + +implementation { + + command void Exec.exec() { + __asm__ __volatile__ ("jmp 0x0000\n\t" ::); + } + +} diff --git a/tos/lib/TOSBoot/micaz/InternalFlash.h b/tos/lib/TOSBoot/micaz/InternalFlash.h new file mode 100644 index 00000000..01f69e80 --- /dev/null +++ b/tos/lib/TOSBoot/micaz/InternalFlash.h @@ -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 + */ + +#ifndef __INTERNAL_FLASH_H__ +#define __INTERNAL_FLASH_H__ + +#include + +#endif diff --git a/tos/lib/TOSBoot/micaz/PluginC.nc b/tos/lib/TOSBoot/micaz/PluginC.nc new file mode 100644 index 00000000..237998ed --- /dev/null +++ b/tos/lib/TOSBoot/micaz/PluginC.nc @@ -0,0 +1,13 @@ + +module PluginC { + provides { + interface StdControl; + } +} + +implementation { + + command error_t StdControl.start() { return SUCCESS; } + command error_t StdControl.stop() { return SUCCESS; } + +} diff --git a/tos/lib/TOSBoot/micaz/TOSBoot_platform.h b/tos/lib/TOSBoot/micaz/TOSBoot_platform.h new file mode 100644 index 00000000..e18285e7 --- /dev/null +++ b/tos/lib/TOSBoot/micaz/TOSBoot_platform.h @@ -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 + */ + +#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 diff --git a/tos/lib/TOSBoot/micaz/VoltageC.nc b/tos/lib/TOSBoot/micaz/VoltageC.nc new file mode 100644 index 00000000..85b8f103 --- /dev/null +++ b/tos/lib/TOSBoot/micaz/VoltageC.nc @@ -0,0 +1,58 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +module VoltageC { + provides { + interface Voltage; + } +} + +implementation { + + command bool Voltage.okToProgram() { + + // 250 KHz ADC clock (4MHz/16) + outp( 0x04, ADCSR ); + // clear interrupt flag by writing a 1 + sbi( ADCSR, ADIF ); + // setup input channel + outp( VOLTAGE_PORT, ADMUX ); + // adc enable + sbi( ADCSR, ADEN ); + // adc start conversion + sbi( ADCSR, ADSC ); + // wait for conversion to complete + while ( !bit_is_set( ADCSR, ADIF ) ); + + return ( __inw(ADCL) < VTHRESH ); + + } + +} diff --git a/tos/lib/TOSBoot/micaz/avrhardware.h b/tos/lib/TOSBoot/micaz/avrhardware.h new file mode 100644 index 00000000..4263d56b --- /dev/null +++ b/tos/lib/TOSBoot/micaz/avrhardware.h @@ -0,0 +1,196 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2003 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." + * + * Copyright (c) 2002-2003 Intel Corporation + * All rights reserved. + * + * This file is distributed under the terms in the attached INTEL-LICENSE + * file. If you do not find these files, copies can be found by writing to + * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, + * 94704. Attention: Intel License Inquiry. + */ +/* + * + * Authors: Jason Hill, Philip Levis, Nelson Lee + * + * + */ + +/** + * @author Jason Hill + * @author Philip Levis + * @author Nelson Lee + */ + + +#ifndef TOSH_AVRHARDWARE_H +#define TOSH_AVRHARDWARE_H + +// check for a new-look avr-libc +#if defined(DTOSTR_ALWAYS_SIGN) && !defined(TOSH_NEW_AVRLIBC) +#define TOSH_NEW_AVRLIBC +#endif + +#ifdef TOSH_NEW_AVRLIBC +#include +#include +#include +#include +#include +#include + +#ifndef sbi +/* avr-libc 1.2.3 doesn't include these anymore. */ +#define sbi(port, bit) ((port) |= _BV(bit)) +#define cbi(port, bit) ((port) &= ~_BV(bit)) +#define inp(port) (port) +#define inb(port) (port) +#define outp(value, port) ((port) = (value)) +#define outb(port, value) ((port) = (value)) +#define inw(port) (*(volatile uint16_t *)&(port)) +#define outw(port, value) ((*(volatile uint16_t *)&(port)) = (value)) +#define PRG_RDB(addr) pgm_read_byte(addr) +#endif + +#else +#include +#include +#include +#include +#include +#endif /* TOSH_NEW_AVRLIBC */ + +// check for version 3.3 of GNU gcc or later +#if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) +#define __outw(val, port) outw(port, val); +#endif + +#ifndef __inw +#ifndef __SFR_OFFSET +#define __SFR_OFFSET 0 +#endif /* !__SFR_OFFSET */ +#define __inw(_port) inw(_port) + +#define __inw_atomic(__sfrport) ({ \ + uint16_t __t; \ + bool bStatus; \ + bStatus = bit_is_set(SREG,7); \ + cli(); \ + __t = inw(__sfrport); \ + if (bStatus) sei(); \ + __t; \ + }) + +#endif /* __inw */ + +#define TOSH_ASSIGN_PIN(name, port, bit) \ +static inline void TOSH_SET_##name##_PIN() {sbi(PORT##port , bit);} \ +static inline void TOSH_CLR_##name##_PIN() {cbi(PORT##port , bit);} \ +static inline int TOSH_READ_##name##_PIN() \ + {return (inp(PIN##port) & (1 << bit)) != 0;} \ +static inline void TOSH_MAKE_##name##_OUTPUT() {sbi(DDR##port , bit);} \ +static inline void TOSH_MAKE_##name##_INPUT() {cbi(DDR##port , bit);} + +#define TOSH_ASSIGN_OUTPUT_ONLY_PIN(name, port, bit) \ +static inline void TOSH_SET_##name##_PIN() {sbi(PORT##port , bit);} \ +static inline void TOSH_CLR_##name##_PIN() {cbi(PORT##port , bit);} \ +static inline void TOSH_MAKE_##name##_OUTPUT() {;} + +#define TOSH_ALIAS_OUTPUT_ONLY_PIN(alias, connector)\ +static inline void TOSH_SET_##alias##_PIN() {TOSH_SET_##connector##_PIN();} \ +static inline void TOSH_CLR_##alias##_PIN() {TOSH_CLR_##connector##_PIN();} \ +static inline void TOSH_MAKE_##alias##_OUTPUT() {} \ + +#define TOSH_ALIAS_PIN(alias, connector) \ +static inline void TOSH_SET_##alias##_PIN() {TOSH_SET_##connector##_PIN();} \ +static inline void TOSH_CLR_##alias##_PIN() {TOSH_CLR_##connector##_PIN();} \ +static inline char TOSH_READ_##alias##_PIN() {return TOSH_READ_##connector##_PIN();} \ +static inline void TOSH_MAKE_##alias##_OUTPUT() {TOSH_MAKE_##connector##_OUTPUT();} \ +static inline void TOSH_MAKE_##alias##_INPUT() {TOSH_MAKE_##connector##_INPUT();} + +// We need slightly different defs than SIGNAL, INTERRUPT +#define TOSH_SIGNAL(signame) \ +void signame() __attribute__ ((signal, spontaneous, C)) + +#define TOSH_INTERRUPT(signame) \ +void signame() __attribute__ ((interrupt, spontaneous, C)) + +/* Watchdog Prescaler + */ +enum { + TOSH_period16 = 0x00, // 47ms + TOSH_period32 = 0x01, // 94ms + TOSH_period64 = 0x02, // 0.19s + TOSH_period128 = 0x03, // 0.38s + TOSH_period256 = 0x04, // 0.75s + TOSH_period512 = 0x05, // 1.5s + TOSH_period1024 = 0x06, // 3.0s + TOSH_period2048 = 0x07 // 6.0s +}; + +void TOSH_wait() +{ + asm volatile("nop"); + asm volatile("nop"); +} + +// atomic statement runtime support + +/* typedef uint8_t __nesc_atomic_t; */ + +/* __nesc_atomic_t __nesc_atomic_start(void); */ +/* void __nesc_atomic_end(__nesc_atomic_t oldSreg); */ + +/* #ifndef NESC_BUILD_BINARY */ + +/* inline __nesc_atomic_t __nesc_atomic_start(void) __attribute__((spontaneous)) */ +/* { */ +/* __nesc_atomic_t result = inp(SREG); */ +/* cli(); */ +/* return result; */ +/* } */ + +/* inline void __nesc_atomic_end(__nesc_atomic_t oldSreg) __attribute__((spontaneous)) */ +/* { */ +/* outp(oldSreg, SREG); */ +/* } */ + +/* #endif */ + +/* inline void __nesc_atomic_sleep() */ +/* { */ +/* /\* Atomically enable interrupts and sleep *\/ */ +/* sei(); // Make sure interrupts are on, so we can wake up! */ +/* asm volatile ("sleep"); */ +/* TOSH_wait(); */ +/* } */ + + +/* inline void __nesc_enable_interrupt() { */ +/* sei(); */ +/* } */ + +/* inline void __nesc_disable_interrupt() { */ +/* cli(); */ +/* } */ + +#endif //TOSH_AVRHARDWARE_H diff --git a/tos/lib/TOSBoot/micaz/hardware.h b/tos/lib/TOSBoot/micaz/hardware.h new file mode 100644 index 00000000..8f7a1c7f --- /dev/null +++ b/tos/lib/TOSBoot/micaz/hardware.h @@ -0,0 +1,143 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2003 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." + * + * Copyright (c) 2002-2003 Intel Corporation + * All rights reserved. + * + * This file is distributed under the terms in the attached INTEL-LICENSE + * file. If you do not find these files, copies can be found by writing to + * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, + * 94704. Attention: Intel License Inquiry. + */ +/* tab:4 + * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By + * downloading, copying, installing or using the software you agree to + * this license. If you do not agree to this license, do not download, + * install, copy or use the software. + * + * Intel Open Source License + * + * Copyright (c) 2002 Intel Corporation + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + */ +/* + * + * $Id$ + * + */ + +#ifndef __HARDWARE_H__ +#define __HARDWARE_H__ + +#include +#include + +typedef uint32_t in_flash_addr_t; +typedef uint32_t ex_flash_addr_t; + +void wait( uint16_t t ) { + for ( ; t; t-- ); +} + +// LED assignments +TOSH_ASSIGN_PIN(RED_LED, A, 2); +TOSH_ASSIGN_PIN(GREEN_LED, A, 1); +TOSH_ASSIGN_PIN(YELLOW_LED, A, 0); + +TOSH_ASSIGN_PIN(SERIAL_ID, A, 4); + +// Flash assignments +TOSH_ASSIGN_PIN(FLASH_CS, A, 3); +TOSH_ASSIGN_PIN(FLASH_CLK, D, 5); +TOSH_ASSIGN_PIN(FLASH_OUT, D, 3); +TOSH_ASSIGN_PIN(FLASH_IN, D, 2); + +// power control assignments +TOSH_ASSIGN_PIN(PW0, C, 0); +TOSH_ASSIGN_PIN(PW1, C, 1); +TOSH_ASSIGN_PIN(PW2, C, 2); +TOSH_ASSIGN_PIN(PW3, C, 3); +TOSH_ASSIGN_PIN(PW4, C, 4); +TOSH_ASSIGN_PIN(PW5, C, 5); +TOSH_ASSIGN_PIN(PW6, C, 6); +TOSH_ASSIGN_PIN(PW7, C, 7); + +void TOSH_SET_PIN_DIRECTIONS(void) +{ + TOSH_MAKE_RED_LED_OUTPUT(); + TOSH_MAKE_YELLOW_LED_OUTPUT(); + TOSH_MAKE_GREEN_LED_OUTPUT(); + + TOSH_MAKE_PW7_OUTPUT(); + TOSH_MAKE_PW6_OUTPUT(); + TOSH_MAKE_PW5_OUTPUT(); + TOSH_MAKE_PW4_OUTPUT(); + TOSH_MAKE_PW3_OUTPUT(); + TOSH_MAKE_PW2_OUTPUT(); + TOSH_MAKE_PW1_OUTPUT(); + TOSH_MAKE_PW0_OUTPUT(); + + TOSH_MAKE_SERIAL_ID_INPUT(); + TOSH_CLR_SERIAL_ID_PIN(); // Prevent sourcing current + + TOSH_MAKE_FLASH_CS_OUTPUT(); + TOSH_MAKE_FLASH_OUT_OUTPUT(); + TOSH_MAKE_FLASH_CLK_OUTPUT(); + TOSH_SET_FLASH_CS_PIN(); +} + +enum { + VOLTAGE_PORT = 30, + VTHRESH = 0x1cf, // 2.7V +}; + +#endif + + + + diff --git a/tos/lib/TOSBoot/msp430/HPLUSART0M.nc b/tos/lib/TOSBoot/msp430/HPLUSART0M.nc new file mode 100644 index 00000000..e53c9eb0 --- /dev/null +++ b/tos/lib/TOSBoot/msp430/HPLUSART0M.nc @@ -0,0 +1,128 @@ +// $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 + */ + +module HPLUSART0M { + provides interface HPLUSARTControl; +} +implementation { + + command void HPLUSARTControl.disableSPI() { + // USART0 SPI module disable + //ME1 &= ~USPIE0; + + // set to PUC values + ME1 = 0; + U0CTL = 1; + U0TCTL = 1; + U0RCTL = 0; + } + + command void HPLUSARTControl.setModeSPI() { + + //U0CTL = SWRST; + + // 8-bit char, SPI-mode, USART as master + U0CTL = SWRST | CHAR | SYNC | MM; + + // 3-pin + half-cycle delayed UCLK + U0TCTL |= STC + CKPH + SSEL_SMCLK; + + // as fast as possible + U0BR0 = 0x02; + U0BR1 = 0; + + // enable SPI + ME1 |= USPIE0; + + U0CTL &= ~SWRST; + + // clear interrupts + IFG1 = 0; + + } + + command void HPLUSARTControl.disableI2C() { + /* + U0CTL = 1; + U0TCTL = 1; + I2CTCTL = 0; + */ + U0CTL &= ~I2CEN; + U0CTL &= ~I2C; + I2CTCTL = 0; + call HPLUSARTControl.disableSPI(); + } + + command void HPLUSARTControl.setModeI2C() { + + // Recommended init procedure + U0CTL = I2C + SYNC + MST; + + // use 1MHz SMCLK as the I2C reference + I2CTCTL |= I2CSSEL_2 | I2CTRX; + + // Enable I2C + U0CTL |= I2CEN; + + return; + } + + command error_t HPLUSARTControl.isTxEmpty(){ + if (U0TCTL & TXEPT) { + return SUCCESS; + } + return FAIL; + } + + command error_t HPLUSARTControl.isTxIntrPending(){ + if (IFG1 & UTXIFG0){ + IFG1 &= ~UTXIFG0; + return SUCCESS; + } + return FAIL; + } + + command error_t HPLUSARTControl.isRxIntrPending(){ + if (IFG1 & URXIFG0){ + IFG1 &= ~URXIFG0; + return SUCCESS; + } + return FAIL; + } + + command void HPLUSARTControl.tx(uint8_t data){ + U0TXBUF = data; + } + + command uint8_t HPLUSARTControl.rx(){ + return U0RXBUF; + } + +} diff --git a/tos/lib/TOSBoot/msp430/HPLUSARTControl.nc b/tos/lib/TOSBoot/msp430/HPLUSARTControl.nc new file mode 100644 index 00000000..4e4998f7 --- /dev/null +++ b/tos/lib/TOSBoot/msp430/HPLUSARTControl.nc @@ -0,0 +1,46 @@ +// $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 + */ + +includes msp430usart; + +interface HPLUSARTControl { + + command void disableSPI(); + command void setModeSPI(); + command void disableI2C(); + command void setModeI2C(); + command error_t isTxEmpty(); + command error_t isTxIntrPending(); + command error_t isRxIntrPending(); + command void tx(uint8_t data); + command uint8_t rx(); + +} + diff --git a/tos/lib/TOSBoot/msp430/HardwareC.nc b/tos/lib/TOSBoot/msp430/HardwareC.nc new file mode 100644 index 00000000..ab5ef932 --- /dev/null +++ b/tos/lib/TOSBoot/msp430/HardwareC.nc @@ -0,0 +1,48 @@ +// $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 + */ + +module HardwareC { + provides { + interface Hardware; + } +} + +implementation { + + command void Hardware.init() { + BCSCTL1 = RSEL0 | RSEL1 | RSEL2 | XT2OFF; + DCOCTL = DCO0 | DCO1 | DCO2; + } + + command void Hardware.reboot() { + WDTCTL = 0; + } + +} diff --git a/tos/lib/TOSBoot/msp430/InternalFlashC.nc b/tos/lib/TOSBoot/msp430/InternalFlashC.nc new file mode 100644 index 00000000..a913bd71 --- /dev/null +++ b/tos/lib/TOSBoot/msp430/InternalFlashC.nc @@ -0,0 +1,122 @@ +// $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." + * + */ + +/** + * InternalFlashC.nc - Internal flash implementation for telos msp + * platform. On the msp, the flash must first be erased before a value + * can be written. However, the msp can only erase the flash at a + * segment granularity (128 bytes for the information section). This + * module allows transparent read/write of individual bytes to the + * information section by dynamically switching between the two + * provided segments in the information section. + * + * Valid address range is 0x1000 - 0x107E (0x107F is used to store the + * version number of the information segment). + * + * @author Jonathan Hui + */ + +includes InternalFlash; + +module InternalFlashC { + provides interface InternalFlash; +} + +implementation { + + enum { + IFLASH_OFFSET = 0x1000, + IFLASH_SIZE = 128, + IFLASH_SEG0_VNUM_ADDR = 0x107f, + IFLASH_SEG1_VNUM_ADDR = 0x10ff, + IFLASH_INVALID_VNUM = -1, + }; + + uint8_t chooseSegment() { + int8_t vnum0 = *(int8_t*)IFLASH_SEG0_VNUM_ADDR; + int8_t vnum1 = *(int8_t*)IFLASH_SEG1_VNUM_ADDR; + if (vnum0 == IFLASH_INVALID_VNUM) + return 1; + else if (vnum1 == IFLASH_INVALID_VNUM) + return 0; + return ( (int8_t)(vnum0 - vnum1) < 0 ); + } + + command error_t InternalFlash.write(void* addr, void* buf, uint16_t size) { + + volatile int8_t *newPtr; + int8_t *oldPtr; + int8_t *bufPtr = (int8_t*)buf; + int8_t version; + uint16_t i; + + addr += IFLASH_OFFSET; + newPtr = oldPtr = (int8_t*)IFLASH_OFFSET; + if (chooseSegment()) { + oldPtr += IFLASH_SIZE; + } + else { + addr += IFLASH_SIZE; + newPtr += IFLASH_SIZE; + } + + FCTL2 = FWKEY + FSSEL1 + FN2; + FCTL3 = FWKEY; + FCTL1 = FWKEY + ERASE; + *newPtr = 0; + FCTL1 = FWKEY + WRT; + + for ( i = 0; i < IFLASH_SIZE-1; i++, newPtr++, oldPtr++ ) { + if ((uint16_t)newPtr < (uint16_t)addr || (uint16_t)addr+size <= (uint16_t)newPtr) + *newPtr = *oldPtr; + else + *newPtr = *bufPtr++; + } + version = *oldPtr + 1; + if (version == IFLASH_INVALID_VNUM) + version++; + *newPtr = version; + + FCTL1 = FWKEY; + FCTL3 = FWKEY + LOCK; + + return SUCCESS; + + } + + command error_t InternalFlash.read(void* addr, void* buf, uint16_t size) { + + addr += IFLASH_OFFSET; + if (chooseSegment()) + addr += IFLASH_SIZE; + + memcpy(buf, addr, size); + + return SUCCESS; + + } + +} diff --git a/tos/lib/TOSBoot/msp430/ProgFlashM.nc b/tos/lib/TOSBoot/msp430/ProgFlashM.nc new file mode 100644 index 00000000..de8b2628 --- /dev/null +++ b/tos/lib/TOSBoot/msp430/ProgFlashM.nc @@ -0,0 +1,70 @@ +// $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 + */ + +module ProgFlashM { + provides { + interface ProgFlash; + } +} + +implementation { + + enum { + RESET_ADDR = 0xfffe, + }; + + command error_t ProgFlash.write(in_flash_addr_t addr, uint8_t* buf, uint16_t len) { + + volatile uint16_t *flashAddr = (uint16_t*)(uint16_t)addr; + uint16_t *wordBuf = (uint16_t*)buf; + uint16_t i = 0; + + // len is 16 bits so it can't be larger than 0xffff + // make sure we can't wrap around + if (addr < (0xffff - (len >> 1))) { + FCTL2 = FWKEY + FSSEL1 + FN2; + FCTL3 = FWKEY; + FCTL1 = FWKEY + ERASE; + *flashAddr = 0; + FCTL1 = FWKEY + WRT; + for (i = 0; i < (len >> 1); i++, flashAddr++) { + if ((uint16_t)flashAddr != RESET_ADDR) + *flashAddr = wordBuf[i]; + else + *flashAddr = TOSBOOT_START; + } + FCTL1 = FWKEY; + FCTL3 = FWKEY + LOCK; + return SUCCESS; + } + return FAIL; + } + +} diff --git a/tos/lib/TOSBoot/msp430/VoltageC.nc b/tos/lib/TOSBoot/msp430/VoltageC.nc new file mode 100644 index 00000000..50a08f8d --- /dev/null +++ b/tos/lib/TOSBoot/msp430/VoltageC.nc @@ -0,0 +1,72 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +module VoltageC { + provides { + interface Voltage; + } +} + +implementation { + + enum { + VTHRESH = 0xE66, // 2.7V + }; + + command bool Voltage.okToProgram() { + + 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/stm25p/ExtFlashC.nc b/tos/lib/TOSBoot/stm25p/ExtFlashC.nc new file mode 100644 index 00000000..d9c507c6 --- /dev/null +++ b/tos/lib/TOSBoot/stm25p/ExtFlashC.nc @@ -0,0 +1,51 @@ +// $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 + */ + +configuration ExtFlashC { + provides { + interface Init; + interface StdControl; + interface ExtFlash; + } +} + +implementation { + + components + ExtFlashM, + HPLUSART0M; + + Init = ExtFlashM; + StdControl = ExtFlashM; + ExtFlash = ExtFlashM; + + ExtFlashM.USARTControl -> HPLUSART0M; + +} diff --git a/tos/lib/TOSBoot/stm25p/ExtFlashM.nc b/tos/lib/TOSBoot/stm25p/ExtFlashM.nc new file mode 100644 index 00000000..f3d16c02 --- /dev/null +++ b/tos/lib/TOSBoot/stm25p/ExtFlashM.nc @@ -0,0 +1,114 @@ +// $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 + */ + +module ExtFlashM { + provides { + interface StdControl; + interface Init; + interface ExtFlash; + } + uses { + interface HPLUSARTControl as USARTControl; + } +} + +implementation { + + command error_t Init.init() { + TOSH_MAKE_FLASH_HOLD_OUTPUT(); + TOSH_MAKE_FLASH_CS_OUTPUT(); + TOSH_SET_FLASH_HOLD_PIN(); + call USARTControl.setModeSPI(); + return SUCCESS; + } + + command error_t StdControl.start() { + return SUCCESS; + } + + command error_t StdControl.stop() { + + TOSH_CLR_FLASH_CS_PIN(); + + call USARTControl.tx(0xb9); + while(call USARTControl.isTxEmpty() != SUCCESS); + + TOSH_SET_FLASH_CS_PIN(); + + call USARTControl.disableSPI(); + + return SUCCESS; + + } + + void powerOnFlash() { + + uint8_t i; + + TOSH_CLR_FLASH_CS_PIN(); + + // command byte + 3 dummy bytes + signature + for ( i = 0; i < 5; i++ ) { + call USARTControl.tx(0xab); + while(call USARTControl.isTxIntrPending() != SUCCESS); + } + + TOSH_SET_FLASH_CS_PIN(); + + } + + command void ExtFlash.startRead(uint32_t addr) { + + uint8_t i; + + powerOnFlash(); + + TOSH_CLR_FLASH_CS_PIN(); + + // add command byte to address + addr |= (uint32_t)0x3 << 24; + + // address + for ( i = 4; i > 0; i-- ) { + call USARTControl.tx((addr >> (i-1)*8) & 0xff); + while(call USARTControl.isTxIntrPending() != SUCCESS); + } + + } + + command uint8_t ExtFlash.readByte() { + call USARTControl.rx(); + call USARTControl.tx(0); + while(call USARTControl.isRxIntrPending() != SUCCESS); + return call USARTControl.rx(); + } + + command void ExtFlash.stopRead() { + TOSH_SET_FLASH_CS_PIN(); + } + +} diff --git a/tos/lib/TOSBoot/telosb/InternalFlash.h b/tos/lib/TOSBoot/telosb/InternalFlash.h new file mode 100644 index 00000000..aa4f8728 --- /dev/null +++ b/tos/lib/TOSBoot/telosb/InternalFlash.h @@ -0,0 +1,45 @@ +// $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 telos msp + * platform. On the msp, the flash must first be erased before a value + * can be written. However, the msp can only erase the flash at a + * segment granularity (128 bytes for the information section). This + * module allows transparent read/write of individual bytes to the + * information section by dynamically switching between the two + * provided segments in the information section. + * + * Valid address range is 0x1000 - 0x107E (0x107F is used to store the + * version number of the information segment). + * + * @author Jonathan Hui + */ + +#ifndef __INTERNAL_FLASH_H__ +#define __INTERNAL_FLASH_H__ + +#endif diff --git a/tos/lib/TOSBoot/telosb/InternalFlash.nc b/tos/lib/TOSBoot/telosb/InternalFlash.nc new file mode 100644 index 00000000..ab860c0e --- /dev/null +++ b/tos/lib/TOSBoot/telosb/InternalFlash.nc @@ -0,0 +1,37 @@ +// $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.nc - A generic interface to read and store values in + * the internal flash of a microcontroller. + * + * @author Jonathan Hui + */ + +interface InternalFlash { + command error_t write(void* addr, void* buf, uint16_t size); + command error_t read(void* addr, void* buf, uint16_t size); +} diff --git a/tos/lib/TOSBoot/telosb/PluginC.nc b/tos/lib/TOSBoot/telosb/PluginC.nc new file mode 100644 index 00000000..de5a7bd3 --- /dev/null +++ b/tos/lib/TOSBoot/telosb/PluginC.nc @@ -0,0 +1,46 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +configuration PluginC { + provides { + interface StdControl; + } +} + +implementation { + + components ExtFlashC, LedsC, PowerOffM; + + StdControl = PowerOffM; + + PowerOffM.Leds -> LedsC; + PowerOffM.SubControl -> ExtFlashC; + +} diff --git a/tos/lib/TOSBoot/telosb/PowerOffM.nc b/tos/lib/TOSBoot/telosb/PowerOffM.nc new file mode 100644 index 00000000..404f892a --- /dev/null +++ b/tos/lib/TOSBoot/telosb/PowerOffM.nc @@ -0,0 +1,85 @@ +// $Id$ + +/* tab:2 + * + * + * "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 + */ + +module PowerOffM { + 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); + + // 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/telosb/TOSBoot_platform.h b/tos/lib/TOSBoot/telosb/TOSBoot_platform.h new file mode 100644 index 00000000..afc7693a --- /dev/null +++ b/tos/lib/TOSBoot/telosb/TOSBoot_platform.h @@ -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 + */ + +#ifndef __TOSBOOT_PLATFORM_H__ +#define __TOSBOOT_PLATFORM_H__ + +enum { + // address of TOSBoot args in internal flash + TOSBOOT_ARGS_ADDR = 0x70, + // number of resets to force golden image + TOSBOOT_GESTURE_MAX_COUNT = 3, + // address of the golden image in external flash + TOSBOOT_GOLDEN_IMG_ADDR = 0xf0000L, + // size of each internal program flash page + TOSBOOT_INT_PAGE_SIZE = 512L, +}; + +enum { + DELUGE_MIN_ADV_PERIOD_LOG2 = 9, + DELUGE_QSIZE = 1, +}; + +#endif diff --git a/tos/lib/TOSBoot/telosb/hardware.h b/tos/lib/TOSBoot/telosb/hardware.h new file mode 100644 index 00000000..ddfae86c --- /dev/null +++ b/tos/lib/TOSBoot/telosb/hardware.h @@ -0,0 +1,88 @@ +// $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 + */ + +#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-- ); +} + +// LEDs +TOSH_ASSIGN_PIN(RED_LED, 5, 4); +TOSH_ASSIGN_PIN(GREEN_LED, 5, 5); +TOSH_ASSIGN_PIN(YELLOW_LED, 5, 6); + +// UART pins +TOSH_ASSIGN_PIN(SOMI0, 3, 2); +TOSH_ASSIGN_PIN(SIMO0, 3, 1); +TOSH_ASSIGN_PIN(UCLK0, 3, 3); +TOSH_ASSIGN_PIN(UTXD0, 3, 4); +TOSH_ASSIGN_PIN(URXD0, 3, 5); + +// User Interupt Pin +TOSH_ASSIGN_PIN(USERINT, 2, 7); + +// FLASH +TOSH_ASSIGN_PIN(FLASH_PWR, 4, 3); +TOSH_ASSIGN_PIN(FLASH_CS, 4, 4); +TOSH_ASSIGN_PIN(FLASH_HOLD, 4, 7); + +void TOSH_SET_PIN_DIRECTIONS(void) +{ + P3SEL = 0x0E; // set SPI and I2C to mod func + + P1DIR = 0xe0; + P1OUT = 0x00; + + P2DIR = 0x7b; + P2OUT = 0x10; + + P3DIR = 0xf1; + P3OUT = 0x00; + + P4DIR = 0xfd; + P4OUT = 0xdd; + + P5DIR = 0xff; + P5OUT = 0xff; + + P6DIR = 0xff; + P6OUT = 0x00; +} + +#endif diff --git a/tos/lib/tosboot/Deluge.h b/tos/lib/tosboot/Deluge.h deleted file mode 100644 index b6aa2873..00000000 --- a/tos/lib/tosboot/Deluge.h +++ /dev/null @@ -1,142 +0,0 @@ -// $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 - */ - -#ifndef __DELUGE_H__ -#define __DELUGE_H__ - -#include "DelugeMetadata.h" -#include "TOSBoot.h" - -#ifndef DELUGE_NUM_IMAGES -#define DELUGE_NUM_IMAGES 3 -#endif - -enum { - DELUGE_VERSION = 2, - DELUGE_MAX_ADV_PERIOD_LOG2 = 22, - DELUGE_NUM_NEWDATA_ADVS_REQUIRED = 2, - DELUGE_NUM_MIN_ADV_PERIODS = 2, - DELUGE_MAX_NUM_REQ_TRIES = 1, - DELUGE_REBOOT_DELAY = 4, - DELUGE_FAILED_SEND_DELAY = 16, - DELUGE_MIN_DELAY = 16, - DELUGE_PKTS_PER_PAGE = 48, - DELUGE_PKT_PAYLOAD_SIZE = 23, - DELUGE_DATA_OFFSET = 128, - DELUGE_IDENT_SIZE = 128, - DELUGE_INVALID_ADDR = (0x7fffffffL), - DELUGE_MAX_REQ_DELAY = (0x1L << (DELUGE_MIN_ADV_PERIOD_LOG2-1)), - DELUGE_NACK_TIMEOUT = (DELUGE_MAX_REQ_DELAY >> 0x1), - DELUGE_BYTES_PER_PAGE = (DELUGE_PKTS_PER_PAGE*DELUGE_PKT_PAYLOAD_SIZE), - DELUGE_PKT_BITVEC_SIZE = (((DELUGE_PKTS_PER_PAGE-1) / 8) + 1), - DELUGE_MAX_IMAGE_SIZE = (128L*1024L), - DELUGE_MAX_PAGES = 128, - DELUGE_CRC_SIZE = sizeof(uint16_t), - DELUGE_CRC_BLOCK_SIZE = DELUGE_MAX_PAGES*DELUGE_CRC_SIZE, - DELUGE_GOLDEN_IMAGE_NUM = 0x0, - DELUGE_INVALID_VNUM = -1, - DELUGE_INVALID_IMGNUM = 0xff, - DELUGE_INVALID_PKTNUM = 0xff, - DELUGE_INVALID_PGNUM = 0xff, -}; - -#include "Storage.h" - -struct deluge_image_t { - imgnum_t imageNum; - volume_id_t volumeId; -}; - -typedef struct DelugeAdvTimer { - uint32_t timer : 32; - uint8_t periodLog2 : 8; - bool overheard : 1; - uint8_t newAdvs : 7; -} DelugeAdvTimer; - -typedef struct DelugeNodeDesc { - imgvnum_t vNum; - uint32_t uid; - imgnum_t imgNum; - uint8_t reserved; - uint16_t crc; -} DelugeNodeDesc; - -enum { - DELUGE_VOLUME_ID_0 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 2 - DELUGE_VOLUME_ID_1 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 3 - DELUGE_VOLUME_ID_2 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 4 - DELUGE_VOLUME_ID_3 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 5 - DELUGE_VOLUME_ID_4 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 6 - DELUGE_VOLUME_ID_5 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 7 - DELUGE_VOLUME_ID_6 = unique("StorageManager"), -#if DELUGE_NUM_IMAGES >= 8 - DELUGE_VOLUME_ID_7 = unique("StorageManager"), -#endif -#endif -#endif -#endif -#endif -#endif -#endif -}; - -static const struct deluge_image_t DELUGE_IMAGES[DELUGE_NUM_IMAGES] = { - { DELUGE_VOLUME_ID_0, 0xDF }, -#if DELUGE_NUM_IMAGES >= 2 - { DELUGE_VOLUME_ID_1, 0xD0 }, -#if DELUGE_NUM_IMAGES >= 3 - { DELUGE_VOLUME_ID_2, 0xD1 }, -#if DELUGE_NUM_IMAGES >= 4 - { DELUGE_VOLUME_ID_3, 0xD2 }, -#if DELUGE_NUM_IMAGES >= 5 - { DELUGE_VOLUME_ID_4, 0xD3 }, -#if DELUGE_NUM_IMAGES >= 6 - { DELUGE_VOLUME_ID_5, 0xD4 }, -#if DELUGE_NUM_IMAGES >= 7 - { DELUGE_VOLUME_ID_6, 0xD5 }, -#if DELUGE_NUM_IMAGES >= 8 - { DELUGE_VOLUME_ID_7, 0xD6 }, -#endif -#endif -#endif -#endif -#endif -#endif -#endif -}; - -#endif diff --git a/tos/lib/tosboot/Exec.nc b/tos/lib/tosboot/Exec.nc deleted file mode 100644 index 3d42c0d9..00000000 --- a/tos/lib/tosboot/Exec.nc +++ /dev/null @@ -1,4 +0,0 @@ - -interface Exec { - command void exec(); -} diff --git a/tos/lib/tosboot/ExtFlash.nc b/tos/lib/tosboot/ExtFlash.nc deleted file mode 100644 index a45e8e79..00000000 --- a/tos/lib/tosboot/ExtFlash.nc +++ /dev/null @@ -1,35 +0,0 @@ -// $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 - */ - -interface ExtFlash { - command void startRead(uint32_t addr); - command uint8_t readByte(); - command void stopRead(); -} diff --git a/tos/lib/tosboot/Hardware.nc b/tos/lib/tosboot/Hardware.nc deleted file mode 100644 index 879c0447..00000000 --- a/tos/lib/tosboot/Hardware.nc +++ /dev/null @@ -1,34 +0,0 @@ -// $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 - */ - -interface Hardware { - command void init(); - command void reboot(); -} diff --git a/tos/lib/tosboot/Leds.nc b/tos/lib/tosboot/Leds.nc deleted file mode 100644 index c672d1be..00000000 --- a/tos/lib/tosboot/Leds.nc +++ /dev/null @@ -1,35 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -interface Leds { - command void set(uint8_t ledsOn); - command void flash(uint8_t a); - command void glow(uint8_t a, uint8_t b); -} diff --git a/tos/lib/tosboot/Makefile b/tos/lib/tosboot/Makefile deleted file mode 100644 index 56924184..00000000 --- a/tos/lib/tosboot/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# $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 -# - -COMPONENT=TOSBoot -TINYOS_NP= - -PFLAGS += -DNESC_BUILD_BINARY - -# ifeq ($(MAKECMDGOALS),mica2) -# CFLAGS += -DTOSBOOT_START=0x1f000 -DTOSBOOT_END=0x20000 -# CFLAGS += -Wl,--section-start=.text=0x1f000 -# CFLAGS += -Iat45db -Iavr -Imica2 -Ilib -# endif - -# ifeq ($(MAKECMDGOALS),mica2dot) -# CFLAGS += -DTOSBOOT_START=0x1f000 -DTOSBOOT_END=0x20000 -# CFLAGS += -Wl,--section-start=.text=0x1f000 -# CFLAGS += -Iat45db -Iavr -Imica2dot -Ilib -# endif - -ifeq ($(MAKECMDGOALS),micaz) - CFLAGS += -DTOSBOOT_START=0x1f000 -DTOSBOOT_END=0x20000 - CFLAGS += -Wl,--section-start=.text=0x1f000 - CFLAGS += -Iat45db -Iavr -Imicaz -Ilib - CFLAGS += -I../net/Deluge -endif - -# ifeq ($(MAKECMDGOALS),telosa) -# CFLAGS += -DTOSBOOT_START=0x1100 -DTOSBOOT_END=0x1a00 -# CFLAGS += -Iat45db -Imsp430 -Itelos -Ilib -# POST_BUILD_EXTRA_DEPS += strip_iv -# endif - -ifeq ($(MAKECMDGOALS),telosb) - CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00 - CFLAGS += -Imsp430 -Istm25p -Itelosb -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 - -include $(MAKERULES) diff --git a/tos/lib/tosboot/ProgFlash.nc b/tos/lib/tosboot/ProgFlash.nc deleted file mode 100644 index 6b67bbb1..00000000 --- a/tos/lib/tosboot/ProgFlash.nc +++ /dev/null @@ -1,33 +0,0 @@ -// $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 - */ - -interface ProgFlash { - command error_t write(in_flash_addr_t addr, uint8_t* buf, in_flash_addr_t len); -} diff --git a/tos/lib/tosboot/TOSBoot.h b/tos/lib/tosboot/TOSBoot.h deleted file mode 100644 index ab5524b5..00000000 --- a/tos/lib/tosboot/TOSBoot.h +++ /dev/null @@ -1,39 +0,0 @@ -// $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 - */ - -#ifndef __TOSBOOT_H__ -#define __TOSBOOT_H__ - -#include "TOSBoot_platform.h" - -typedef struct tosboot_args_t { - uint32_t imageAddr; - uint8_t gestureCount; - bool noReprogram; -} tosboot_args_t; - -#endif diff --git a/tos/lib/tosboot/TOSBoot.nc b/tos/lib/tosboot/TOSBoot.nc deleted file mode 100644 index d08429b7..00000000 --- a/tos/lib/tosboot/TOSBoot.nc +++ /dev/null @@ -1,61 +0,0 @@ -// $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 - */ - -includes Deluge; -includes TOSBoot; - -configuration TOSBoot { -} -implementation { - - components - TOSBootM, - ExecC, - ExtFlashC, - HardwareC, - InternalFlashC as IntFlash, - LedsC, - PluginC, - ProgFlashM as ProgFlash, - VoltageC; - - TOSBootM.SubInit -> ExtFlashC; - TOSBootM.SubControl -> ExtFlashC.StdControl; - TOSBootM.SubControl -> PluginC; - - TOSBootM.Exec -> ExecC; - TOSBootM.ExtFlash -> ExtFlashC; - TOSBootM.Hardware -> HardwareC; - TOSBootM.IntFlash -> IntFlash; - TOSBootM.Leds -> LedsC; - TOSBootM.ProgFlash -> ProgFlash; - TOSBootM.Voltage -> VoltageC; - -} diff --git a/tos/lib/tosboot/TOSBootM.nc b/tos/lib/tosboot/TOSBootM.nc deleted file mode 100644 index 8b4eba70..00000000 --- a/tos/lib/tosboot/TOSBootM.nc +++ /dev/null @@ -1,269 +0,0 @@ -/* - * "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." - * - * Copyright (c) 2007 Johns Hopkins University. - * All rights reserved. - * - */ - -/** - * @author Jonathan Hui - * @author Chieh-Jan Mike Liang - * @author Razvan Musaloiu-E. - */ - -includes crc; -includes hardware; - -module TOSBootM { - uses { - interface Exec; - interface ExtFlash; - interface Hardware; - interface InternalFlash as IntFlash; - interface Leds; - interface ProgFlash; - interface StdControl as SubControl; - interface Init as SubInit; - interface Voltage; - } -} -implementation { - - enum { - LEDS_LOWBATT = 1, - LEDS_GESTURE = 7, - }; - - enum { - R_SUCCESS, - R_INVALID_IMAGE_ERROR, - R_PROGRAMMING_ERROR, - }; - - void startupLeds() { - - uint8_t output = 0x7; - uint8_t i; - - for (i = 3; i; i--, output >>= 1 ) - call Leds.glow(output, output >> 1); - - } - - in_flash_addr_t extFlashReadAddr() { - in_flash_addr_t result = 0; - uint8_t i; - for ( i = 0; i < 4; i++ ) - result |= ((in_flash_addr_t)call ExtFlash.readByte() & 0xff) << (i*8); - return result; - } - - bool verifyImage(ex_flash_addr_t startAddr) { - - uint16_t crcTarget = 0, crcTmp = 0; - uint16_t addr, len; - pgnum_t numPgs; - uint8_t i; - - // read size of image - call ExtFlash.startRead(startAddr + offsetof(DelugeImgDesc,numPgs)); - numPgs = call ExtFlash.readByte(); - call ExtFlash.stopRead(); - - if (numPgs == 0 || numPgs == 0xff) - return FALSE; - - startAddr += DELUGE_METADATA_SIZE; - - addr = DELUGE_CRC_BLOCK_SIZE; - len = DELUGE_BYTES_PER_PAGE-DELUGE_CRC_BLOCK_SIZE; - - for ( i = 0; i < numPgs && crcTarget == crcTmp; i++ ) { - - // read crc - call ExtFlash.startRead(startAddr + i*sizeof(uint16_t)); - crcTarget = (uint16_t)(call ExtFlash.readByte() & 0xff); - crcTarget |= (uint16_t)(call ExtFlash.readByte() & 0xff) << 8; - call ExtFlash.stopRead(); - - // compute crc - call ExtFlash.startRead(startAddr + addr); - for ( crcTmp = 0; len; len-- ) - crcTmp = crcByte(crcTmp, call ExtFlash.readByte()); - call ExtFlash.stopRead(); - - addr = (uint16_t)(i+1)*DELUGE_BYTES_PER_PAGE; - len = DELUGE_BYTES_PER_PAGE; - } - - return (i == numPgs) && (crcTarget == crcTmp); - } - - error_t programImage(ex_flash_addr_t startAddr) { - - uint8_t buf[TOSBOOT_INT_PAGE_SIZE]; - uint16_t pageAddr, newPageAddr; - in_flash_addr_t intAddr; - in_flash_addr_t secLength; - ex_flash_addr_t curAddr; - - if (!verifyImage(startAddr)) - return R_INVALID_IMAGE_ERROR; - - curAddr = startAddr + DELUGE_METADATA_SIZE + DELUGE_CRC_BLOCK_SIZE + DELUGE_IDENT_SIZE; - - call ExtFlash.startRead(curAddr); - - intAddr = extFlashReadAddr(); - secLength = extFlashReadAddr(); - curAddr = curAddr + 8; - -#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; - - call ExtFlash.startRead(curAddr); - // fill in ram buffer for internal program flash sector - do { - - // check if secLength is all ones - if ( secLength == 0xffffffff ) { - call ExtFlash.stopRead(); // MIKE_LIANG - return FAIL; - } - - buf[(uint16_t)intAddr % TOSBOOT_INT_PAGE_SIZE] = call ExtFlash.readByte(); - intAddr++; curAddr++; - - if ( --secLength == 0 ) { - intAddr = extFlashReadAddr(); - secLength = extFlashReadAddr(); - curAddr = curAddr + 8; - } - - newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE; - - } while ( pageAddr == newPageAddr && secLength ); - call ExtFlash.stopRead(); - - call Leds.set(pageAddr); - - - // write out page - if (call ProgFlash.write(pageAddr*TOSBOOT_INT_PAGE_SIZE, buf, - TOSBOOT_INT_PAGE_SIZE) == FAIL) { - return R_PROGRAMMING_ERROR; - } - } - - return R_SUCCESS; - - } - - void runApp() { - call SubControl.stop(); - call Exec.exec(); - } - - void startupSequence() { - - tosboot_args_t args; - - // check voltage and make sure flash can be programmed - // if not, just run the app, can't check for gestures - // if we can't write to the internal flash anyway - if ( !call Voltage.okToProgram() ) { - // give user some time and count down LEDs - call Leds.flash(LEDS_LOWBATT); - startupLeds(); - runApp(); - } - - // get current value of counter - call IntFlash.read((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args)); - - // increment gesture counter, see if it exceeds threshold - if ( ++args.gestureCount >= TOSBOOT_GESTURE_MAX_COUNT - 1 ) { - // gesture has been detected, display receipt of gesture on LEDs - call Leds.flash(LEDS_GESTURE); - - // load golden image from flash - // 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) { - call Hardware.reboot(); - } - } - else { - // update gesture counter - call IntFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args)); - if ( !args.noReprogram ) { - // if an error happened during reprogramming, reboot and try again - // after two tries, try programming the golden image - if (programImage(args.imageAddr) == R_PROGRAMMING_ERROR) { - call Hardware.reboot(); - } - } - } - - // give user some time and count down LEDs - startupLeds(); - - // reset counter and reprogramming flag - args.gestureCount = 0xff; - args.noReprogram = TRUE; - call IntFlash.write((uint8_t*)TOSBOOT_ARGS_ADDR, &args, sizeof(args)); - - runApp(); - - } - - int main() __attribute__ ((C, spontaneous)) { - - __nesc_disable_interrupt(); - - TOSH_SET_PIN_DIRECTIONS(); - call Hardware.init(); - - call SubInit.init(); - call SubControl.start(); - - startupSequence(); - - return 0; - - } - -} diff --git a/tos/lib/tosboot/Voltage.nc b/tos/lib/tosboot/Voltage.nc deleted file mode 100644 index de4bbec1..00000000 --- a/tos/lib/tosboot/Voltage.nc +++ /dev/null @@ -1,33 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -interface Voltage { - command bool okToProgram(); -} diff --git a/tos/lib/tosboot/at45db/ExtFlashC.nc b/tos/lib/tosboot/at45db/ExtFlashC.nc deleted file mode 100644 index 1d5d3c85..00000000 --- a/tos/lib/tosboot/at45db/ExtFlashC.nc +++ /dev/null @@ -1,126 +0,0 @@ -// $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 - */ - -module ExtFlashC { - provides { - interface Init; - interface StdControl; - interface ExtFlash; - } -} - -implementation { - - uint32_t addr; - - command error_t Init.init() { - TOSH_MAKE_FLASH_CS_OUTPUT(); - TOSH_SET_FLASH_CS_PIN(); - TOSH_MAKE_FLASH_CLK_OUTPUT(); - TOSH_CLR_FLASH_CLK_PIN(); - TOSH_MAKE_FLASH_OUT_OUTPUT(); - TOSH_SET_FLASH_OUT_PIN(); - TOSH_MAKE_FLASH_IN_INPUT(); - TOSH_CLR_FLASH_IN_PIN(); - return SUCCESS; - } - - command error_t StdControl.start() { return SUCCESS; } - command error_t StdControl.stop() { return SUCCESS; } - - 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; - - } - - command void ExtFlash.startRead(uint32_t newAddr) { - - uint8_t cmdBuf[4]; - uint8_t i; - - addr = newAddr; - - cmdBuf[0] = 0x68; - cmdBuf[1] = (addr >> 15) & 0xff; - cmdBuf[2] = (addr >> 7) & 0xfe; - cmdBuf[3] = addr & 0xff; - - TOSH_CLR_FLASH_CLK_PIN(); - TOSH_CLR_FLASH_CS_PIN(); - - for(i = 0; i < 4; i++) - SPIByte(cmdBuf[i]); - for(i = 0; i < 4; i++) - SPIByte(0x0); - - TOSH_SET_FLASH_CLK_PIN(); - TOSH_CLR_FLASH_CLK_PIN(); - - } - - command uint8_t ExtFlash.readByte() { - if (!(addr & 0xff)) { - call ExtFlash.stopRead(); - call ExtFlash.startRead(addr); - } - addr++; - return SPIByte(0); - } - - command void ExtFlash.stopRead() { - TOSH_SET_FLASH_CS_PIN(); - } - -} diff --git a/tos/lib/tosboot/avr/HardwareC.nc b/tos/lib/tosboot/avr/HardwareC.nc deleted file mode 100644 index c48c89bc..00000000 --- a/tos/lib/tosboot/avr/HardwareC.nc +++ /dev/null @@ -1,46 +0,0 @@ -// $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 - */ - -module HardwareC { - provides { - interface Hardware; - } -} - -implementation { - - command void Hardware.init() {} - - command void Hardware.reboot() { - wdt_enable(1); - while(1); - } - -} diff --git a/tos/lib/tosboot/avr/InternalFlashC.nc b/tos/lib/tosboot/avr/InternalFlashC.nc deleted file mode 100644 index 1d6d8fb8..00000000 --- a/tos/lib/tosboot/avr/InternalFlashC.nc +++ /dev/null @@ -1,65 +0,0 @@ -// $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 - */ - -includes InternalFlash; - -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/tosboot/avr/ProgFlashM.nc b/tos/lib/tosboot/avr/ProgFlashM.nc deleted file mode 100644 index 8bada2d6..00000000 --- a/tos/lib/tosboot/avr/ProgFlashM.nc +++ /dev/null @@ -1,65 +0,0 @@ -// $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 - */ - -module ProgFlashM { - provides { - interface ProgFlash; - } -} - -implementation { - -#include - - command error_t ProgFlash.write(in_flash_addr_t addr, uint8_t* buf, in_flash_addr_t len) { - - uint16_t* wordBuf = (uint16_t*)buf; - uint32_t i; - - if ( addr + len > TOSBOOT_START ) - return FAIL; - - boot_page_erase( addr ); - while( boot_rww_busy() ) - boot_rww_enable(); - - for ( i = 0; i < len; i += 2 ) - boot_page_fill( addr + i, *wordBuf++ ); - - boot_page_write( addr ); - - while ( boot_rww_busy() ) - boot_rww_enable(); - - return SUCCESS; - - } - -} diff --git a/tos/lib/tosboot/avr/boot.h b/tos/lib/tosboot/avr/boot.h deleted file mode 100644 index 08c89ce1..00000000 --- a/tos/lib/tosboot/avr/boot.h +++ /dev/null @@ -1,498 +0,0 @@ -/* Copyright (c) 2002, 2003, 2004 Eric B. Weddington - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _AVR_BOOT_H_ -#define _AVR_BOOT_H_ 1 - -/** \defgroup avr_boot Bootloader Support Utilities - \code - #include - #include - \endcode - - The macros in this module provide a C language interface to the - bootloader support functionality of certain AVR processors. These - macros are designed to work with all sizes of flash memory. - - \note Not all AVR processors provide bootloader support. See your - processor datasheet to see if it provides bootloader support. - - \todo From email with Marek: On smaller devices (all except ATmega64/128), - __SPM_REG is in the I/O space, accessible with the shorter "in" and "out" - instructions - since the boot loader has a limited size, this could be an - important optimization. - - \par API Usage Example - The following code shows typical usage of the boot API. - - \code - #include - #include - - #define ADDRESS 0x1C000UL - - void boot_test(void) - { - unsigned char buffer[8]; - - cli(); - - // Erase page. - boot_page_erase((unsigned long)ADDRESS); - while(boot_rww_busy()) - { - boot_rww_enable(); - } - - // Write data to buffer a word at a time. Note incrementing address - // by 2. SPM_PAGESIZE is defined in the microprocessor IO header file. - for(unsigned long i = ADDRESS; i < ADDRESS + SPM_PAGESIZE; i += 2) - { - boot_page_fill(i, (i-ADDRESS) + ((i-ADDRESS+1) << 8)); - } - - // Write page. - boot_page_write((unsigned long)ADDRESS); - while(boot_rww_busy()) - { - boot_rww_enable(); - } - - sei(); - - // Read back the values and display. - // (The show() function is undefined and is used here as an example - // only.) - for(unsigned long i = ADDRESS; i < ADDRESS + 256; i++) - { - show(utoa(pgm_read_byte(i), buffer, 16)); - } - - return; - }\endcode */ - -#include -#include -#include -#include - -/* Check for SPM Control Register in processor. */ -#if defined (SPMCSR) -# define __SPM_REG SPMCSR -#elif defined (SPMCR) -# define __SPM_REG SPMCR -#else -# error AVR processor does not provide bootloader support! -#endif - -/** \ingroup avr_boot - \def BOOTLOADER_SECTION - - Used to declare a function or variable to be placed into a - new section called .bootloader. This section and its contents - can then be relocated to any address (such as the bootloader - NRWW area) at link-time. */ - -#define BOOTLOADER_SECTION __attribute__ ((section (".bootloader"))) - -/* Create common bit definitions. */ -#ifdef ASB -#define __COMMON_ASB ASB -#else -#define __COMMON_ASB RWWSB -#endif - -#ifdef ASRE -#define __COMMON_ASRE ASRE -#else -#define __COMMON_ASRE RWWSRE -#endif - -/* Define the bit positions of the Boot Lock Bits. */ - -#define BLB12 5 -#define BLB11 4 -#define BLB02 3 -#define BLB01 2 - -/** \ingroup avr_boot - \def boot_spm_interrupt_enable() - Enable the SPM interrupt. */ - -#define boot_spm_interrupt_enable() (__SPM_REG |= (uint8_t)_BV(SPMIE)) - -/** \ingroup avr_boot - \def boot_spm_interrupt_disable() - Disable the SPM interrupt. */ - -#define boot_spm_interrupt_disable() (__SPM_REG &= (uint8_t)~_BV(SPMIE)) - -/** \ingroup avr_boot - \def boot_is_spm_interrupt() - Check if the SPM interrupt is enabled. */ - -#define boot_is_spm_interrupt() (__SPM_REG & (uint8_t)_BV(SPMIE)) - -/** \ingroup avr_boot - \def boot_rww_busy() - Check if the RWW section is busy. */ - -#define boot_rww_busy() (__SPM_REG & (uint8_t)_BV(__COMMON_ASB)) - -/** \ingroup avr_boot - \def boot_spm_busy() - Check if the SPM instruction is busy. */ - -#define boot_spm_busy() (__SPM_REG & (uint8_t)_BV(SPMEN)) - -/** \ingroup avr_boot - \def boot_spm_busy_wait() - Wait while the SPM instruction is busy. */ - -#define boot_spm_busy_wait() do{}while(boot_spm_busy()) - -#define __BOOT_PAGE_ERASE (_BV(SPMEN) | _BV(PGERS)) -#define __BOOT_PAGE_WRITE (_BV(SPMEN) | _BV(PGWRT)) -#define __BOOT_PAGE_FILL _BV(SPMEN) -#define __BOOT_RWW_ENABLE (_BV(SPMEN) | _BV(__COMMON_ASRE)) -#define __BOOT_LOCK_BITS_SET (_BV(SPMEN) | _BV(BLBSET)) - -#define __BOOT_LOCK_BITS_MASK (_BV(BLB01) | _BV(BLB02) \ - | _BV(BLB11) | _BV(BLB12)) - -#define eeprom_busy_wait() do {} while (!eeprom_is_ready()) - -#define __boot_page_fill_normal(address, data) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r0, %3\n\t" \ - "movw r30, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - "clr r1\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_PAGE_FILL), \ - "r" ((uint16_t)address), \ - "r" ((uint16_t)data) \ - : "r0", "r30", "r31" \ - ); \ -}) - -#define __boot_page_fill_alternate(address, data)\ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r0, %3\n\t" \ - "movw r30, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - ".word 0xffff\n\t" \ - "nop\n\t" \ - "clr r1\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_PAGE_FILL), \ - "r" ((uint16_t)address), \ - "r" ((uint16_t)data) \ - : "r0", "r30", "r31" \ - ); \ -}) - -#define __boot_page_fill_extended(address, data) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r0, %4\n\t" \ - "movw r30, %A3\n\t" \ - "sts %1, %C3\n\t" \ - "sts %0, %2\n\t" \ - "spm\n\t" \ - "clr r1\n\t" \ - : "=m" (__SPM_REG), \ - "=m" (RAMPZ) \ - : "r" ((uint8_t)__BOOT_PAGE_FILL), \ - "r" ((uint32_t)address), \ - "r" ((uint16_t)data) \ - : "r0", "r30", "r31" \ - ); \ -}) - -#define __boot_page_erase_normal(address) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r30, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_PAGE_ERASE), \ - "r" ((uint16_t)address) \ - : "r30", "r31" \ - ); \ -}) - -#define __boot_page_erase_alternate(address) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r30, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - ".word 0xffff\n\t" \ - "nop\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_PAGE_ERASE), \ - "r" ((uint16_t)address) \ - : "r30", "r31" \ - ); \ -}) - -#define __boot_page_erase_extended(address) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r30, %A3\n\t" \ - "sts %1, %C3\n\t" \ - "sts %0, %2\n\t" \ - "spm\n\t" \ - : "=m" (__SPM_REG), \ - "=m" (RAMPZ) \ - : "r" ((uint8_t)__BOOT_PAGE_ERASE), \ - "r" ((uint32_t)address) \ - : "r30", "r31" \ - ); \ -}) - -#define __boot_page_write_normal(address) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r30, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_PAGE_WRITE), \ - "r" ((uint16_t)address) \ - : "r30", "r31" \ - ); \ -}) - -#define __boot_page_write_alternate(address) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r30, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - ".word 0xffff\n\t" \ - "nop\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_PAGE_WRITE), \ - "r" ((uint16_t)address) \ - : "r30", "r31" \ - ); \ -}) - -#define __boot_page_write_extended(address) \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "movw r30, %A3\n\t" \ - "sts %1, %C3\n\t" \ - "sts %0, %2\n\t" \ - "spm\n\t" \ - : "=m" (__SPM_REG), \ - "=m" (RAMPZ) \ - : "r" ((uint8_t)__BOOT_PAGE_WRITE), \ - "r" ((uint32_t)address) \ - : "r30", "r31" \ - ); \ -}) - -#define __boot_rww_enable() \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_RWW_ENABLE) \ - ); \ -}) - -#define __boot_rww_enable_alternate() \ -({ \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - ".word 0xffff\n\t" \ - "nop\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_RWW_ENABLE) \ - ); \ -}) - -#define __boot_lock_bits_set(lock_bits) \ -({ \ - uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "ldi r30, 1\n\t" \ - "ldi r31, 0\n\t" \ - "mov r0, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ - "r" (value) \ - : "r0", "r30", "r31" \ - ); \ -}) - -#define __boot_lock_bits_set_alternate(lock_bits) \ -({ \ - uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \ - boot_spm_busy_wait(); \ - eeprom_busy_wait(); \ - __asm__ __volatile__ \ - ( \ - "ldi r30, 1\n\t" \ - "ldi r31, 0\n\t" \ - "mov r0, %2\n\t" \ - "sts %0, %1\n\t" \ - "spm\n\t" \ - ".word 0xffff\n\t" \ - "nop\n\t" \ - : "=m" (__SPM_REG) \ - : "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \ - "r" (value) \ - : "r0", "r30", "r31" \ - ); \ -}) - -/** \ingroup avr_boot - \def boot_page_fill(address, data) - - Fill the bootloader temporary page buffer for flash - address with data word. - - \note The address is a byte address. The data is a word. The AVR - writes data to the buffer a word at a time, but addresses the buffer - per byte! So, increment your address by 2 between calls, and send 2 - data bytes in a word format! The LSB of the data is written to the lower - address; the MSB of the data is written to the higher address.*/ - -/** \ingroup avr_boot - \def boot_page_erase(address) - - Erase the flash page that contains address. - - \note address is a byte address in flash, not a word address. */ - -/** \ingroup avr_boot - \def boot_page_write(address) - - Write the bootloader temporary page buffer - to flash page that contains address. - - \note address is a byte address in flash, not a word address. */ - -/** \ingroup avr_boot - \def boot_rww_enable() - - Enable the Read-While-Write memory section. */ - -/** \ingroup avr_boot - \def boot_lock_bits_set(lock_bits) - - Set the bootloader lock bits. */ - -/* Normal versions of the macros use 16-bit addresses. - Extended versions of the macros use 32-bit addresses. - Alternate versions of the macros use 16-bit addresses and require special - instruction sequences after LPM. - - FLASHEND is defined in the ioXXXX.h file. - USHRT_MAX is defined in . */ - -#if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \ - || defined(__AVR_ATmega323__) - -/* Alternate: ATmega161/163/323 and 16 bit address */ -#define boot_page_fill(address, data) __boot_page_fill_alternate(address, data) -#define boot_page_erase(address) __boot_page_erase_alternate(address) -#define boot_page_write(address) __boot_page_write_alternate(address) -#define boot_rww_enable() __boot_rww_enable_alternate() -#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits) - -#elif (FLASHEND > USHRT_MAX) && !defined(__USING_MINT8) - -/* Extended: >16 bit address */ -#define boot_page_fill(address, data) __boot_page_fill_extended(address, data) -#define boot_page_erase(address) __boot_page_erase_extended(address) -#define boot_page_write(address) __boot_page_write_extended(address) -#define boot_rww_enable() __boot_rww_enable() -#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set(lock_bits) - -#else - -/* Normal: 16 bit address */ -#define boot_page_fill(address, data) __boot_page_fill_normal(address, data) -#define boot_page_erase(address) __boot_page_erase_normal(address) -#define boot_page_write(address) __boot_page_write_normal(address) -#define boot_rww_enable() __boot_rww_enable() -#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set(lock_bits) - -#endif - -#endif /* _AVR_BOOT_H_ */ diff --git a/tos/lib/tosboot/crc.h b/tos/lib/tosboot/crc.h deleted file mode 100644 index 64391d3d..00000000 --- a/tos/lib/tosboot/crc.h +++ /dev/null @@ -1,56 +0,0 @@ -// $Id$ - -/* tab:4 - * "Copyright (c) 2000-2003 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." - * - * Copyright (c) 2002-2003 Intel Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached INTEL-LICENSE - * file. If you do not find these files, copies can be found by writing to - * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, - * 94704. Attention: Intel License Inquiry. - */ - -/** - * Default CRC function. Note that avrmote has a much more efficient one. - * - * This CRC-16 function produces a 16-bit running CRC that adheres to the - * ITU-T CRC standard. - * - * The ITU-T polynomial is: G_16(x) = x^16 + x^12 + x^5 + 1 - * - */ - -uint16_t crcByte(uint16_t crc, uint8_t b) -{ - uint8_t i; - - crc = crc ^ b << 8; - i = 8; - do - if (crc & 0x8000) - crc = crc << 1 ^ 0x1021; - else - crc = crc << 1; - while (--i); - - return crc; -} diff --git a/tos/lib/tosboot/lib/ExecC.nc b/tos/lib/tosboot/lib/ExecC.nc deleted file mode 100644 index f29fb8c9..00000000 --- a/tos/lib/tosboot/lib/ExecC.nc +++ /dev/null @@ -1,45 +0,0 @@ -// $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 - */ - -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/lib/LedsC.nc b/tos/lib/tosboot/lib/LedsC.nc deleted file mode 100644 index 476f76e0..00000000 --- a/tos/lib/tosboot/lib/LedsC.nc +++ /dev/null @@ -1,80 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -module LedsC { - provides interface Leds; -} - -implementation { - - enum { - RED_BIT = 1, - GREEN_BIT = 2, - YELLOW_BIT = 4 - }; - - command void Leds.set(uint8_t ledsOn) { - if (ledsOn & GREEN_BIT) - TOSH_CLR_GREEN_LED_PIN(); - else - TOSH_SET_GREEN_LED_PIN(); - if (ledsOn & YELLOW_BIT ) - TOSH_CLR_YELLOW_LED_PIN(); - else - TOSH_SET_YELLOW_LED_PIN(); - if (ledsOn & RED_BIT) - TOSH_CLR_RED_LED_PIN(); - else - TOSH_SET_RED_LED_PIN(); - } - - command void Leds.flash(uint8_t a) { - uint8_t i, j; - for ( i = 3; i; i-- ) { - call Leds.set(a); - for ( j = 4; j; j-- ) - wait(0xffff); - call Leds.set(0); - for ( j = 4; j; j-- ) - wait(0xffff); - } - } - - command void Leds.glow(uint8_t a, uint8_t b) { - int i; - for (i = 1536; i > 0; i -= 4) { - call Leds.set(a); - wait(i); - call Leds.set(b); - wait(1536-i); - } - } - -} diff --git a/tos/lib/tosboot/micaz/ExecC.nc b/tos/lib/tosboot/micaz/ExecC.nc deleted file mode 100644 index dc789acf..00000000 --- a/tos/lib/tosboot/micaz/ExecC.nc +++ /dev/null @@ -1,40 +0,0 @@ -// $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 - */ - -module ExecC { - provides { - interface Exec; - } -} - -implementation { - - command void Exec.exec() { - __asm__ __volatile__ ("jmp 0x0000\n\t" ::); - } - -} diff --git a/tos/lib/tosboot/micaz/InternalFlash.h b/tos/lib/tosboot/micaz/InternalFlash.h deleted file mode 100644 index 01f69e80..00000000 --- a/tos/lib/tosboot/micaz/InternalFlash.h +++ /dev/null @@ -1,41 +0,0 @@ -// $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 - */ - -#ifndef __INTERNAL_FLASH_H__ -#define __INTERNAL_FLASH_H__ - -#include - -#endif diff --git a/tos/lib/tosboot/micaz/PluginC.nc b/tos/lib/tosboot/micaz/PluginC.nc deleted file mode 100644 index 237998ed..00000000 --- a/tos/lib/tosboot/micaz/PluginC.nc +++ /dev/null @@ -1,13 +0,0 @@ - -module PluginC { - provides { - interface StdControl; - } -} - -implementation { - - command error_t StdControl.start() { return SUCCESS; } - command error_t StdControl.stop() { return SUCCESS; } - -} diff --git a/tos/lib/tosboot/micaz/TOSBoot_platform.h b/tos/lib/tosboot/micaz/TOSBoot_platform.h deleted file mode 100644 index e18285e7..00000000 --- a/tos/lib/tosboot/micaz/TOSBoot_platform.h +++ /dev/null @@ -1,47 +0,0 @@ -// $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 - */ - -#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 diff --git a/tos/lib/tosboot/micaz/VoltageC.nc b/tos/lib/tosboot/micaz/VoltageC.nc deleted file mode 100644 index 85b8f103..00000000 --- a/tos/lib/tosboot/micaz/VoltageC.nc +++ /dev/null @@ -1,58 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -module VoltageC { - provides { - interface Voltage; - } -} - -implementation { - - command bool Voltage.okToProgram() { - - // 250 KHz ADC clock (4MHz/16) - outp( 0x04, ADCSR ); - // clear interrupt flag by writing a 1 - sbi( ADCSR, ADIF ); - // setup input channel - outp( VOLTAGE_PORT, ADMUX ); - // adc enable - sbi( ADCSR, ADEN ); - // adc start conversion - sbi( ADCSR, ADSC ); - // wait for conversion to complete - while ( !bit_is_set( ADCSR, ADIF ) ); - - return ( __inw(ADCL) < VTHRESH ); - - } - -} diff --git a/tos/lib/tosboot/micaz/avrhardware.h b/tos/lib/tosboot/micaz/avrhardware.h deleted file mode 100644 index 15a3e87d..00000000 --- a/tos/lib/tosboot/micaz/avrhardware.h +++ /dev/null @@ -1,200 +0,0 @@ -// $Id$ - -/* tab:4 - * "Copyright (c) 2000-2003 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." - * - * Copyright (c) 2002-2003 Intel Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached INTEL-LICENSE - * file. If you do not find these files, copies can be found by writing to - * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, - * 94704. Attention: Intel License Inquiry. - */ -/* - * - * Authors: Jason Hill, Philip Levis, Nelson Lee - * - * - */ - -/** - * @author Jason Hill - * @author Philip Levis - * @author Nelson Lee - */ - - -#ifndef TOSH_AVRHARDWARE_H -#define TOSH_AVRHARDWARE_H - -// check for a new-look avr-libc -#if defined(DTOSTR_ALWAYS_SIGN) && !defined(TOSH_NEW_AVRLIBC) -#define TOSH_NEW_AVRLIBC -#endif - -#ifdef TOSH_NEW_AVRLIBC -#include -#if __AVR_LIBC_VERSION__ >= 10400UL -#include -#else -#include -#include -#endif -#include -#include -#include - -#ifndef sbi -/* avr-libc 1.2.3 doesn't include these anymore. */ -#define sbi(port, bit) ((port) |= _BV(bit)) -#define cbi(port, bit) ((port) &= ~_BV(bit)) -#define inp(port) (port) -#define inb(port) (port) -#define outp(value, port) ((port) = (value)) -#define outb(port, value) ((port) = (value)) -#define inw(port) (*(volatile uint16_t *)&(port)) -#define outw(port, value) ((*(volatile uint16_t *)&(port)) = (value)) -#define PRG_RDB(addr) pgm_read_byte(addr) -#endif - -#else -#include -#include -#include -#include -#include -#endif /* TOSH_NEW_AVRLIBC */ - -// check for version 3.3 of GNU gcc or later -#if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) -#define __outw(val, port) outw(port, val); -#endif - -#ifndef __inw -#ifndef __SFR_OFFSET -#define __SFR_OFFSET 0 -#endif /* !__SFR_OFFSET */ -#define __inw(_port) inw(_port) - -#define __inw_atomic(__sfrport) ({ \ - uint16_t __t; \ - bool bStatus; \ - bStatus = bit_is_set(SREG,7); \ - cli(); \ - __t = inw(__sfrport); \ - if (bStatus) sei(); \ - __t; \ - }) - -#endif /* __inw */ - -#define TOSH_ASSIGN_PIN(name, port, bit) \ -static inline void TOSH_SET_##name##_PIN() {sbi(PORT##port , bit);} \ -static inline void TOSH_CLR_##name##_PIN() {cbi(PORT##port , bit);} \ -static inline int TOSH_READ_##name##_PIN() \ - {return (inp(PIN##port) & (1 << bit)) != 0;} \ -static inline void TOSH_MAKE_##name##_OUTPUT() {sbi(DDR##port , bit);} \ -static inline void TOSH_MAKE_##name##_INPUT() {cbi(DDR##port , bit);} - -#define TOSH_ASSIGN_OUTPUT_ONLY_PIN(name, port, bit) \ -static inline void TOSH_SET_##name##_PIN() {sbi(PORT##port , bit);} \ -static inline void TOSH_CLR_##name##_PIN() {cbi(PORT##port , bit);} \ -static inline void TOSH_MAKE_##name##_OUTPUT() {;} - -#define TOSH_ALIAS_OUTPUT_ONLY_PIN(alias, connector)\ -static inline void TOSH_SET_##alias##_PIN() {TOSH_SET_##connector##_PIN();} \ -static inline void TOSH_CLR_##alias##_PIN() {TOSH_CLR_##connector##_PIN();} \ -static inline void TOSH_MAKE_##alias##_OUTPUT() {} \ - -#define TOSH_ALIAS_PIN(alias, connector) \ -static inline void TOSH_SET_##alias##_PIN() {TOSH_SET_##connector##_PIN();} \ -static inline void TOSH_CLR_##alias##_PIN() {TOSH_CLR_##connector##_PIN();} \ -static inline char TOSH_READ_##alias##_PIN() {return TOSH_READ_##connector##_PIN();} \ -static inline void TOSH_MAKE_##alias##_OUTPUT() {TOSH_MAKE_##connector##_OUTPUT();} \ -static inline void TOSH_MAKE_##alias##_INPUT() {TOSH_MAKE_##connector##_INPUT();} - -// We need slightly different defs than SIGNAL, INTERRUPT -#define TOSH_SIGNAL(signame) \ -void signame() __attribute__ ((signal, spontaneous, C)) - -#define TOSH_INTERRUPT(signame) \ -void signame() __attribute__ ((interrupt, spontaneous, C)) - -/* Watchdog Prescaler - */ -enum { - TOSH_period16 = 0x00, // 47ms - TOSH_period32 = 0x01, // 94ms - TOSH_period64 = 0x02, // 0.19s - TOSH_period128 = 0x03, // 0.38s - TOSH_period256 = 0x04, // 0.75s - TOSH_period512 = 0x05, // 1.5s - TOSH_period1024 = 0x06, // 3.0s - TOSH_period2048 = 0x07 // 6.0s -}; - -void TOSH_wait() -{ - asm volatile("nop"); - asm volatile("nop"); -} - -// atomic statement runtime support - -/* typedef uint8_t __nesc_atomic_t; */ - -/* __nesc_atomic_t __nesc_atomic_start(void); */ -/* void __nesc_atomic_end(__nesc_atomic_t oldSreg); */ - -/* #ifndef NESC_BUILD_BINARY */ - -/* inline __nesc_atomic_t __nesc_atomic_start(void) __attribute__((spontaneous)) */ -/* { */ -/* __nesc_atomic_t result = inp(SREG); */ -/* cli(); */ -/* return result; */ -/* } */ - -/* inline void __nesc_atomic_end(__nesc_atomic_t oldSreg) __attribute__((spontaneous)) */ -/* { */ -/* outp(oldSreg, SREG); */ -/* } */ - -/* #endif */ - -/* inline void __nesc_atomic_sleep() */ -/* { */ -/* /\* Atomically enable interrupts and sleep *\/ */ -/* sei(); // Make sure interrupts are on, so we can wake up! */ -/* asm volatile ("sleep"); */ -/* TOSH_wait(); */ -/* } */ - - -/* inline void __nesc_enable_interrupt() { */ -/* sei(); */ -/* } */ - -/* inline void __nesc_disable_interrupt() { */ -/* cli(); */ -/* } */ - -#endif //TOSH_AVRHARDWARE_H diff --git a/tos/lib/tosboot/micaz/hardware.h b/tos/lib/tosboot/micaz/hardware.h deleted file mode 100644 index 8f7a1c7f..00000000 --- a/tos/lib/tosboot/micaz/hardware.h +++ /dev/null @@ -1,143 +0,0 @@ -// $Id$ - -/* tab:4 - * "Copyright (c) 2000-2003 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." - * - * Copyright (c) 2002-2003 Intel Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached INTEL-LICENSE - * file. If you do not find these files, copies can be found by writing to - * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, - * 94704. Attention: Intel License Inquiry. - */ -/* tab:4 - * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By - * downloading, copying, installing or using the software you agree to - * this license. If you do not agree to this license, do not download, - * install, copy or use the software. - * - * Intel Open Source License - * - * Copyright (c) 2002 Intel Corporation - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ -/* - * - * $Id$ - * - */ - -#ifndef __HARDWARE_H__ -#define __HARDWARE_H__ - -#include -#include - -typedef uint32_t in_flash_addr_t; -typedef uint32_t ex_flash_addr_t; - -void wait( uint16_t t ) { - for ( ; t; t-- ); -} - -// LED assignments -TOSH_ASSIGN_PIN(RED_LED, A, 2); -TOSH_ASSIGN_PIN(GREEN_LED, A, 1); -TOSH_ASSIGN_PIN(YELLOW_LED, A, 0); - -TOSH_ASSIGN_PIN(SERIAL_ID, A, 4); - -// Flash assignments -TOSH_ASSIGN_PIN(FLASH_CS, A, 3); -TOSH_ASSIGN_PIN(FLASH_CLK, D, 5); -TOSH_ASSIGN_PIN(FLASH_OUT, D, 3); -TOSH_ASSIGN_PIN(FLASH_IN, D, 2); - -// power control assignments -TOSH_ASSIGN_PIN(PW0, C, 0); -TOSH_ASSIGN_PIN(PW1, C, 1); -TOSH_ASSIGN_PIN(PW2, C, 2); -TOSH_ASSIGN_PIN(PW3, C, 3); -TOSH_ASSIGN_PIN(PW4, C, 4); -TOSH_ASSIGN_PIN(PW5, C, 5); -TOSH_ASSIGN_PIN(PW6, C, 6); -TOSH_ASSIGN_PIN(PW7, C, 7); - -void TOSH_SET_PIN_DIRECTIONS(void) -{ - TOSH_MAKE_RED_LED_OUTPUT(); - TOSH_MAKE_YELLOW_LED_OUTPUT(); - TOSH_MAKE_GREEN_LED_OUTPUT(); - - TOSH_MAKE_PW7_OUTPUT(); - TOSH_MAKE_PW6_OUTPUT(); - TOSH_MAKE_PW5_OUTPUT(); - TOSH_MAKE_PW4_OUTPUT(); - TOSH_MAKE_PW3_OUTPUT(); - TOSH_MAKE_PW2_OUTPUT(); - TOSH_MAKE_PW1_OUTPUT(); - TOSH_MAKE_PW0_OUTPUT(); - - TOSH_MAKE_SERIAL_ID_INPUT(); - TOSH_CLR_SERIAL_ID_PIN(); // Prevent sourcing current - - TOSH_MAKE_FLASH_CS_OUTPUT(); - TOSH_MAKE_FLASH_OUT_OUTPUT(); - TOSH_MAKE_FLASH_CLK_OUTPUT(); - TOSH_SET_FLASH_CS_PIN(); -} - -enum { - VOLTAGE_PORT = 30, - VTHRESH = 0x1cf, // 2.7V -}; - -#endif - - - - diff --git a/tos/lib/tosboot/msp430/HPLUSART0M.nc b/tos/lib/tosboot/msp430/HPLUSART0M.nc deleted file mode 100644 index e53c9eb0..00000000 --- a/tos/lib/tosboot/msp430/HPLUSART0M.nc +++ /dev/null @@ -1,128 +0,0 @@ -// $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 - */ - -module HPLUSART0M { - provides interface HPLUSARTControl; -} -implementation { - - command void HPLUSARTControl.disableSPI() { - // USART0 SPI module disable - //ME1 &= ~USPIE0; - - // set to PUC values - ME1 = 0; - U0CTL = 1; - U0TCTL = 1; - U0RCTL = 0; - } - - command void HPLUSARTControl.setModeSPI() { - - //U0CTL = SWRST; - - // 8-bit char, SPI-mode, USART as master - U0CTL = SWRST | CHAR | SYNC | MM; - - // 3-pin + half-cycle delayed UCLK - U0TCTL |= STC + CKPH + SSEL_SMCLK; - - // as fast as possible - U0BR0 = 0x02; - U0BR1 = 0; - - // enable SPI - ME1 |= USPIE0; - - U0CTL &= ~SWRST; - - // clear interrupts - IFG1 = 0; - - } - - command void HPLUSARTControl.disableI2C() { - /* - U0CTL = 1; - U0TCTL = 1; - I2CTCTL = 0; - */ - U0CTL &= ~I2CEN; - U0CTL &= ~I2C; - I2CTCTL = 0; - call HPLUSARTControl.disableSPI(); - } - - command void HPLUSARTControl.setModeI2C() { - - // Recommended init procedure - U0CTL = I2C + SYNC + MST; - - // use 1MHz SMCLK as the I2C reference - I2CTCTL |= I2CSSEL_2 | I2CTRX; - - // Enable I2C - U0CTL |= I2CEN; - - return; - } - - command error_t HPLUSARTControl.isTxEmpty(){ - if (U0TCTL & TXEPT) { - return SUCCESS; - } - return FAIL; - } - - command error_t HPLUSARTControl.isTxIntrPending(){ - if (IFG1 & UTXIFG0){ - IFG1 &= ~UTXIFG0; - return SUCCESS; - } - return FAIL; - } - - command error_t HPLUSARTControl.isRxIntrPending(){ - if (IFG1 & URXIFG0){ - IFG1 &= ~URXIFG0; - return SUCCESS; - } - return FAIL; - } - - command void HPLUSARTControl.tx(uint8_t data){ - U0TXBUF = data; - } - - command uint8_t HPLUSARTControl.rx(){ - return U0RXBUF; - } - -} diff --git a/tos/lib/tosboot/msp430/HPLUSARTControl.nc b/tos/lib/tosboot/msp430/HPLUSARTControl.nc deleted file mode 100644 index 4e4998f7..00000000 --- a/tos/lib/tosboot/msp430/HPLUSARTControl.nc +++ /dev/null @@ -1,46 +0,0 @@ -// $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 - */ - -includes msp430usart; - -interface HPLUSARTControl { - - command void disableSPI(); - command void setModeSPI(); - command void disableI2C(); - command void setModeI2C(); - command error_t isTxEmpty(); - command error_t isTxIntrPending(); - command error_t isRxIntrPending(); - command void tx(uint8_t data); - command uint8_t rx(); - -} - diff --git a/tos/lib/tosboot/msp430/HardwareC.nc b/tos/lib/tosboot/msp430/HardwareC.nc deleted file mode 100644 index ab5ef932..00000000 --- a/tos/lib/tosboot/msp430/HardwareC.nc +++ /dev/null @@ -1,48 +0,0 @@ -// $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 - */ - -module HardwareC { - provides { - interface Hardware; - } -} - -implementation { - - command void Hardware.init() { - BCSCTL1 = RSEL0 | RSEL1 | RSEL2 | XT2OFF; - DCOCTL = DCO0 | DCO1 | DCO2; - } - - command void Hardware.reboot() { - WDTCTL = 0; - } - -} diff --git a/tos/lib/tosboot/msp430/InternalFlashC.nc b/tos/lib/tosboot/msp430/InternalFlashC.nc deleted file mode 100644 index a913bd71..00000000 --- a/tos/lib/tosboot/msp430/InternalFlashC.nc +++ /dev/null @@ -1,122 +0,0 @@ -// $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." - * - */ - -/** - * InternalFlashC.nc - Internal flash implementation for telos msp - * platform. On the msp, the flash must first be erased before a value - * can be written. However, the msp can only erase the flash at a - * segment granularity (128 bytes for the information section). This - * module allows transparent read/write of individual bytes to the - * information section by dynamically switching between the two - * provided segments in the information section. - * - * Valid address range is 0x1000 - 0x107E (0x107F is used to store the - * version number of the information segment). - * - * @author Jonathan Hui - */ - -includes InternalFlash; - -module InternalFlashC { - provides interface InternalFlash; -} - -implementation { - - enum { - IFLASH_OFFSET = 0x1000, - IFLASH_SIZE = 128, - IFLASH_SEG0_VNUM_ADDR = 0x107f, - IFLASH_SEG1_VNUM_ADDR = 0x10ff, - IFLASH_INVALID_VNUM = -1, - }; - - uint8_t chooseSegment() { - int8_t vnum0 = *(int8_t*)IFLASH_SEG0_VNUM_ADDR; - int8_t vnum1 = *(int8_t*)IFLASH_SEG1_VNUM_ADDR; - if (vnum0 == IFLASH_INVALID_VNUM) - return 1; - else if (vnum1 == IFLASH_INVALID_VNUM) - return 0; - return ( (int8_t)(vnum0 - vnum1) < 0 ); - } - - command error_t InternalFlash.write(void* addr, void* buf, uint16_t size) { - - volatile int8_t *newPtr; - int8_t *oldPtr; - int8_t *bufPtr = (int8_t*)buf; - int8_t version; - uint16_t i; - - addr += IFLASH_OFFSET; - newPtr = oldPtr = (int8_t*)IFLASH_OFFSET; - if (chooseSegment()) { - oldPtr += IFLASH_SIZE; - } - else { - addr += IFLASH_SIZE; - newPtr += IFLASH_SIZE; - } - - FCTL2 = FWKEY + FSSEL1 + FN2; - FCTL3 = FWKEY; - FCTL1 = FWKEY + ERASE; - *newPtr = 0; - FCTL1 = FWKEY + WRT; - - for ( i = 0; i < IFLASH_SIZE-1; i++, newPtr++, oldPtr++ ) { - if ((uint16_t)newPtr < (uint16_t)addr || (uint16_t)addr+size <= (uint16_t)newPtr) - *newPtr = *oldPtr; - else - *newPtr = *bufPtr++; - } - version = *oldPtr + 1; - if (version == IFLASH_INVALID_VNUM) - version++; - *newPtr = version; - - FCTL1 = FWKEY; - FCTL3 = FWKEY + LOCK; - - return SUCCESS; - - } - - command error_t InternalFlash.read(void* addr, void* buf, uint16_t size) { - - addr += IFLASH_OFFSET; - if (chooseSegment()) - addr += IFLASH_SIZE; - - memcpy(buf, addr, size); - - return SUCCESS; - - } - -} diff --git a/tos/lib/tosboot/msp430/ProgFlashM.nc b/tos/lib/tosboot/msp430/ProgFlashM.nc deleted file mode 100644 index de8b2628..00000000 --- a/tos/lib/tosboot/msp430/ProgFlashM.nc +++ /dev/null @@ -1,70 +0,0 @@ -// $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 - */ - -module ProgFlashM { - provides { - interface ProgFlash; - } -} - -implementation { - - enum { - RESET_ADDR = 0xfffe, - }; - - command error_t ProgFlash.write(in_flash_addr_t addr, uint8_t* buf, uint16_t len) { - - volatile uint16_t *flashAddr = (uint16_t*)(uint16_t)addr; - uint16_t *wordBuf = (uint16_t*)buf; - uint16_t i = 0; - - // len is 16 bits so it can't be larger than 0xffff - // make sure we can't wrap around - if (addr < (0xffff - (len >> 1))) { - FCTL2 = FWKEY + FSSEL1 + FN2; - FCTL3 = FWKEY; - FCTL1 = FWKEY + ERASE; - *flashAddr = 0; - FCTL1 = FWKEY + WRT; - for (i = 0; i < (len >> 1); i++, flashAddr++) { - if ((uint16_t)flashAddr != RESET_ADDR) - *flashAddr = wordBuf[i]; - else - *flashAddr = TOSBOOT_START; - } - FCTL1 = FWKEY; - FCTL3 = FWKEY + LOCK; - return SUCCESS; - } - return FAIL; - } - -} diff --git a/tos/lib/tosboot/msp430/VoltageC.nc b/tos/lib/tosboot/msp430/VoltageC.nc deleted file mode 100644 index 50a08f8d..00000000 --- a/tos/lib/tosboot/msp430/VoltageC.nc +++ /dev/null @@ -1,72 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -module VoltageC { - provides { - interface Voltage; - } -} - -implementation { - - enum { - VTHRESH = 0xE66, // 2.7V - }; - - command bool Voltage.okToProgram() { - - 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/stm25p/ExtFlashC.nc b/tos/lib/tosboot/stm25p/ExtFlashC.nc deleted file mode 100644 index d9c507c6..00000000 --- a/tos/lib/tosboot/stm25p/ExtFlashC.nc +++ /dev/null @@ -1,51 +0,0 @@ -// $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 - */ - -configuration ExtFlashC { - provides { - interface Init; - interface StdControl; - interface ExtFlash; - } -} - -implementation { - - components - ExtFlashM, - HPLUSART0M; - - Init = ExtFlashM; - StdControl = ExtFlashM; - ExtFlash = ExtFlashM; - - ExtFlashM.USARTControl -> HPLUSART0M; - -} diff --git a/tos/lib/tosboot/stm25p/ExtFlashM.nc b/tos/lib/tosboot/stm25p/ExtFlashM.nc deleted file mode 100644 index f3d16c02..00000000 --- a/tos/lib/tosboot/stm25p/ExtFlashM.nc +++ /dev/null @@ -1,114 +0,0 @@ -// $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 - */ - -module ExtFlashM { - provides { - interface StdControl; - interface Init; - interface ExtFlash; - } - uses { - interface HPLUSARTControl as USARTControl; - } -} - -implementation { - - command error_t Init.init() { - TOSH_MAKE_FLASH_HOLD_OUTPUT(); - TOSH_MAKE_FLASH_CS_OUTPUT(); - TOSH_SET_FLASH_HOLD_PIN(); - call USARTControl.setModeSPI(); - return SUCCESS; - } - - command error_t StdControl.start() { - return SUCCESS; - } - - command error_t StdControl.stop() { - - TOSH_CLR_FLASH_CS_PIN(); - - call USARTControl.tx(0xb9); - while(call USARTControl.isTxEmpty() != SUCCESS); - - TOSH_SET_FLASH_CS_PIN(); - - call USARTControl.disableSPI(); - - return SUCCESS; - - } - - void powerOnFlash() { - - uint8_t i; - - TOSH_CLR_FLASH_CS_PIN(); - - // command byte + 3 dummy bytes + signature - for ( i = 0; i < 5; i++ ) { - call USARTControl.tx(0xab); - while(call USARTControl.isTxIntrPending() != SUCCESS); - } - - TOSH_SET_FLASH_CS_PIN(); - - } - - command void ExtFlash.startRead(uint32_t addr) { - - uint8_t i; - - powerOnFlash(); - - TOSH_CLR_FLASH_CS_PIN(); - - // add command byte to address - addr |= (uint32_t)0x3 << 24; - - // address - for ( i = 4; i > 0; i-- ) { - call USARTControl.tx((addr >> (i-1)*8) & 0xff); - while(call USARTControl.isTxIntrPending() != SUCCESS); - } - - } - - command uint8_t ExtFlash.readByte() { - call USARTControl.rx(); - call USARTControl.tx(0); - while(call USARTControl.isRxIntrPending() != SUCCESS); - return call USARTControl.rx(); - } - - command void ExtFlash.stopRead() { - TOSH_SET_FLASH_CS_PIN(); - } - -} diff --git a/tos/lib/tosboot/telosb/InternalFlash.h b/tos/lib/tosboot/telosb/InternalFlash.h deleted file mode 100644 index aa4f8728..00000000 --- a/tos/lib/tosboot/telosb/InternalFlash.h +++ /dev/null @@ -1,45 +0,0 @@ -// $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 telos msp - * platform. On the msp, the flash must first be erased before a value - * can be written. However, the msp can only erase the flash at a - * segment granularity (128 bytes for the information section). This - * module allows transparent read/write of individual bytes to the - * information section by dynamically switching between the two - * provided segments in the information section. - * - * Valid address range is 0x1000 - 0x107E (0x107F is used to store the - * version number of the information segment). - * - * @author Jonathan Hui - */ - -#ifndef __INTERNAL_FLASH_H__ -#define __INTERNAL_FLASH_H__ - -#endif diff --git a/tos/lib/tosboot/telosb/InternalFlash.nc b/tos/lib/tosboot/telosb/InternalFlash.nc deleted file mode 100644 index ab860c0e..00000000 --- a/tos/lib/tosboot/telosb/InternalFlash.nc +++ /dev/null @@ -1,37 +0,0 @@ -// $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.nc - A generic interface to read and store values in - * the internal flash of a microcontroller. - * - * @author Jonathan Hui - */ - -interface InternalFlash { - command error_t write(void* addr, void* buf, uint16_t size); - command error_t read(void* addr, void* buf, uint16_t size); -} diff --git a/tos/lib/tosboot/telosb/PluginC.nc b/tos/lib/tosboot/telosb/PluginC.nc deleted file mode 100644 index de5a7bd3..00000000 --- a/tos/lib/tosboot/telosb/PluginC.nc +++ /dev/null @@ -1,46 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -configuration PluginC { - provides { - interface StdControl; - } -} - -implementation { - - components ExtFlashC, LedsC, PowerOffM; - - StdControl = PowerOffM; - - PowerOffM.Leds -> LedsC; - PowerOffM.SubControl -> ExtFlashC; - -} diff --git a/tos/lib/tosboot/telosb/PowerOffM.nc b/tos/lib/tosboot/telosb/PowerOffM.nc deleted file mode 100644 index 404f892a..00000000 --- a/tos/lib/tosboot/telosb/PowerOffM.nc +++ /dev/null @@ -1,85 +0,0 @@ -// $Id$ - -/* tab:2 - * - * - * "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 - */ - -module PowerOffM { - 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); - - // 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/telosb/TOSBoot_platform.h b/tos/lib/tosboot/telosb/TOSBoot_platform.h deleted file mode 100644 index afc7693a..00000000 --- a/tos/lib/tosboot/telosb/TOSBoot_platform.h +++ /dev/null @@ -1,47 +0,0 @@ -// $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 - */ - -#ifndef __TOSBOOT_PLATFORM_H__ -#define __TOSBOOT_PLATFORM_H__ - -enum { - // address of TOSBoot args in internal flash - TOSBOOT_ARGS_ADDR = 0x70, - // number of resets to force golden image - TOSBOOT_GESTURE_MAX_COUNT = 3, - // address of the golden image in external flash - TOSBOOT_GOLDEN_IMG_ADDR = 0xf0000L, - // size of each internal program flash page - TOSBOOT_INT_PAGE_SIZE = 512L, -}; - -enum { - DELUGE_MIN_ADV_PERIOD_LOG2 = 9, - DELUGE_QSIZE = 1, -}; - -#endif diff --git a/tos/lib/tosboot/telosb/hardware.h b/tos/lib/tosboot/telosb/hardware.h deleted file mode 100644 index ddfae86c..00000000 --- a/tos/lib/tosboot/telosb/hardware.h +++ /dev/null @@ -1,88 +0,0 @@ -// $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 - */ - -#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-- ); -} - -// LEDs -TOSH_ASSIGN_PIN(RED_LED, 5, 4); -TOSH_ASSIGN_PIN(GREEN_LED, 5, 5); -TOSH_ASSIGN_PIN(YELLOW_LED, 5, 6); - -// UART pins -TOSH_ASSIGN_PIN(SOMI0, 3, 2); -TOSH_ASSIGN_PIN(SIMO0, 3, 1); -TOSH_ASSIGN_PIN(UCLK0, 3, 3); -TOSH_ASSIGN_PIN(UTXD0, 3, 4); -TOSH_ASSIGN_PIN(URXD0, 3, 5); - -// User Interupt Pin -TOSH_ASSIGN_PIN(USERINT, 2, 7); - -// FLASH -TOSH_ASSIGN_PIN(FLASH_PWR, 4, 3); -TOSH_ASSIGN_PIN(FLASH_CS, 4, 4); -TOSH_ASSIGN_PIN(FLASH_HOLD, 4, 7); - -void TOSH_SET_PIN_DIRECTIONS(void) -{ - P3SEL = 0x0E; // set SPI and I2C to mod func - - P1DIR = 0xe0; - P1OUT = 0x00; - - P2DIR = 0x7b; - P2OUT = 0x10; - - P3DIR = 0xf1; - P3OUT = 0x00; - - P4DIR = 0xfd; - P4OUT = 0xdd; - - P5DIR = 0xff; - P5OUT = 0xff; - - P6DIR = 0xff; - P6OUT = 0x00; -} - -#endif diff --git a/tos/platforms/btnode3/.platform b/tos/platforms/btnode3/.platform index ac67392e..439fdd74 100644 --- a/tos/platforms/btnode3/.platform +++ b/tos/platforms/btnode3/.platform @@ -17,7 +17,7 @@ push( @includes, qw( %T/platforms/mica %T/platforms/mica2 %T/platforms/mica2/chips/cc1000 - %T/chips/cc1000 + %T/chips/cc1000_lpl %T/chips/atm128 %T/chips/atm128/adc %T/chips/atm128/i2c diff --git a/tos/platforms/btnode3/hardware.h b/tos/platforms/btnode3/hardware.h index 18062b8b..37732a76 100644 --- a/tos/platforms/btnode3/hardware.h +++ b/tos/platforms/btnode3/hardware.h @@ -51,7 +51,6 @@ #include #include -#include // A/D constants (channels, etc) enum {