搞zigbee算是国内第一批了,很早就知道6lowpan。用cc2430时,从研究http://www.tinyos8051wg.net,找寻资料了解到 Nanostack1.0.0,直到Nanostack1.1.0 之后就转为contiki了。好久没发帖了,发个帖Mark一下,先!
1.Download Instant Contiki
http://sourceforge.net/projects/contiki/files/Instant%20Contiki/
2.Install VMWare Player
https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0
3.Log into Instant Contiki.
password is: user
4.编译~/contiki/examples/cc2530dk下例子,需要先安装SDCC.
参考文档
https://github.com/contiki-os/contiki/wiki/8051-Requirements
4.1)下载SDCC
cd /opt
sudo svn co -r 7100 https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc/
4.2) 更改配置
sudo vi /opt/sdcc/device/libs/incl.mk
将最后一行
MODELS = small medium large
替换为
MODELS = small large huge
sudo vi /opt/sdcc/device/libs/Makefile.in
将最后一行
TARGETS += models small-mcs51-stack-auto
替换为
TARGETS += models model-mcs51-stack-auto
cd /opt/sdcc
•Run this:
sudo ./configure –disable-gbz80-port –disable-z80-port –disable-ds390-port </font>
–disable-ds400-port –disable-pic14-port –disable-pic16-port </font>
–disable-hc08-port –disable-r2k-port –disable-z180-port </font>
–disable-sdcdb –disable-ucsim
此过程若出现
configure: error: boost library not found (boost/graph/adjacency_list.hpp)
执行
sudo apt-get install libboost-graph-dev
完成后,重新执行
sudo ./configure –disable-gbz80-port –disable-z80-port –disable-ds390-port </font>
–disable-ds400-port –disable-pic14-port –disable-pic16-port </font>
–disable-hc08-port –disable-r2k-port –disable-z180-port </font>
–disable-sdcdb –disable-ucsim_
4.3)编译,安装
sudo make
sudo make install
4.4)完成
sdcc -v
显示
SDCC : mcs51 3.1.1 #7100 (Jan 10 2013) (Linux)
5.编译cc2530dk
5.1) hello world
cd ~/contiki/examples/cc2530dk
make hello-world
编译完成
user@instant-contiki:~/contiki/examples/cc2530dk$ ls
blink-hello.c hello-world.c obj_cc2530dk timer-test.c
blink-hello.cc2530dk hello-world.cc2530dk sensors-demo.c timer-test.cc2530dk
blink-hello.cdb hello-world.cdb sensors-demo.cc2530dk timer-test.cdb
blink-hello.hex hello-world.hex sensors-demo.cdb timer-test.hex
blink-hello.lk hello-world.lk sensors-demo.hex timer-test.lk
blink-hello.map hello-world.map sensors-demo.lk timer-test.map
blink-hello.mem hello-world.mem sensors-demo.map timer-test.mem
blink-hello.omf hello-world.omf sensors-demo.mem timer-test.omf
border-router Makefile sensors-demo.omf udp-ipv6
contiki-cc2530dk.lib Makefile.target sniffer
5.2) udp-ipv6
cd ~/contiki/examples/cc2530dk/udp-ipv6
make
报错,缺少srecord
Pack hex file
===============
srec_cat -disable_sequence_warnings client.banked-hex -intel -crop 0x18000 0x1FFFF -offset -65536 -o bank1.hex -intel
/bin/sh: 5: srec_cat: not found
srec_cat -disable_sequence_warnings client.banked-hex -intel -crop 0x28000 0x2FFFF -offset -98304 -o bank2.hex -intel
/bin/sh: 5: srec_cat: not found
srec_cat -disable_sequence_warnings client.banked-hex -intel -crop 0x38000 0x3FFFF -offset -131072 -o bank3.hex -intel
/bin/sh: 5: srec_cat: not found
srec_cat -disable_sequence_warnings client.banked-hex -intel -crop 0x48000 0x4FFFF -offset -163840 -o bank4.hex -intel
/bin/sh: 5: srec_cat: not found
make: *** [client.hex] Error 127
执行
sudo apt-get install srecord
6.TI SmartRF Flash Programmer 烧录 *.hex
已烧录hello-world.hex为例,CC2530 UART0 会打印输出如下信息:
##########################################
Contiki-2.6
TI SmartRF05 EB
cc2530-F256, 08KB SRAM
SDCC Build:
–model-large
–stack-auto
Net: Rime
MAC: CSMA
RDC: nullrdc
##########################################
Rime is 0x02 bytes long
Reading MAC from Info Page
Rime configured with address c6:1c
Rime is 0x02 bytes long
Reading MAC from Info Page
Rime configured with address 67:af
Hello World!
7.建立自己的硬件平台[我的是:edutech]和工程[我的是:edutech]
7.1) cpu
cd ~/contiki/cpu/cc253x
cp Makefile.cc253x Makefile.cc253x-edutech
cp bank-alloc.py bank-alloc-edutech.py
vi Makefile.cc253x-edutech
编辑第14行
BANK_ALLOC = $(CONTIKI_CPU)/bank-alloc.py
为
BANK_ALLOC = $(CONTIKI_CPU)/bank-alloc-edutech.py
保存
:wq
vi bank-alloc-edutech.py
编辑第101行
file_pat = re.compile(‘obj_cc2530dk[^ ]+.‘)
为
** file_pat = re.compile(‘obj_edutech[^ ]+.‘)**
将文中4处,157、158、172、173行中
bank-alloc.py 替换为 **bank-alloc-edutech.py **
保存
:wq
7.2) platform
cd ~/contiki/platform
cp cc2530dk edutech -R
cd edutech
mv Makefile.cc2530dk Makefile.edutech
vi Makefile.edutech
编辑第1行[非必须]
# cc2530dk platform makefile
为
# edutech platform makefile
编辑第19行
CLEAN += *.cc2530dk
为
CLEAN += *.edutech *.native
编辑第52行,最后一行
include $(CONTIKI_CPU)/Makefile.cc253x
为
include $(CONTIKI_CPU)/Makefile.cc253x-edutech
保存
:wq
接下来根据实际硬件情况,编辑或创建驱动文件
7.3) project
cd ~/contiki/examples
cp cc2530dk/ edutech -R
cd edutech
vi Makefile.target
编辑第1行
TARGET = cc2530dk
为
TARGET = edutech
保存
:wq
make
烧录
using TI CC Debugger (based on Ubuntu)
install Package libboost-all-dev and libusb-1.0-0-dev by using command
sudo apt-get install libboost-all-dev
sudo apt-get install libusb-1.0-0-dev
- download cc-tool source code from https://github.com/misham/cc-tool
- extract cc-tool source code and install by using command
sudo wget https://github.com/misham/cc-tool/archive/master.zip
sudo unzip master.zip
cd cc-tool- master
sudo ./configure
make
make install
- use lsusb command for list your Board
lsusb
- the output should be
..Bus 006 Device 015: ID 0451:16a0 Texas Instruments, Inc. Bus 006 Device 013: ID 0451:16a0 Texas Instruments, Inc. ..
- change directory to your .hex file
(example /home/user/contiki-sensinode/examples/cc2530dk)
cd /home/user/contiki-sensinode/examples/cc2530dk
- start program board (cc-tool -ew FILE_NAME.hex -d’Bus:Device’ -v)
cc-tool -ew blink-hello.hex -d'006:015' -v
- the result should be
Programmer: SmartRF05EB Target: CC2530 Erasing flash… Erasing completed Writing flash… (42 KB)… Writing completed (3.13 s.) Verifying flash… Verification completed (3.33 s.)
- for more cc-tool command option you can use –help
cc-tool –help
可使用 sudo cc-tool –n cc2530 –w blink-hello.hex –v 烧录
#sensniff
https://github.com/g-oikonomou/sensniff
https://github.com/jerusalemdax/contiki-cc2530eb
下载
[git clone git://github.com/jerusalemdax/contiki-cc2530eb.git](git clone git://github.com/jerusalemdax/contiki-cc2530eb.git)
发表链接
amoBBS 阿莫电子论坛 http://www.amobbs.com/thread-5515866-1-1.html