2007/08/18

Build Octopus develop environment

What is Octopus?

1. Install Moteiv's Tmote Tools from http://www.moteiv.com/

If already installed Cygwin, I recommend uninstall Cygwin firstly. Secondly,
to run setup.msi from tmote-tools-2_0_5.zip. Finally, to upgrade or install
other Cygwin packages.

2. Copy and Modify target file


shell> cd /opt/moteiv/tools/make/
shell:/opt/moteiv/tools/make/> cp tmote.target octopus.target



octopus.target




...

-PLATFORM ?= tmote
+PLATFORM ?= octopus

...

-CFLAGS += \
--I$(MOTEIV_DIR)/tos/platform/tmote \
--I$(MOTEIV_DIR)/tos/platform/tmote/util/uartdetect \
+CFLAGS += \
+-I$(MOTEIV_DIR)/tos/platform/octopus \
+-I$(MOTEIV_DIR)/tos/platform/octopus/util/uartdetect \

...

- BOOTLOADER ?= $(MOTEIV_DIR)/tos/lib/Deluge/TOSBoot/build/tmote/main.ihex
+ BOOTLOADER ?= $(MOTEIV_DIR)/tos/lib/Deluge/TOSBoot/build/octopus/main.ihex

...

-tmote: $(BUILD_DEPS)
+octopus: $(BUILD_DEPS)

...




3. Create octopus directory


shell> cp -r /opt/moteiv/tos/platform/tmote /opt/moteiv/tos/platform/octopus



4. Modify hardware.h file

/opt/moteiv/tos/platform/octopus/hardware.h




...

// LEDs
TOSH_ASSIGN_PIN(RED_LED, 5, 4);
TOSH_ASSIGN_PIN(GREEN_LED, 5, 5);
-TOSH_ASSIGN_PIN(YELLOW_LED, 5, 6);
+TOSH_ASSIGN_PIN(YELLOW_LED, 5, 3);
+TOSH_ASSIGN_PIN(BLUE_LED, 5, 6);

...

TOSH_ASSIGN_PIN(STE1, 5, 0);
+TOSH_ASSIGN_PIN(BUFFER_CS, 4, 3);

// ADC
TOSH_ASSIGN_PIN(ADC0, 6, 0);

...

// FLASH
-TOSH_ASSIGN_PIN(FLASH_PWR, 4, 3);
+TOSH_ASSIGN_PIN(FLASH_W, 4, 0);
TOSH_ASSIGN_PIN(FLASH_CS, 4, 4);

...




5. Copy and Modify HPLUSART1M.nc file


shell> cp /opt/moteiv/tos/platform/msp430/HPLUSART1M.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/HPLUSART1M.nc




...

async command result_t USARTControl.tx(uint8_t data){
atomic {
+ TOSH_CLR_BUFFER_CS_PIN();
U1TXBUF = data;
}
return SUCCESS;
}

...




6. Copy and Modify Leds.nc file


shell> cp /opt/tinyos-1.x/tos/interfaces/Leds.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/Leds.nc




interface Leds {

...

/**
* Toggle the yellow LED. If it was on, turn it off. If it was off,
* turn it on.
*
* @return SUCCESS always.
*
*/
async command result_t yellowToggle();

+ async command result_t blueOn();
+ async command result_t blueOff();
+ async command result_t blueToggle();

/**
* Get current Leds information
*
* @return A uint8_t typed value representing Leds status
*
*/
async command uint8_t get();

...
}



7. Copy and Modify LedsC.nc file


shell> cp /opt/tinyos-1.x/tos/system/LedsC.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/LedsC.nc




...

enum {
- RED_BIT = 1,
- GREEN_BIT = 2,
- YELLOW_BIT = 4
+ BLUE_BIT = 1,
+ GREEN_BIT = 2,
+ RED_BIT = 4,
+ YELLOW_BIT = 8
};

async command result_t Leds.init() {
atomic {
ledsOn = 0;
dbg(DBG_BOOT, "LEDS: initialized.\n");
TOSH_MAKE_RED_LED_OUTPUT();
TOSH_MAKE_YELLOW_LED_OUTPUT();
TOSH_MAKE_GREEN_LED_OUTPUT();
+ TOSH_MAKE_BLUE_LED_OUTPUT();
TOSH_SET_RED_LED_PIN();
TOSH_SET_YELLOW_LED_PIN();
TOSH_SET_GREEN_LED_PIN();
+ TOSH_SET_BLUE_LED_PIN();
}
return SUCCESS;
}

...

async command result_t Leds.yellowToggle() {
result_t rval;
atomic {
if (ledsOn & YELLOW_BIT)
rval = call Leds.yellowOff();
else
rval = call Leds.yellowOn();
}
return rval;
}

+ async command result_t Leds.blueOn() {
+ dbg(DBG_LED, "LEDS: Blue on.\n");
+ atomic {
+ TOSH_CLR_BLUE_LED_PIN();
+ ledsOn |= BLUE_BIT;
+ }
+ return SUCCESS;
+ }

+ async command result_t Leds.blueOff() {
+ dbg(DBG_LED, "LEDS: Blue off.\n");
+ atomic {
+ TOSH_SET_BLUE_LED_PIN();
+ ledsOn &= ~BLUE_BIT;
+ }
+ return SUCCESS;
+ }

+ async command result_t Leds.blueToggle() {
+ result_t rval;
+ atomic {
+ if (ledsOn & BLUE_BIT)
+ rval = call Leds.blueOff();
+ else
+ rval = call Leds.blueOn();
+ }
+ return rval;
+ }

async command uint8_t Leds.get() {
uint8_t rval;
atomic {
rval = ledsOn;
}
return rval;
}

async command result_t Leds.set(uint8_t ledsNum) {
atomic {
- ledsOn = (ledsNum & 0x7);
+ ledsOn = (ledsNum & 0xF);
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();
+ if (ledsOn & BLUE_BIT)
+ TOSH_CLR_BLUE_LED_PIN();
+ else
+ TOSH_SET_BLUE_LED_PIN();
}
return SUCCESS;
}

...




8. Copy MSP430ClockM.nc file


shell> cp /opt/moteiv/tos/platform/msp430/timer/MSP430ClockM.nc /opt/moteiv/tos/platform/octopus/



9. Copy and Modify MSP430GeneralIOM.nc file


shell> cp /opt/tinyos-1.x/tos/platform/msp430/MSP430GeneralIOM.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/MSP430GeneralIOM.nc




...

- async command uint8_t Port12.getRaw() { return TOSH_READ_PORT12_PIN(); }
- async command bool Port12.get() { return TOSH_READ_PORT12_PIN() != 0; }
+ async command uint8_t Port12.getRaw() { TOSH_READ_PORT12_PIN(); return 1;}
+ async command bool Port12.get() { TOSH_READ_PORT12_PIN(); return 1;}

...




10. Copy and Modify NoLeds.nc file


shell> cp /opt/moteiv/tinyos-1.x/tos/system/NoLeds.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/NoLeds.nc




...

async command result_t Leds.yellowToggle() {
return SUCCESS;
}

+ async command result_t Leds.blueOn() {
+ return SUCCESS;
+ }

+ async command result_t Leds.blueOff() {
+ return SUCCESS;
+ }

+ async command result_t Leds.blueToggle() {
+ return SUCCESS;
+ }

async command uint8_t Leds.get() {
return 0;
}

...




11. Modify and Compile SerialByteSource.java file

/opt/tinyos-1.x/tools/java/net/tinyos/packet/SerialByteSource.java




...

public void openStreams() throws IOException {

...

try {
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
serialPort.setSerialPortParams(baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);

+ // elva set COM port pin(DTR) to LOW
+ serialPort.setDTR(false);
+ // elva end of modify

serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
}

...

is = serialPort.getInputStream();
os = serialPort.getOutputStream();

+ // elva delay for mote reboot
+ try {
+ Thread.sleep(1300);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ // elva end of modify
}

...



Complie SerialByteSource.java file


shell> cd /opt/tinyos-1.x/tools/java/net/tinyos/packet
shell:/opt/tinyos-1.x/tools/java/net/tinyos/packet> javac SerialByteSource.java



appendix 1. Make an example application


shell> cd /opt/moteiv/apps/Count/CountLeds
shell:/opt/moteiv/apps/Count/CountLeds> make octopus



appendix 2. Run an example application


shell> export MOTECOM=serial@COM6:tmote
shell> cd /opt/tinyos-1.x/tools/java/net/tinyos/tools
shell:/opt/tinyos-1.x/tools/java/net/tinyos/tools> java net.tinyos.tools.Listen



appendix 3. Set Node ID: 5

shell:/opt/moteiv/apps/Count/CountLeds> /opt/tinyos-1.x/tools/make/msp/set-mote-id --objcopy msp430-objcopy --objdump msp430-objdump --target ihex build/octopus/main.ihex build/octopus/main.ihex.out-5 5

No comments:

Post a Comment