没有合适的资源?快使用搜索试试~ 我知道了~
首页contiki学习资料
contiki学习资料
需积分: 10 81 浏览量
更新于2023-05-30
评论
收藏 171KB PDF 举报
详细的contiki学习笔记,包括:环境设置,微处理器,系统架构,线程,时钟,硬件I/O,网络,无线电,其它。
资源详情
资源评论
资源推荐

Contiki Study Notes
Zengxu Yang

Contents
1 Environment setup 4
1.1 Access 6LoWPAN motes on the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.1 Configure your virtual machine network . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.2 Setting up virtual machine guest OS . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.3 Setting up remote computer OS . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.4 Two virtual machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1.5 Analyze packets using Wireshark . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 MSP430 ABIs 8
3 Contiki system architecture 9
3.1 Compiling a Contiki program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.1 Contiki version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.2 GCC compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.3 GNU linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.4 Check object files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.5 GNU make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.6 Makefile example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Z1 motes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2.1 Hardware features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2.2 LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2.3 USB to serial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1

3.2.4 ADXL345 accelerometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2.5 Z1 websense . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4 Contiki processes 30
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2 Process list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 Process initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4 Process body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5 Scheduler loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.6 Autostart processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.7 Process declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.8 Protothreads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.8.1 Protothreads states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.9 Process control block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.9.1 Process states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.10 Start a process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.11 Running processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.12 Process events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.13 Post events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.14 Process polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.15 Event waiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.16 End a process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5 Clocks and timers 44
5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.2 Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3 Timer interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4 Real-time timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5 Event timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6 Callback timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2

6 Hardware I/O operations 48
6.1 Interrupt operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.2 GPIOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.3 SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.4 UART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.4.1 UART receive interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7 Networking 52
7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.2 TCP/IP events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.3 Web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
8 Radio 53
8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
8.2 IEEE802.15.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
9 Incoming 55
9.1 Memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
9.2 Compile examples for Z1 motes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
9.3 Virtual machine settings for USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
9.4 Flash the Z1 mote through USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10 Misc 57
10.1 CoAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.2 REST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.3 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3

Chapter 1
Environment setup
1.1 Access 6LoWPAN motes on the Internet
Accessing 6LoWPAN motes on the Internet can be challenging. Below is my notes of setting up it
successfully.
1.1.1 Configure your virtual machine network
The best way to access your virtual machine remotely is configuring your virtual machine network
to bridged mode. I’ll use VirtualBox as an example. VMWare is similar. The default network
configuration is NAT mode. Go to Devices-Network-Network Settings...-Adapter 1, beside “Attached
to:”, choose “Bridged Adapter”. Beside “Name”, choose the interface that you use to get online for
your computer. Normally it is “wlan0” for wireless and “eth0” for wired. Also check the “Cable
Connected”. You should do this before running your guest OS.
1.1.2 Setting up virtual machine guest OS
6LoWPAN motes are accessed through the border router. In Cooja we use the SLIP protocol to
establish a point-to-point connection to the Internet by executing:
cd /home/user/contiki/examples/ipv6/rpl-border-router
make connect-router-cooja TARGET=sky
It adds a virtual network interface called tun0. At the end of this command we are providing a
prefix of aaaa::1/64, which enables the device to pick its own IPv6 address using Stateless Address
Auto-configuration (SLAAC). It is important to note that this means the prefix needs to use a /64
mask.
When first connected to a network, a host sends a link-local router solicitation multicast request for its
configuration parameters; routers respond to such a request with a router advertisement packet that
contains Internet Layer configuration parameters.
4
剩余59页未读,继续阅读













安全验证
文档复制为VIP权益,开通VIP直接复制

评论0