TinyOS On Debian

Source: Internet
Author: User
Debian is installed with TinyOS-Debian, which is the Linux release technology. The following is a detailed description. Filed under: Work

Install TinyOS 1.x. Just a few important points

1. First install and compile the tool chain required by AVR

Aptitude install gcc-avr binutils-avr-libc may also come with graphviz, which is used for drawing.

2. From the nesc under sf

Wget http://kent.dl.sourceforge.net/s .. c/nesc-1.2.7.tar.gz

./Configure -- prefix =/opt/tos; make install

3. Of course there is sun-java5-jdk

Aptitude install sun-java5-jdk plus SUN Java Communication API version 3.0

Unzip comm3.0_uw.linux.zip

Cp commapi/lib/*. so $ JAVA_HOME/jre/lib/i386/

Cp commapi/jar/comm. jar $ JAVA_HOME/jre/lib/ext/

Cp commapi/docs/javax. comm. properties $ JAVA_HOME/jre/lib/

4. Finally, capture TinyOS from CVS

Cvs-d: pserver: anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login

Cvs-z9-d: pserver: anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co tinyos-1.x

. After confirming the installation directory of the TOS, you can add a function in. bashrc. If you want to work in the future, you just need to knock the tos:

Tos ()

{

Export TOSROOT =/home/save/dev/tinyos/tinyos-1.x

Export TOSDIR = \ "$ TOSROOT/tos \"

Export PATH = $ PATH:/opt/tos/bin

Export CLASSPATH = '$ TOSROOT/tools/java/javapath'

Cd $ TOSROOT

}

. Now ncc is moved from nesc to TinyOS, And now ncc Compilation:

Cd $ TOSROOT/tools/src/ncc

./Bootstrap;./configure -- prefix =/opt/tos; make install

Let's see if everything is different:

./Tools/scripts/toscheck may think that some versions are incorrect, which may cause some problems. In the Assembly program generated by nesc, there will be a lot of variable names with the $ symbol in the middle, gcc-avr will see this will be uncomfortable. When you make mica2, errors will be reported frantically, similar to the following:

/Tmp/c137uzvj. s: 1743: Error: unknown opcode 'timertask'

/Tmp/c137uzvj. s: 1743: Error: unknown opcode 'timertask'

/Tmp/c137uzvj. s: 1744: Error: unrecognized symbol type

/Tmp/c137uzvj. s: 1744: Error: unknown opcode 'packetsent'

/Tmp/c137uzvj. s: 1745: Error: unknown opcode 'cc1000radi'

/Tmp/c137uzvj. s: 1753: Error: unknown opcode 'txbufptr'

This friend regards this as the consequence of disobedience. In fact, he can change it in $ TOSROOT/apps/Makeruls:

-OPTFLAGS: =-OS

+ OPTFLAGS: =-OS-Wa, -- allow-dollars let gcc-avr see the knife.

4. 3. Compile uisp

When you use Debian's uisp to write a program, an error is reported, saying:

/Usr/bin/uisp-dprog = mib510-dserial =/dev/ttyUSB0-dpart = ATmega128 -- wr_fuse_e = ff -- erase -- upload if = build/mica2/main. srec

Direct Parallel Access not defined.

Make TinyOS your own.

Cd $ TOSROOT/tools/src/uisp

./Set-dates

./Configure -- prefix =/opt/tos & make install

4. Compile libgetenv

Some TinyOS Java programs use JNI libgetenv. So we need ...... Compile:

Cd $ TOSROOT/tools/java/jni make

Before making, you also need to modify a script $ TOSROOT/tools/scripts/locate-jre. Comment out all programs from lines 37 to 47, and then add:

J = \ "$ JAVA_HOME \"/bin/javac

Of course, the premise is that you have set the $ JAVA_HOME environment variable. In the modified row 70th, modify it:

-Dir = \ "$ jhome/jre/bin

+ Dir = \ "$ jhome/jre/lib/i386

These problems are caused by the absence of ibm jdk and the absence of rpm db installed in Debian.

5. Now set the ports used by the Programming Board, as well as the frequency band and power used by mica2.

Write a file $ TOSROOT/apps/Makelocal,

DEFAULT_PROGRAM = mib510 # Programming Board Model

MIB510 =/dev/ttyUSB0 # USB to serial is like this in GNU/Linux

DEFAULT_LOCAL_GROUP = 0x88 # group id

FLAGS =-DCC1K_DEFAULT_FREQ = CC1K_433_002_MHZ # frequency band used for wireless communication

CFLAGS + =-DRADIO_XMIT_POWER = 0xFF # use the maximum power

6. Check whether the hardware is normal.

Cd $ TOSROOT/apps/MicaHWVerify make mica2 if everything is normal, it means TinyOS is almost ready. The reason we say "almost" is that TinyOS also comes with a lot of tools, and we haven't compiled these tools yet. Next, burn the compiled program to the Board:

Make reinstall mica2 next, follow Tutorial to check communication and other functions. Now TinyOS has been installed on the Debian GNU/Linux platform. In addition, if you want to use deluge, you need to change the Makefile of deluge:

Sed-I-e \ "s/DELUGE_PLATFORM = telosb/DELUGE_PLATFORM = mica2 /\"\

-E \ "s/CC2420Radio/CC1000Radio/\" $ TOSROOT/tools/java/net/tinyos/deluge/Makefile

6. The last point is caused by the USB to serial adapter.

. Let Java programs know/dev/ttyUSB0

To modify the $ JAVA_HOME/jre/lib/javax. comm. properties file, add a line:

Serpath2 =/dev/ttyUSB06.2. do not exit when Java programs set the baud rate

This is just a workaround, that is, all the grep java files under the $ TOSROOT/tools/java directory, find the place of setSerialPortParams, and change it to this:

Try {

SerialPort. setSerialPortParams (sf. BAUD_RATE, SerialPort. DATABITS_8,

SerialPort. STOPBITS_1,

SerialPort. PARITY_NONE );

} Catch (Exception e ){}

SerialPort. setSerialPortParams (sf. BAUD_RATE,

SerialPort. DATABITS_8,

SerialPort. STOPBITS_1,

SerialPort. PARITY_NONE );

This is to make it run twice. The first time there will be an error:

Exception in thread \ "AWT-EventQueue-0 \" java. io. IOException: Not all params are supported by kernel

At com. sun. comm. LinuxSerial. nativeSetSerialPortParams (Native Method)

At com. sun. comm. LinuxSerial. setSerialPortParams (LinuxSerial. java: 346)

At SerialConnection. setConnectionParameters (Unknown Source)

At SerialConnection. openConnection (Unknown Source)

At SerialDemo. actionreceivmed (Unknown Source)

At java. awt. Button. processActionEvent (Button. java: 388)

At java. awt. Button. processEvent (Button. java: 356)

At java. awt. Component. dispatchEventImpl (Component. java: 3955)

At java. awt. Component. dispatchEvent (Component. java: 3803)

At java. awt. EventQueue. dispatchEvent (EventQueue. java: 463)

At java. awt. EventDispatchThread. pumpOneEventForHierarchy (EventDispatchThread. java: 242)

At java. awt. EventDispatchThread. pumpEventsForHierarchy (EventDispatchThread. java: 163)

At java. awt. EventDispatchThread. pumpEvents (EventDispatchThread. java: 157)

At java. awt. EventDispatchThread. pumpEvents (EventDispatchThread. java: 149)

At java. awt. EventDispatchThread. run (EventDispatchThread. java: 110)

But this must not be a kernel issue, because C Programs can set the baud rate for the serial port. Some people have encountered the same problem here. Here I use the second method.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.