From c6d9663aef7ea2f34323160158e0143cd38880cd Mon Sep 17 00:00:00 2001 From: razvanm Date: Mon, 25 Aug 2008 16:48:45 +0000 Subject: [PATCH] Deluge T2 support for Epic. This includes support for at45db161d and some refactoring and cleaning. --- apps/tests/deluge/Blink/burn | 6 +- support/make/epic.target | 5 +- support/make/tosboot.extra | 13 ++- tools/tinyos/misc/tos-deluge | 3 +- .../BlockStorageManagerC.nc | 2 +- .../BlockStorageManagerP.nc | 10 +- tos/lib/net/Deluge/DelugePageTransfer.h | 2 +- .../net/Deluge/extra/epic/TOSBoot_platform.h | 38 +++++++ .../extra/{telosb => telos}/InternalFlash.h | 0 .../extra/{telosb => telos}/InternalFlash.nc | 0 .../net/Deluge/extra/telos/ReprogramGuardC.nc | 13 +++ .../net/Deluge/extra/telos/ReprogramGuardP.nc | 23 +++++ tos/lib/tosboot/Makefile | 9 +- tos/lib/tosboot/TOSBootM.nc | 4 +- tos/lib/tosboot/epic/ExtFlashC.nc | 51 ++++++++++ tos/lib/tosboot/epic/ExtFlashM.nc | 98 +++++++++++++++++++ tos/lib/tosboot/epic/hardware.h | 86 ++++++++++++++++ tos/lib/tosboot/micaz/TOSBoot_platform.h | 12 +-- .../{telosb => msp430f1611}/InternalFlash.h | 0 .../{telosb => msp430f1611}/InternalFlash.nc | 0 .../{telosb => msp430f1611}/PluginC.nc | 0 .../{telosb => msp430f1611}/PowerOffM.nc | 0 .../TOSBoot_platform.h | 12 +-- tos/platforms/epic/.platform | 4 +- tos/platforms/epic/MotePlatformC.nc | 45 +++++++++ tos/platforms/epic/PlatformC.nc | 2 + tos/platforms/epic/PlatformP.nc | 2 + tos/platforms/epic/chips/at45db/HplAt45dbC.nc | 50 ++++++++++ tos/platforms/epic/chips/at45db/HplAt45dbP.nc | 71 ++++++++++++++ .../epic/chips/at45db/HplAt45db_chip.h | 45 +++++++++ .../telosa/chips/at45db/HplAt45dbC.nc | 18 ++-- .../telosa/chips/at45db/HplAt45dbP.nc | 26 ++--- 32 files changed, 587 insertions(+), 63 deletions(-) create mode 100644 tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h rename tos/lib/net/Deluge/extra/{telosb => telos}/InternalFlash.h (100%) rename tos/lib/net/Deluge/extra/{telosb => telos}/InternalFlash.nc (100%) create mode 100644 tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc create mode 100644 tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc create mode 100644 tos/lib/tosboot/epic/ExtFlashC.nc create mode 100644 tos/lib/tosboot/epic/ExtFlashM.nc create mode 100644 tos/lib/tosboot/epic/hardware.h rename tos/lib/tosboot/{telosb => msp430f1611}/InternalFlash.h (100%) rename tos/lib/tosboot/{telosb => msp430f1611}/InternalFlash.nc (100%) rename tos/lib/tosboot/{telosb => msp430f1611}/PluginC.nc (100%) rename tos/lib/tosboot/{telosb => msp430f1611}/PowerOffM.nc (100%) rename tos/lib/tosboot/{telosb => msp430f1611}/TOSBoot_platform.h (80%) create mode 100644 tos/platforms/epic/MotePlatformC.nc create mode 100644 tos/platforms/epic/chips/at45db/HplAt45dbC.nc create mode 100644 tos/platforms/epic/chips/at45db/HplAt45dbP.nc create mode 100644 tos/platforms/epic/chips/at45db/HplAt45db_chip.h diff --git a/apps/tests/deluge/Blink/burn b/apps/tests/deluge/Blink/burn index 1e82f5d3..e43e7b0c 100755 --- a/apps/tests/deluge/Blink/burn +++ b/apps/tests/deluge/Blink/burn @@ -22,7 +22,7 @@ if [[ $# -ne 2 && $# -ne 3 ]]; then echo "Usage: $0 [] " echo " /dev/ttyUSB0" echo " /dev/ttyUSB1" - echo " micaz, telosb or iris" + echo " micaz, telosb, iris or epic" exit 2 fi @@ -35,7 +35,7 @@ if [ $# -eq 3 ]; then PLATFORM=$3 fi -if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' -a ${PLATFORM} != 'iris' ]; then +if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' -a ${PLATFORM} != 'iris' -a ${PLATFORM} != 'epic' ]; then echo "\"${PLATFORM}\" is not a supported platform" exit 2 fi @@ -52,7 +52,7 @@ echo ============================ Compile and load Blink ======================= if [ $PLATFORM == 'micaz' ] then CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install mib510,${PPORT} -elif [ $PLATFORM == 'telosb' ] +elif [ $PLATFORM == 'telosb' -o $PLATFORM == 'epic' ] then CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install bsl,${PPORT} elif [ $PLATFORM == 'iris' ] diff --git a/support/make/epic.target b/support/make/epic.target index 8f0aadb4..02b6b4b5 100644 --- a/support/make/epic.target +++ b/support/make/epic.target @@ -11,9 +11,8 @@ OPTFLAGS += -O MSP_BSL ?= tos-bsl MSP_BSL_FLAGS = --telosb -#Update for Epic AT45 flash -#VOLUME_FILE = volumes-stm25p.xml -#VOLUME_ALLOCATOR = tos-storage-stm25p +VOLUME_FILE = volumes-at45db.xml +VOLUME_ALLOCATOR ?= tos-storage-at45db ifdef CC2420_CHANNEL PFLAGS += -DCC2420_DEF_CHANNEL=$(CC2420_CHANNEL) diff --git a/support/make/tosboot.extra b/support/make/tosboot.extra index 2420fa93..80e00688 100644 --- a/support/make/tosboot.extra +++ b/support/make/tosboot.extra @@ -10,12 +10,19 @@ ifeq ($(BOOTLOADER),tosboot) CFLAGS += -DDELUGE CFLAGS += -I$(TOSDIR)/lib/net -I$(TOSDIR)/lib/net/drip -I$(DELUGE_DIR) -I$(DELUGE_DIR)/FlashVolumeManager -I$(DELUGE_DIR)/BlockStorageManager - ifneq ($(filter telosb tmote,$(TARGETS)),) - CFLAGS += -I$(DELUGE_EXTRA) -I$(DELUGE_EXTRA)/msp430 -I$(DELUGE_EXTRA)/telos -I$(DELUGE_EXTRA)/telosb + ifneq ($(filter telosb tmote epic,$(TARGETS)),) + CFLAGS += -I$(DELUGE_EXTRA) -I$(DELUGE_EXTRA)/msp430 -I$(DELUGE_EXTRA)/telos ifeq ($(filter docs,$(GOALS)),) CFLAGS += -Wl,--section-start=.text=0x4a00,--defsym=_reset_vector__=0x4000 endif - BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/telosb/main.ihex + ifeq ($(TARGETS),telosb) + CFLAGS += -I$(DELUGE_EXTRA)/telosb + BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/telosb/main.ihex + endif + ifeq ($(TARGETS),epic) + CFLAGS += -I$(DELUGE_EXTRA)/epic + BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/epic/main.ihex + endif ifeq ($(shell [ -f /bin/cygwin1.dll ] && echo cygwin),cygwin) BOOTLOADER_IMG := $(shell cygpath -m $(BOOTLOADER_IMG)) endif diff --git a/tools/tinyos/misc/tos-deluge b/tools/tinyos/misc/tos-deluge index c1c7777f..1ca3acb5 100755 --- a/tools/tinyos/misc/tos-deluge +++ b/tools/tinyos/misc/tos-deluge @@ -41,7 +41,8 @@ DM_AMID = 0x54 SERIAL_DATA_LENGTH = 28 - 1 - 1 - 2 - 2 BAUDRATES = {'micaz': 57600, 'telosb': 115200, - 'iris': 57600} + 'iris': 57600, + 'epic': 115200} # Commands for FlashManager FM_CMD_ERASE = 0 diff --git a/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerC.nc b/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerC.nc index 5feb3031..168961d6 100644 --- a/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerC.nc +++ b/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerC.nc @@ -69,7 +69,7 @@ implementation BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE1] -> BlockStorageC_1; BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE2] -> BlockStorageC_2; BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE3] -> BlockStorageC_3; -#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) components At45dbStorageManagerC; BlockStorageManagerP.At45dbVolume -> At45dbStorageManagerC; #endif diff --git a/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerP.nc b/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerP.nc index 9fbd9e40..a6ce351f 100644 --- a/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerP.nc +++ b/tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerP.nc @@ -37,7 +37,7 @@ generic module BlockStorageManagerP(uint8_t clients) interface VolumeId[uint8_t client]; #if defined(PLATFORM_TELOSB) interface StorageMap as SubStorageMap[volume_id_t volume_id]; -#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) +#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) interface At45dbVolume[volume_id_t volume_id]; #endif } @@ -180,13 +180,7 @@ implementation storage_addr_t p_addr = 0xFFFFFFFF; #if defined(PLATFORM_TELOSB) p_addr = call SubStorageMap.getPhysicalAddress[volume_id](addr); -#elif defined(PLATFORM_MICAZ) - at45page_t page = call At45dbVolume.remap[volume_id]((addr >> AT45_PAGE_SIZE_LOG2)); - at45pageoffset_t offset = addr & ((1 << AT45_PAGE_SIZE_LOG2) - 1); - p_addr = page; - p_addr = p_addr << AT45_PAGE_SIZE_LOG2; - p_addr += offset; -#elif defined(PLATFORM_IRIS) +#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) at45page_t page = call At45dbVolume.remap[volume_id]((addr >> AT45_PAGE_SIZE_LOG2)); at45pageoffset_t offset = addr & ((1 << AT45_PAGE_SIZE_LOG2) - 1); p_addr = page; diff --git a/tos/lib/net/Deluge/DelugePageTransfer.h b/tos/lib/net/Deluge/DelugePageTransfer.h index c491dffb..f3d6c652 100644 --- a/tos/lib/net/Deluge/DelugePageTransfer.h +++ b/tos/lib/net/Deluge/DelugePageTransfer.h @@ -31,7 +31,7 @@ #ifndef DELUGEPAGETRANSFER_H #define DELUGEPAGETRANSFER_H -#if defined(PLATFORM_TELOSB) +#if defined(PLATFORM_TELOSB) || defined(PLATFORM_EPIC) #include "extra/telosb/TOSBoot_platform.h" #elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) #include "extra/micaz/TOSBoot_platform.h" diff --git a/tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h b/tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h new file mode 100644 index 00000000..c892207f --- /dev/null +++ b/tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h @@ -0,0 +1,38 @@ +// $Id$ + +/* + * "Copyright (c) 2000-2005 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + */ + +/** + * @author Jonathan Hui + */ + +#ifndef __TOSBOOT_PLATFORM_H__ +#define __TOSBOOT_PLATFORM_H__ + +enum { + TOSBOOT_ARGS_ADDR = 0x70, // address of TOSBoot args in internal flash + TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image + TOSBOOT_GOLDEN_IMG_ADDR = 0x0L, // address of the golden image in external flash + TOSBOOT_INT_PAGE_SIZE = 512L, // size of each internal program flash page +}; + +#endif diff --git a/tos/lib/net/Deluge/extra/telosb/InternalFlash.h b/tos/lib/net/Deluge/extra/telos/InternalFlash.h similarity index 100% rename from tos/lib/net/Deluge/extra/telosb/InternalFlash.h rename to tos/lib/net/Deluge/extra/telos/InternalFlash.h diff --git a/tos/lib/net/Deluge/extra/telosb/InternalFlash.nc b/tos/lib/net/Deluge/extra/telos/InternalFlash.nc similarity index 100% rename from tos/lib/net/Deluge/extra/telosb/InternalFlash.nc rename to tos/lib/net/Deluge/extra/telos/InternalFlash.nc diff --git a/tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc b/tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc new file mode 100644 index 00000000..9f25e503 --- /dev/null +++ b/tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc @@ -0,0 +1,13 @@ +configuration ReprogramGuardC +{ + provides interface ReprogramGuard; +} + +implementation +{ + components ReprogramGuardP; + components new VoltageC(); + + ReprogramGuard = ReprogramGuardP; + ReprogramGuardP.Voltage -> VoltageC; +} diff --git a/tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc b/tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc new file mode 100644 index 00000000..1ffb1e9a --- /dev/null +++ b/tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc @@ -0,0 +1,23 @@ +module ReprogramGuardP +{ + provides interface ReprogramGuard; + uses interface Read as Voltage; +} + +implementation +{ + enum { + VTHRESH = 0xE66, // 2.7V + }; + + command error_t ReprogramGuard.okToProgram() + { + return call Voltage.read(); + } + + event void Voltage.readDone(error_t result, uint16_t val) + { + signal ReprogramGuard.okToProgramDone(result == SUCCESS && val > VTHRESH); + } + +} diff --git a/tos/lib/tosboot/Makefile b/tos/lib/tosboot/Makefile index 5551bc79..605bbbb4 100644 --- a/tos/lib/tosboot/Makefile +++ b/tos/lib/tosboot/Makefile @@ -67,7 +67,14 @@ endif ifeq ($(MAKECMDGOALS),telosb) CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00 - CFLAGS += -Imsp430 -Istm25p -Itelosb -Ilib + CFLAGS += -Imsp430 -Imsp430f1611 -Istm25p -Itelosb -Ilib + CFLAGS += -I../net/Deluge + POST_BUILD_EXTRA_DEPS += strip_iv +endif + +ifeq ($(MAKECMDGOALS),epic) + CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00 + CFLAGS += -Imsp430 -Imsp430f1611 -Iepic -Ilib CFLAGS += -I../net/Deluge POST_BUILD_EXTRA_DEPS += strip_iv endif diff --git a/tos/lib/tosboot/TOSBootM.nc b/tos/lib/tosboot/TOSBootM.nc index fa1893c7..e04718f4 100644 --- a/tos/lib/tosboot/TOSBootM.nc +++ b/tos/lib/tosboot/TOSBootM.nc @@ -120,7 +120,7 @@ implementation { startAddr + addr, DELUGE_BYTES_PER_PAGE)) { if (i == 0) while (1) - call Leds.flash(1); + call Leds.flash(2); return FALSE; } addr += DELUGE_BYTES_PER_PAGE; @@ -147,7 +147,7 @@ implementation { secLength = extFlashReadAddr(); curAddr = curAddr + 8; -#if defined(PLATFORM_TELOSB) +#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) if (intAddr != TOSBOOT_END) { #elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) if (intAddr != 0) { diff --git a/tos/lib/tosboot/epic/ExtFlashC.nc b/tos/lib/tosboot/epic/ExtFlashC.nc new file mode 100644 index 00000000..9f7d5347 --- /dev/null +++ b/tos/lib/tosboot/epic/ExtFlashC.nc @@ -0,0 +1,51 @@ +// $Id$ + +/* + * + * + * "Copyright (c) 2000-2005 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + */ + +/** + * @author Jonathan Hui + */ + +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/epic/ExtFlashM.nc b/tos/lib/tosboot/epic/ExtFlashM.nc new file mode 100644 index 00000000..a80ecabe --- /dev/null +++ b/tos/lib/tosboot/epic/ExtFlashM.nc @@ -0,0 +1,98 @@ +// $Id$ + +/* + * "Copyright (c) 2000-2005 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + */ + +/** + * @author Jonathan Hui + * @author Razvan Musaloiu-E. + */ + +module ExtFlashM { + provides { + interface StdControl; + interface Init; + interface ExtFlash; + } + uses { + interface HPLUSARTControl as USARTControl; + } +} + +implementation { + + uint32_t addr; + + command error_t Init.init() { + TOSH_MAKE_FLASH_CS_OUTPUT(); + TOSH_SET_FLASH_CS_PIN(); + call USARTControl.setModeSPI(); + return SUCCESS; + } + + command error_t StdControl.start() { + return SUCCESS; + } + + command error_t StdControl.stop() { + call USARTControl.disableSPI(); + return SUCCESS; + } + + command void ExtFlash.startRead(uint32_t newAddr) { + + uint8_t cmd[4]; + uint8_t i; + uint32_t page = newAddr / 512; + uint32_t offset = newAddr % 512; + + addr = newAddr; + + cmd[0] = 0x03; + cmd[1] = page >> 6; + cmd[2] = (page << 2) | (offset >> 8); + cmd[3] = offset; + + TOSH_CLR_FLASH_CS_PIN(); + + for ( i = 0; i < sizeof(cmd); i++ ) { + call USARTControl.tx(cmd[i]); + while(call USARTControl.isTxEmpty() != SUCCESS); + } + } + + command uint8_t ExtFlash.readByte() { + if (!(addr & 0x1ff)) { + call ExtFlash.stopRead(); + call ExtFlash.startRead(addr); + } + addr++; + 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/epic/hardware.h b/tos/lib/tosboot/epic/hardware.h new file mode 100644 index 00000000..281de0a9 --- /dev/null +++ b/tos/lib/tosboot/epic/hardware.h @@ -0,0 +1,86 @@ +// $Id$ + +/* + * + * + * "Copyright (c) 2000-2005 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + */ + +/** + * @author Jonathan Hui + */ + +#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, 4, 0); +TOSH_ASSIGN_PIN(GREEN_LED, 4, 3); +TOSH_ASSIGN_PIN(YELLOW_LED, 4, 7); + +// 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_CS, 4, 4); + +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/micaz/TOSBoot_platform.h b/tos/lib/tosboot/micaz/TOSBoot_platform.h index 91300751..17477461 100644 --- a/tos/lib/tosboot/micaz/TOSBoot_platform.h +++ b/tos/lib/tosboot/micaz/TOSBoot_platform.h @@ -29,14 +29,10 @@ #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, + TOSBOOT_ARGS_ADDR = 0xff0, // address of TOSBoot args in internal flash + TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image + TOSBOOT_GOLDEN_IMG_ADDR = 0x0L, // address of the golden image in external flash + TOSBOOT_INT_PAGE_SIZE = SPM_PAGESIZE, // size of each internal program flash page }; enum { diff --git a/tos/lib/tosboot/telosb/InternalFlash.h b/tos/lib/tosboot/msp430f1611/InternalFlash.h similarity index 100% rename from tos/lib/tosboot/telosb/InternalFlash.h rename to tos/lib/tosboot/msp430f1611/InternalFlash.h diff --git a/tos/lib/tosboot/telosb/InternalFlash.nc b/tos/lib/tosboot/msp430f1611/InternalFlash.nc similarity index 100% rename from tos/lib/tosboot/telosb/InternalFlash.nc rename to tos/lib/tosboot/msp430f1611/InternalFlash.nc diff --git a/tos/lib/tosboot/telosb/PluginC.nc b/tos/lib/tosboot/msp430f1611/PluginC.nc similarity index 100% rename from tos/lib/tosboot/telosb/PluginC.nc rename to tos/lib/tosboot/msp430f1611/PluginC.nc diff --git a/tos/lib/tosboot/telosb/PowerOffM.nc b/tos/lib/tosboot/msp430f1611/PowerOffM.nc similarity index 100% rename from tos/lib/tosboot/telosb/PowerOffM.nc rename to tos/lib/tosboot/msp430f1611/PowerOffM.nc diff --git a/tos/lib/tosboot/telosb/TOSBoot_platform.h b/tos/lib/tosboot/msp430f1611/TOSBoot_platform.h similarity index 80% rename from tos/lib/tosboot/telosb/TOSBoot_platform.h rename to tos/lib/tosboot/msp430f1611/TOSBoot_platform.h index 0522d6b4..e880dd13 100644 --- a/tos/lib/tosboot/telosb/TOSBoot_platform.h +++ b/tos/lib/tosboot/msp430f1611/TOSBoot_platform.h @@ -29,14 +29,10 @@ #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, + TOSBOOT_ARGS_ADDR = 0x70, // address of TOSBoot args in internal flash + TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image + TOSBOOT_GOLDEN_IMG_ADDR = 0xf0000L, // address of the golden image in external flash + TOSBOOT_INT_PAGE_SIZE = 512L, // size of each internal program flash page }; enum { diff --git a/tos/platforms/epic/.platform b/tos/platforms/epic/.platform index b33fc030..5fa10d9e 100644 --- a/tos/platforms/epic/.platform +++ b/tos/platforms/epic/.platform @@ -10,6 +10,7 @@ push( @includes, qw( %T/platforms/epic + %T/platforms/epic/chips/at45db %T/platforms/telosa %T/platforms/telosa/chips/cc2420 %T/chips/cc2420 @@ -32,8 +33,7 @@ push( @includes, qw( %T/chips/msp430/timer %T/chips/msp430/usart %T/chips/msp430/sensors -# TODO -# %T/chips/at45db161d + %T/chips/at45db %T/lib/timer %T/lib/serial %T/lib/adc diff --git a/tos/platforms/epic/MotePlatformC.nc b/tos/platforms/epic/MotePlatformC.nc new file mode 100644 index 00000000..5636b321 --- /dev/null +++ b/tos/platforms/epic/MotePlatformC.nc @@ -0,0 +1,45 @@ +module MotePlatformC @safe() { + provides interface Init; +} +implementation { + + command error_t Init.init() { + // reset all of the ports to be input and using i/o functionality + atomic + { + P1SEL = 0; + P2SEL = 0; + P3SEL = 0; + P4SEL = 0; + P5SEL = 0; + P6SEL = 0; + + P1OUT = 0x00; + P1DIR = 0xe0; + + P2OUT = 0x30; + P2DIR = 0x7b; + + P3OUT = 0x00; + P3DIR = 0xf1; + + P4OUT = 0xdd; + P4DIR = 0xfd; + + P5OUT = 0xff; + P5DIR = 0xff; + + P6OUT = 0x00; + P6DIR = 0xff; + + P1IE = 0; + P2IE = 0; + + // the commands above take care of the pin directions + // there is no longer a need for explicit set pin + // directions using the TOSH_SET/CLR macros + + }//atomic + return SUCCESS; + } +} diff --git a/tos/platforms/epic/PlatformC.nc b/tos/platforms/epic/PlatformC.nc index c0cd4a17..b36f1f35 100644 --- a/tos/platforms/epic/PlatformC.nc +++ b/tos/platforms/epic/PlatformC.nc @@ -40,7 +40,9 @@ configuration PlatformC { implementation { components PlatformP; components MoteClockC; + components MotePlatformC; Init = PlatformP; PlatformP.MoteClockInit -> MoteClockC; + PlatformP.MoteInit -> MotePlatformC; } diff --git a/tos/platforms/epic/PlatformP.nc b/tos/platforms/epic/PlatformP.nc index 582e665f..acb3afbe 100644 --- a/tos/platforms/epic/PlatformP.nc +++ b/tos/platforms/epic/PlatformP.nc @@ -38,12 +38,14 @@ module PlatformP { } uses { interface Init as MoteClockInit; + interface Init as MoteInit; interface Init as LedsInit; } } implementation { command error_t Init.init() { call MoteClockInit.init(); + call MoteInit.init(); call LedsInit.init(); return SUCCESS; } diff --git a/tos/platforms/epic/chips/at45db/HplAt45dbC.nc b/tos/platforms/epic/chips/at45db/HplAt45dbC.nc new file mode 100644 index 00000000..ef992a8a --- /dev/null +++ b/tos/platforms/epic/chips/at45db/HplAt45dbC.nc @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2006, Technische Universitat Berlin +* 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 Technische Universitat Berlin 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 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. +*/ + +configuration HplAt45dbC { + provides interface HplAt45db; +} +implementation { + + components new HplAt45dbByteC(10), + new Msp430Spi0C() as Spi, + HplAt45dbP, + HplMsp430GeneralIOC as MspGeneralIO, + new Msp430GpioC() as Select; + + HplAt45db = HplAt45dbByteC; + + HplAt45dbByteC.Resource -> Spi; + HplAt45dbByteC.FlashSpi -> Spi; + HplAt45dbByteC.HplAt45dbByte -> HplAt45dbP; + + Select -> MspGeneralIO.Port44; + HplAt45dbP.Select -> Select; + HplAt45dbP.FlashSpi -> Spi; +} diff --git a/tos/platforms/epic/chips/at45db/HplAt45dbP.nc b/tos/platforms/epic/chips/at45db/HplAt45dbP.nc new file mode 100644 index 00000000..b3be5b95 --- /dev/null +++ b/tos/platforms/epic/chips/at45db/HplAt45dbP.nc @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006, Technische Universitat Berlin +* 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 Technische Universitat Berlin 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 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. +*/ + + +module HplAt45dbP { + provides { + interface HplAt45dbByte; + } + uses { + interface SpiByte as FlashSpi; + interface GeneralIO as Select; + } +} +implementation +{ + command void HplAt45dbByte.select() { + call Select.clr(); + } + + command void HplAt45dbByte.deselect() { + call Select.set(); + } + + task void idleTask() { + uint8_t status; + status = call FlashSpi.write(0); + if (!(status & 0x80)) { + post idleTask(); + } else { + //printf("idle: %d\n", status); + signal HplAt45dbByte.idle(); + } + } + + command void HplAt45dbByte.waitIdle() { + post idleTask(); + } + + command bool HplAt45dbByte.getCompareStatus() { + uint8_t status; + status = call FlashSpi.write(0); + //printf("s: %d\n", status); + return (!(status & 0x40)); + } +} diff --git a/tos/platforms/epic/chips/at45db/HplAt45db_chip.h b/tos/platforms/epic/chips/at45db/HplAt45db_chip.h new file mode 100644 index 00000000..303b351c --- /dev/null +++ b/tos/platforms/epic/chips/at45db/HplAt45db_chip.h @@ -0,0 +1,45 @@ +// $Id$ + +/* + * "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-2006 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. + */ + +#ifndef HPLAT45DB_CHIP_H +#define HPLAT45DB_CHIP_H + +// flash characteristics +enum { + AT45_MAX_PAGES = 4096, + AT45_PAGE_SIZE = 528, + AT45_PAGE_SIZE_LOG2 = 9 // For those who want to ignore the last 8 bytes +}; + +typedef uint16_t at45page_t; +typedef uint16_t at45pageoffset_t; /* must fit 0 to AT45_PAGE_SIZE - 1 */ + +#endif diff --git a/tos/platforms/telosa/chips/at45db/HplAt45dbC.nc b/tos/platforms/telosa/chips/at45db/HplAt45dbC.nc index b48ffbab..61ed0f01 100644 --- a/tos/platforms/telosa/chips/at45db/HplAt45dbC.nc +++ b/tos/platforms/telosa/chips/at45db/HplAt45dbC.nc @@ -32,19 +32,19 @@ configuration HplAt45dbC { } implementation { - components new HplAt45dbByteC(9), - new Msp430Spi0C() as Spi, - HplAt45dbP, - HplMsp430GeneralIOC as MspGeneralIO, - new Msp430GpioC() as Select; + components new HplAt45dbByteC(9), + new Msp430Spi0C() as Spi, + HplAt45dbP, + HplMsp430GeneralIOC as MspGeneralIO, + new Msp430GpioC() as Select; - HplAt45db = HplAt45dbByteC; + HplAt45db = HplAt45dbByteC; HplAt45dbByteC.Resource -> Spi; HplAt45dbByteC.FlashSpi -> Spi; HplAt45dbByteC.HplAt45dbByte -> HplAt45dbP; - Select -> MspGeneralIO.Port44; - HplAt45dbP.Select -> Select; - HplAt45dbP.FlashSpi -> Spi; + Select -> MspGeneralIO.Port44; + HplAt45dbP.Select -> Select; + HplAt45dbP.FlashSpi -> Spi; } diff --git a/tos/platforms/telosa/chips/at45db/HplAt45dbP.nc b/tos/platforms/telosa/chips/at45db/HplAt45dbP.nc index b7e73980..79fc4c00 100644 --- a/tos/platforms/telosa/chips/at45db/HplAt45dbP.nc +++ b/tos/platforms/telosa/chips/at45db/HplAt45dbP.nc @@ -33,7 +33,7 @@ module HplAt45dbP { interface HplAt45dbByte; } uses { - interface SpiByte as FlashSpi; + interface SpiByte as FlashSpi; interface GeneralIO as Select; } } @@ -47,23 +47,23 @@ implementation call Select.set(); } - task void idleTask() { - uint8_t status; - status = call FlashSpi.write(0); - if (!(status & 0x80)) { - post idleTask(); - } else { - signal HplAt45dbByte.idle(); - } - } + task void idleTask() { + uint8_t status; + status = call FlashSpi.write(0); + if (!(status & 0x80)) { + post idleTask(); + } else { + signal HplAt45dbByte.idle(); + } + } command void HplAt45dbByte.waitIdle() { - post idleTask(); + post idleTask(); } command bool HplAt45dbByte.getCompareStatus() { - uint8_t status; - status = call FlashSpi.write(0); + uint8_t status; + status = call FlashSpi.write(0); return (!(status & 0x40)); } } -- 2.39.2