Contiki OS Sharvil Patel, Michael Ray, Emily Rowland 1
Agenda ●Introduction to Contiki with History ●Components ●Applications ●Conclusion 2
Introduction ●Real-time operating system ●Specializes in Internet of Things (IoT) ●Low power oriented ●Open-source (github.com/contiki-os) ○Free in commercial and noncommercial applications ●Easy/Fast rapid development ○Developed in C ●16 supported hardware platforms 3
Specifications ●Extremely lightweight ○10 kB of RAM ○30 kB of ROM ○Fully functional system including GUI requires 30 kB of RAM ■Linux uses 1 MB! 4
History ●Created in 2002 by Adam Dunkels Ph.D. ○Author of the uIP stack, Rime, protothreads ○Founder of Thingsquare ●Now developed by a worldwide team ○TI, Atmel, Cisco, Oxford University, SAP, etc, & you! 5
Applications ●City sound monitoring ●Street lights ●Networked electrical power meters ●Industrial monitoring ●Remote house monitoring ●Radiation monitoring ●ATUM 6
OS components ●Processes ●Protothreads ●Communication stacks ●Full IP networking ●Memory allocation ●Timers ●Power awareness ●Sleepy routers ●Cooja networking simulator ●Coffee - flash file system ●Rime stack ●Watchdog 7
Processes All programs in Contiki are processes There are cooperative and preemptive contexts 8
Protothreads ●Mix of event-driven and multithreaded programming mechanisms ○Kernel invokes a process’ protothread in response to an event ●Non-preemptive ○Blocking event-handlers ○Context switches only available on blocking operations ●Stackless ○Global variables are required for preserving variables across context switches ● 9
Protothreads (continued) ●Extremely lightweight ○Overhead: 2 bytes (plus no stack) ●Portable ○Can be used with/without an OS ○Pure C code (macros) 10
Communication Stacks ●4 types ●Rime ○Lightweight communication stack ○When full IPv6 networking is overkill ○Simple operations (single message sending) ○Layered stack ●uIP ○TCP/IP stack ○Meant for 8 bit and 16 bit devices ○Very low RAM and overhead code 11 Rime uIP 6LoWPAN IPv4 Lightest Heaviest pdfhttps://github.com/adamdunkels/uip
Communication Stacks (continued) ●IPv6 Ready certification ○Developed by Cisco ○Smallest IPv6 stack when it was created ●6LoWPAN ○IPv6 over Low power Wireless Personal Area Networks ○Specializes in low power IPv6 communication ○Allows send/receive over IEEE ■Same network as Zigbee ●Capabilities: UDP, TCP, HTTP Rime uIP 6LoWPAN IPv4 Lightest Heaviest
Memory Allocation ●3 types ○memb memory block ■Static memory struct ■Most common ■Lightweight ○mmem managed memory, ○malloc - standard C library 13
Timers ●Uses: time elapsed, low power wake up, real time scheduling ○Timer & STimer ■Set, reset, check expiration manually, time remaining ○Etimer ■ Timed events, repeated ○Ctimer ■Call a function when expired ○Rtimer ■For real-time tasks, preemptive 14
Power awareness ●Designed for small systems and to last on a pair of AA for years ○Dr. Kevin Fu ●Provides mechanisms for energy management and system power consumption ●Uses timers to figure out where more energy was spent 15
Sleepy routers ●Power saving feature ●When devices are used as relay-nodes, or routers, in wireless networks, Contiki allows these nodes to sleep between packets 16
Cooja networking simulator ●Simulates Contiki nodes ●Emulated node ○Complete hardware emulation ●Cooja node ○Contiki code executed in the simulator ●Java node ●Uses: ○Swarm intelligence ○Indoor localization
Applications 18
Applications -- Koubachi Garden Sensor Wireless, connected garden sensor Data on water, temperature, and light WiFi Connected 2 AA Batteries Push notifications and lookup database 19
Applications -- LIFX Color Changing Lights Adjusts color, warmth, brightness and intensity Can be set to adjust via schedule Connects with: Apps, IFTTT, Nest Products, Samsung SmartThings, Amazon Echo, and others Contiki: Wireless connectivity 20
Applications -- Life of a Badger Sensor Collars with Microcontrollers running Contiki “Detailing badger behavior and locations underground was impossible” - Dr. Andrew Markham Data sent wirelessly Researchers using network maps of collar nodes echnology
ATUM ●Created here at U of M ○Available in lab for our final projects ●Project requirements: ○“Connected” - network enabled ○Low power ○Responsive ○Small ●Uses: ○Timer (for PWM) ○Protothreads ○Interrupts 22
Questions? 23
Resources Getting Started Protothreads Networking
Bibliography
mmem and malloc heap memory allocators mmem is byte aligned, memcpy() or packed must be used malloc is the same as defined in stdlib.h 26