基本平台
1. 操作系統:Ubuntu 12.04
2. 硬件節點:Micaz節點
XJTU Ubuntu 源:http://ubuntu.xjtuns.cn/
Ubuntu 12.04 Precise Pangolin
deb http://ubuntu.xjtuns.cn/ubuntu/ precise main restricted universe multiverse
deb http://ubuntu.xjtuns.cn/ubuntu/ precise-backports main restricted universe multiverse
deb http://ubuntu.xjtuns.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb http://ubuntu.xjtuns.cn/ubuntu/ precise-security main restricted universe multiverse
deb http://ubuntu.xjtuns.cn/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://ubuntu.xjtuns.cn/ubuntu/ precise main restricted universe multiverse
deb-src http://ubuntu.xjtuns.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://ubuntu.xjtuns.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://ubuntu.xjtuns.cn/ubuntu/ precise-security main restricted universe multiverse
deb-src http://ubuntu.xjtuns.cn/ubuntu/ precise-updates main restricted universe multiverse
基本步驟
1. 安裝准備:
如果系統沒有python開發環境支持和g++編譯工具:
$sudo apt-get install python-dev
$sudo apt-get install g++
2. 按照官方步驟進行操作,注意修改~/.bashrc文件中對應的tinyos版本 號:http://docs.tinyos.net/tinywiki/index.php/Installing_TinyOS_2.1.1#Two-step_install_on_your_host_OS_with_Debian_packages
3. 在目前最新的2.1.2版本中,在/opt/tinyos-2.1.2/下缺少tinyos.sh文件,則需要編輯添加如下:
#installation by substituting /opt for the actual tinyos tree
#installation point
TOSROOT="/opt/tinyos-2.1.2"
TOSDIR="$TOSROOT/tos"
CLASSPATH="$TOSROOT/support/sdk/java/tinyos.jar:."
MAKERULES="$TOSROOT/support/make/Makerules"
export TOSROOT
export TOSDIR
export CLASSPATH
export MAKERULES
關閉並重啟終端或者$source ~/.bashrc,使配置生效。
4. 修改/opt/tinyos-2.1.2/ 文件夾權限,$chown -R username /opt/tinyos-2.1.2/
5. 安裝tos-install-jni,$sudo tos-install-jni
6. 檢查是否安裝正確:$sudo tos-check-env ,一般會出現兩個Warning,一個是你的Java版本不對,不是1.4或者1.5的;另一個是graphviz版本有問題,都可以忽略。
7. 檢查tinyos編譯系統是否可用:$ printenv MAKERULES
出現“/opt/tinyos-2.1.2/support/make/Makerules”信息則可用正常使用。
8. 最後進入/opt/tinyos-2.1.2/apps/Blink目錄,編譯Blink應用程序,輸入如下命令進行仿真編譯:$make micaz sim
得到“Successfully built micaz TOSSIM library”信息,則編譯順利,環境安裝成功。
在micaz節點上進行下載測試
1. 確定serial port device name:$ ls /dev/ttyU*
顯示:
則我的USB端號為0。
2. 將端口屬性設置為可寫:$ sudo chmod 666 /dev/ttyUSB0 (usb-device-name)
3. 將將程序下載到節點:$ make micaz reinstall mib510,/dev/ttyUSB0顯示結果為:
如果為每個節點進行標記則:$ make micaz reinstall.ID mib510,serialport
4. make tinynode reinstall device-type,serialport 與 make tinynode install device-type,serialport的區別:reinstall直接將編譯好的代碼寫入到串口中,而install先編譯源文件為可執行代碼,然後再寫入串口。
5. 程序下載好之後,節點的LED燈按照每2秒0-7的二進制數不斷閃爍。
使nesC在vim中高亮顯示
參考文檔:http://www.vim.org/scripts/script.php?script_id=1847
1. 下載Version 2.0的壓縮包:vim.tar.gz;如果沒有安裝Vim,則$sudo apt-get install vim進行安裝。
2. 按照步驟進行操作:
untar the the files to ~/.vim/
tar zxvf vim.tar.gz
add the following into the end of ~/.vimrc
augroup filetypedetect
au! BufRead,BufNewFile *nc setfiletype nc
augroup END
如果沒有~/.vim/文件夾則新建,$mkdir ~/.vim/,如果沒有~/.vimrc文件則同樣新建文件。
更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2