TinyOS 系列文章【一】:TinyOS 配置教程
TinyOS 系列文章【二】:Tossim 教程
本文主要用于记录在 WSN 课程中,配置大作业所需使用的 TinyOS
仿真环境
本实验以如下版本为例,其他系统版本可能会出现未知的问题
有关虚拟机的安装,可以参考我的另一篇 blog:Blitz 配置教程
sudo gedit /etc/apt/sources.list
这个命令使用的是 gedit
编辑器,当然你也可以使用 vim 等
需要注意的是,你需要先使用 su root
进入 root 后, 再使用 sudo
以运行如上指令,否则会报如下错误:
(gedit:2640): dconf-WARNING **: failed to commit changes to dconf: 连接已关闭
** (gedit:2640): CRITICAL **: log.vala:104: Unable to connect to Zeitgeist: 连接已关闭
(gedit:2640): dconf-WARNING **: failed to commit changes to dconf: 连接已关闭
(gedit:2640): dconf-WARNING **: failed to commit changes to dconf: 连接已关闭
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
(gedit:2640): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
(gedit:2640): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
(gedit:2640): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
(gedit:2640): dconf-WARNING **: failed to commit changes to dconf: 连接已关闭
(gedit:2640): dconf-WARNING **: failed to commit changes to dconf: 连接已关闭
(gedit:2640): dconf-WARNING **: failed to commit changes to dconf: 连接已关闭
** (gedit:2640): CRITICAL **: Unable to connect to Zeitgeist's DataSourceRegistry: 连接已关闭
# TinyOS Repository
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main
在添加如上代码的时候,终端会有如下错误提示(但是似乎不影响后续下载,暂时跳过):
(gedit:3437): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
sudo apt-get update
终端部分输出如下所示:
命中 http://security.ubuntu.com trusty-security/main Translation-en
命中 http://security.ubuntu.com trusty-security/multiverse Translation-en
获取:3 http://tinyos.stanford.edu lucid/main i386 Packages [5,310 B]
命中 http://security.ubuntu.com trusty-security/restricted Translation-en
命中 http://security.ubuntu.com trusty-security/universe Translation-en
忽略 http://tinyos.stanford.edu lucid/main Translation-zh_CN
忽略 http://tinyos.stanford.edu lucid/main Translation-zh
忽略 http://tinyos.stanford.edu lucid/main Translation-en
忽略 http://extras.ubuntu.com trusty/main Translation-zh_CN
忽略 http://extras.ubuntu.com trusty/main Translation-zh
忽略 http://extras.ubuntu.com trusty/main Translation-en
下载 12.3 kB,耗时 11秒 (1,034 B/s)
正在读取软件包列表... 完成
update
成功后,执行安装 TinyOS
命令:sudo apt-get install tinyos-2.1.2
可能下载过程会有些缓慢,请耐心等待。安装成功后,终端部分输出如下所示:
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/bin/schemagen to provide /usr/bin/schemagen (schemagen) in 自动模式
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/bin/serialver to provide /usr/bin/serialver (serialver) in 自动模式
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/bin/wsgen to provide /usr/bin/wsgen (wsgen) in 自动模式
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/bin/wsimport to provide /usr/bin/wsimport (wsimport) in 自动模式
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/bin/xjc to provide /usr/bin/xjc (xjc) in 自动模式
正在设置 openjdk-6-jre-lib (6b41-1.13.13-0ubuntu0.14.04.1) ...
正在设置 libatk-wrapper-java-jni:amd64 (0.30.4-4) ...
正在处理用于 libc-bin (2.19-0ubuntu6.14) 的触发器 ...
正在处理用于 ca-certificates (20170717~14.04.2) 的触发器 ...
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....
done.
done.
安装成功后,现在 TinyOS
的基础工作已经做好,接下来就是完成配置以及安装相应的编译器即可。
sudo chown your_user_name:your_user_name -R /opt/tinyos-2.1.2/
sudo chown your_user_name -R /opt/tinyos-2.1.2
tinyos-2.1.2
目录下检查是否有 tinyos.sh
文件,如果没有该文件,使用指令 vim tinyos.sh
新建这个文件并添加以下代码:#! /usr/bin/env bash
# www.ElectronicsPub.com
# TinyOS 2.1.2 Configuration Guide
# Here we setup the environment
# variables needed by the tinyos
# make system
echo "Setting up for TinyOS 2.1.2"
export TOSROOT=
export TOSDIR=
export MAKERULES=
TOSROOT="/opt/tinyos-2.1.2"
TOSDIR="$TOSROOT/tos"
CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java
MAKERULES="$TOSROOT/support/make/Makerules"
export TOSROOT
export TOSDIR
export CLASSPATH
export MAKERULES
sudo gedit ~/.bashrc
在最下面添加以下代码:
# Start TinyOS environment pathing
export TOSROOT=/opt/tinyos-2.1.2
export TOSDIR=$TOSROOT/tos
export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.$CLASSPATH
export MAKERULES=$TOSROOT/support/make/Makerules
export PATH=/opt/msp430/bin:$PATH
source /opt/tinyos-2.1.2/tinyos.sh
# End TinyOS pathing
source ~/.bashrc
终端出现如下提示,说明成功:
Setting up for TinyOS 2.1.2
cd $TOSROOT/support/sdk/java
sudo tos-install-jni
make
make install
msp430-gcc --version
终端出现如下提示说明安装成功:
msp430-gcc (GCC) 4.5.3
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
需要注意的是:
command not found or msp430 compiler is not installed
,请参考步骤 1.5依次输入以下命令:
sudo apt-get install gcc g++
sudo apt-get install python2.7 python2.7-dev
现在环境就搭建好了,可以进行仿真程序的测试了
进入程序所在的目录:
cd /opt/tinyos-2.1.2/apps/Blink
执行如下指令编译:
make micaz sim
终端出现如下输出时,说明配置成功:
一份简单的配置指南