Imote2 with Camera setup IMB400 over Ubuntu 9.10/10.04

Imote2 Camera driver for TinyOS is available in contribution directory of TinyOS 2.x. It goes by the name of tinyos-2.x-contrib.
Its location within is tinyos-2.x-contrib/intelmote2/apps

I am assuming that you have tinyos-2.1.1 installed, this is required to have Camera Driver build.
If you dont have it installed... than better have it done by invoking:

apt-get install tinyos-2.1.1

From here on to get the driver working, the procedure is as follows:

Browse to opt directory.





cd /opt

The recommended way to get the source of tinyos-2.x and tinyos-2.x-contribis is through CVS.

echo "Getting TinyOS 2.x and TinyOS 2.x-contrib from CVS"
echo "Press enter when asked for password."
cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login
cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P tinyos-2.x
cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P tinyos-2.x-contrib

--OR-- 

echo "Getting TinyOS 2.x and TinyOS 2.x-contrib from GIT"
#git clone git://hinrg.cs.jhu.edu/git/tinyos-2.x.git tinyos-2.x
git clone git://github.com/tyll/tinyos-2.x.git tinyos-2.x
git clone git://github.com/tyll/tinyos-2.x-contrib.git tinyos-2.x-contrib

{I found CVS not working for me, so I found solution for it to get it from GIT}

{github is ok to get the code. I found hinrg not working for me initially.}

Do set appropriate environment variables for tinyos-2.x. Remember this will change the variable values, which are by default set to tinyos-2.1.1 if you have installed it. 

If you don't set the following environment variables in your terminal sessions you wont be able to build your code. You can make the following part of your script and execute is when you plan to use tinyos-2.x





export TOSDIR=$TOSROOT/tos
export INTELMOTE2_CONTRIB_DIR=$TOSROOT-contrib/intelmote2
export MAKERULES=$TOSROOT/support/make/Makerules
export TOSMAKE_PATH=$INTELMOTE2_CONTRIB_DIR/support/make
export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
export LGL_CONTRIB=$INTELMOTE2_CONTRIB_DIR

For Imote2 since it is equipped with XScale, so you will be needing to install xscale tools.

Download the tools from the following location:


After downloading, you will be running the following command in the downloaded folder:

dpkg --install xscale-elf-binutils-2.15-2.i386.deb
dpkg --install xscale-elf-gcc-3.4.3-2.i386.deb
dpkg --install xscale-elf-newlib-1.13.0-1.i386.deb

--OR--

dpkg --install --force-all xscale-elf-binutils-2.15-2.i386.deb
dpkg --install --force-all xscale-elf-gcc-3.4.3-2.i386.deb
dpkg --install --force-all xscale-elf-newlib-1.13.0-1.i386.deb

{IF YOU HAVE tinyos-2.1.1 already installed, THAN YOU WILL NOT BE ABLE TO INSTALL ONE OF THE ABOVE, 
FOR THIS YOU WILL BE REQUIRING TO RUN DKPG WITH --force-all ARGUMENT}

The error it shows while installing is that it cannot replace libiberty.a in /usr/lib/libiberty.a
So for this --force-all argument is required.

Here on you will be needing the openocd.

DONT RUN apt-get install openocd, IT JUST WONT WORK. If you do so, and build with it, than it will give you socket error 111. 

Openocd is no longer available via SVN, however it is mentioned on http://docs.tinyos.net/index.php/OpenOCD_for_IMote2, so the only method is to get it is from GIT.

git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
git checkout 3b2a068ea997323eb37251b31be8034c57ff9def
cd openocd
 ./bootstrap
 ./configure --enable-maintainer-mode --enable-ft2232_ftd2xx 
echo installing OpenOCD
sudo make $PARALLEL
sudo make install

If you face any issue here showing appropriate tools missing to build openocd, like I did when it was looking for makeinfo, located in apt-get install texinfo, and for automake, apt-get install automake, for autoconf, apt-get install autoconf, for libtools apt-get install libtool, for libftdi1, apt-get install libftdi1 and apt-get install libftdi-dev, or just try to install them by searching apt-cache search 

chmod 4755 /usr/local/bin/openocd 
cd /opt/tinyos-2.x/tools/platforms/intelmote2/openocd/

We need to replace the imote2-ocd-program because it pointes to arm-usb-tiny.cfg file, which no longer works, for this we need to modify the line 
openocd -f arm-usb-tiny.cfg 
TO 
openocd -f interface/olimex-jtag-tiny.cfg -f board/crossbow_tech_imote2.cfg

We do this by the following scriplet.
mv imote2-ocd-program.py imote2-ocd-program_old.py
wget http://www.cs.columbia.edu/~msz/wsn/scripts/imote2-ocd-program.py
chmod +x imote2-ocd-program.py
cd /opt/tinyos-2.x-contrib/intelmote2/tools/platforms/intelmote2/openocd/
mv imote2-ocd-program.py imote2-ocd-program_old.py
wget http://www.cs.columbia.edu/~msz/wsn/scripts/imote2-ocd-program.py
chmod +x imote2-ocd-program.py
Thanks to http://www.cs.columbia.edu/~msz/wsn for providing with it. Though the scripts mentioned for 10.04 is not working. 


After this try browsing to the 

cd /opt/tinyos-2.x-contrib/intelmote2/apps/cameraMultiHop/rootNode

Compile the first code:
make intelmote2 install openocd

If you see something like 

Starting OpenOCD...
Connecting to OpenOCD
...
Erasing flash
Writing flash

This means you have setup the required environment to work and proceed with Imote2 Camera Driver. If you see that the OpenOCD halted, than press CTRL+C and than the restart button on the interface board. Try make intelmote2 install openocd again.

If you try to compile the cameraTestJpegSerial driver, tinyos-2.x-contrib/intelmote2/apps/cameraTestJpegSerial, you will see programming errors reported. 

To fix these you just need to change #include "xbowCam.h" to "XbowCam.h" in cameraJpegTestM.nc
Also you will be required to change the filename tinyos-2.x-contrib/intelmote2/tos/sensorboards/xbow_cb/xbowCam.hto XbowCam.h

This will fix cameraTestJpegSerial.

We can now execute cameraTestJpegSerial but first we will be required to invoke TinyOS SerialForwarder in another terminal:

java net.tinyos.sf.SerialForwarder -comm serial@/dev/ttyUSB1:115200 -port 9002

If you see the error like below

The toscomm JNI library was not found.
Check that your tinyos-tools package is installed and try
rerunning tos-install-jni.
Aborting.

This means that your tos jni is corrupted. Invoking the tos-install-jni will not fix this problem. You will have to give path of library manually where ever you see this problem. The path can be obtained by invoking tos-locate-jre --jni
Hence the command will be 

java -Djava.library.path=/usr/lib/jvm/java-6-sun/jre/lib/i386 net.tinyos.sf.SerialForwarder -comm serial@/dev/ttyUSB1:115200 -port 9002

I am assuming that you have the jtag and the usb mini B connected to /dev/ttyUSB0 and /dev/ttyUSB1. Make sure that both are connected to the same interface board, i.e. the one having jtag port, obviously when you are programming. 

The above is the gui of serial forwarder. You can run command line of it also by invoking 
sf 9002 serial@/dev/ttyUSB1 115200

sf is located in tinyos-2.x/support/sdk/c/sf/

After running serial forwader, either the GUI or command line one, we browse to the following folder and invoke make, followed by ./run

cd /opt/tinyos-2.x-contrib/intelmote2/apps/cameraTestJpegSerial/java
make
./run

If you again see error like the last one informing that toscomm JNI library was not found, than replace the ./run file last line with java -Djava.library.path=/usr/lib/jvm/java-6-sun/jre/lib/i386 CameraGUI

Make sure you see the dialog, having the path, change this path where you want to place the captured images. Or you can modify theCameraGUI.java file and replace the path there i.e. at line 126 you will see something like fieldInterval.setText("/tmp/imote2/"); 
Just change this path, to your desired location, ending with '/', invoke make and ./run than.
Only VGA is working as an image capturing. 

Currently the saved images are cut, it seems like a jigsaw puzzle sometimes, and sometimes repeatition of the same image. That's still unfixed as per http://tech.groups.yahoo.com/group/intel-mote2-community

The application for Multihop is broken so far. The working application is just the single hop located at http://tech.groups.yahoo.com/group/intel-mote2-community/files/CameraSingleHopTest/, you will be required to sign in to access it. Place the folder in the same apps directory as of cameraTestJpegSerial and camerMultiHop. Burn one mote with baseNode and one mote with cameraNode. Than browse to the java folder and invoke make followed by java CameraGUI, again if you see error like the last one informing that toscomm JNI library was not found, than replace the run file last line with java -Djava.library.path=/usr/lib/jvm/java-6-sun/jre/lib/i386 CameraGUI

This time it relies on MOTECOM variable
This MOTECOM variable is also used internally by applications, you can see it by printenv MOTECOM, you can set it by export MOTECOM=serial@/dev/ttyUSB1:115200

That's all for now. If you face any issue during this, please comment on this post with your finding. After all its a hard earned debugging evolution up there :).

Thanks.

Comments

Ivan said…
For an updated version of XScale compiling tools and instructions on the compiling options you may check

http://www.gaps.ssr.upm.es/en/research/wsn/138-compiling-for-an-arm-architecture-imote2-tinyos
encima said…
This may not be the right place to post but do you know where I could buy an Imote2 and its cost please?
Thomas said…
Hello

I cannot do the commend

make intelmote2 install openocd

It gives out an error of

make: *** No rule to make target 'intelmote2'. Stop

May I know how to deal with it?
Talha Obaid said…
Its because of missing environment variables. Make sure you set TINYOS paths.

Popular posts from this blog

Branch and bound algorithm in C#- Article by AsiF Munir

Baseline: Data, ML, AI https://www.qwiklabs.com/quests/34 - Tips