TinyOS. Software Challenges - TinyOS Power efficient –Put microcontroller and radio to sleep Small memory footprint –Non-preemptable.

Slides:



Advertisements
Similar presentations
How to use TinyOS Jason Hill Rob Szewczyk Alec Woo David Culler An event based execution environment for Networked Sensors.
Advertisements

A System Architecture for Tiny Networked Devices
Sensor Network Platforms and Tools
Overview: Chapter 7  Sensor node platforms must contend with many issues  Energy consumption  Sensing environment  Networking  Real-time constraints.
Chapter 13 Embedded Systems
The Mote Revolution: Low Power Wireless Sensor Network Devices
Chapter 13 Embedded Systems Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
1 Introduction to Wireless Sensor Networks. 2 Learning Objectives Understand the basics of Wireless Sensor Networks (WSNs) –Applications –Constraints.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
How to Code on TinyOS Xufei Mao Advisor: Dr. Xiang-yang Li CS Dept. IIT.
Jason Hill, Robert Szewczyk, Alec Woo Spring 2000 TinyOS Operating System for Networked Sensors Networked SensorsSystem Structure Composing Components.
Sample Project Ideas KD Kang. Project Idea 1: Real-time task scheduling in TinyOS EDF in TinyOS 2.x –Description is available at
Integrated  -Wireless Communication Platform Jason Hill.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
IEEE Standardized radio technology for low power personal area networks Joe Polastre January 14, 2004.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
A System Architecture for Tiny Networked Devices Jason Hill U.C. Berkeley 9/22/2000.
Radio Stack Iteration How to improve the CC1000 Joe Polastre January 15, 2004 NEST Retreat.
Chapter 13 Embedded Systems
OS Spring’03 Introduction Operating Systems Spring 2003.
1 TinyOS Mohammad Rahimi CSCI599-Spring Motivation  The new class of distributed tiny devices  The new generation of software.
TinyOS Software Engineering Sensor Networks for the Masses.
Introduction to TinyOS. Faster, Smaller, Numerous Moore’s Law –“Stuff” (transistors, etc) doubling every 1-2 years Bell’s Law –New computing class every.
2008EECS Embedded Network Programming nesC, TinyOS, Networking, Microcontrollers Jonathan Hui University of California, Berkeley.
A Framework for Patient Monitoring A. L. Praveen Aroul, William Walker, Dinesh Bhatia Department of Electrical Engineering University of Texas at Dallas.
Introduction to TinyOS. Networking Open Experimental Platform Small microcontroller 8 kB code 512 B data Simple, low-power radio 10 kbps ASK EEPROM (32.
1 EE249 Discussion System Architecture Directions for Networked Sensors (J. Hill, et al) Presented By: Sarah Bergbreiter EE249 Discussion Section October.
Chapter 13 Embedded Operating Systems Eighth Edition By William Stallings Operating Systems: Internals and Design Principles.
Chapter 2 Operating System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
1 Software Development Infrastructure for Sensor Networks  Operating systems ( TinyOS )  Resource (device) management  Basic primitives  Protocols.
TinyOS Tutorial Jianping Wang (merge several tutorials found online)
A System Architecture for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister
Shahin Farshchi, Member, IEEE, Aleksey Pesterev, Paul Nuyujukian, Eric Guenterberg, Istvan Mody, and Jack W. Judy, Senior Member, IEEE, ” Structure of.
By: R Jayampathi Sampath
April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College.
TinyOS. Learning Objectives Understand TinyOS – the dominant open source operating systems for WSN –Hardware abstraction architecture (HAA) –TinyOS architecture.
TinyOS By Morgan Leider CS 411 with Mike Rowe with Mike Rowe.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Introduction to Wireless Sensor Networks
Vishal Jain, TinyOS Design Viewpoint “TinyOS” Design Viewpoint.
Dhanshree Nimje Smita Khartad
System Architecture Directions for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister Presented by Yang Zhao.
Simulation of Distributed Application and Protocols using TOSSIM Valliappan Annamalai.
Part 2 TinyOS and nesC Programming Selected slides from:
Ihr Logo Operating Systems Internals & Design Principles Fifth Edition William Stallings Chapter 2 (Part II) Operating System Overview.
Processes Introduction to Operating Systems: Module 3.
System Architecture Directions for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister Presenter: James.
Xiong Junjie Node-level debugging based on finite state machine in wireless sensor networks.
WSN Software Platforms - concepts Vinod Kulathumani Lecture uses some slides from tutorials prepared by authors of these platforms.
TinyOS Sandeep Gupta. Operating System (OS) What is an OS? Main functions  Process management  Memory management  Resource management Traditional OSs.
System Architecture Directions for Networked Sensors.
Introduction to Wireless Sensor Networks
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Why does it need? [USN] ( 주 ) 한백전자 Background Wireless Sensor Network (WSN)  Relationship between Sensor and WSN Individual sensors are very limited.
Software Architecture of Sensors. Hardware - Sensor Nodes Sensing: sensor --a transducer that converts a physical, chemical, or biological parameter into.
Wireless Sensors Networks - Network Address Allocation Presented by: Assaf Goren Supervisor: Dr. Yehuda Ben-Shimol.
Implementing Context Aware Applications Class 5. Agenda Review of TinyOS execution model Tutorial on TinyOS Code walk through Code quiz Assignment 2.
INTRODUCTION TO WIRELESS SENSOR NETWORKS
Simulation of Distributed Application and Protocols using TOSSIM
Operating System for Sensor Network
Wireless Sensor Networks
TinyOS: An Operating System for Sensor Networks
Embedded Operating Systems
Chapter 2 Operating System Overview
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Chapter 13: I/O Systems.
Modeling Event-Based Systems in Ptolemy II EE249 Project Status Report
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

TinyOS

Software Challenges - TinyOS Power efficient –Put microcontroller and radio to sleep Small memory footprint –Non-preemptable FIFO task scheduling Efficient modularity –Function call (event and command) interface between commands Application specific Concurrency-intensive operation –Event-driven architecture –No user/kernel boundary

[TinyOS_1]: Table 23 TinyOS Hardware Abstraction Architecture (HAA) Section 2.3 and Figure 2.5 of J. Polastre Dissertation:

TinyOS Hardware Abstraction Architecture (HAA) Ref: Figure 2.4 of J. Polastre Dissertation

Traditional OS Architectures Problem with Large Scale Deeply embedded system.. Large memory & storage requirement Unnecessary and overkill functionality ( address space isolation, complex I/O subsystem, UI ) for our scenario. Relative high system overhead ( e.g, context switch ) Require complex and power consuming hardware support. VMI/O Scheduler Application 1 Application 2 Monolith-kernel HW NFSI/O Scheduler Application 1 Micro-kernel HW IPC VM

NO Kernel Direct hardware manipulation NO Process management Only one process on the fly. NO Virtual memory Single linear physical address space NO Dynamic memory allocation Assigned at compile time NO Software signal or exception Function Call instead Goal: to strip down memory size and system overhead. TinyOS Architecture Overview (1) I/O COMM. ……. Scheduler TinyOS Application Component Application Component Application Component

TinyOS Overview Application = scheduler + graph of components –Compiled into one executable Event-driven architecture Single shared stack No kernel/user space differentiation Communication ActuatingSensing Communication Application (User Components) Main (includes Scheduler) Hardware Abstractions

[TinyOS_4]8 TinyOS Component Model Component has: –Frame (storage) –Tasks: computation –Interface: Command Event Frame: static storage model - compile time memory allocation (efficiency) Command and events are function calls (efficiency) Messaging Component Internal State Internal Tasks CommandsEvents

Power Optimization Energy is the most valuable resource All components must support low power modes (sleep) Low Duty cycle operation –Duty cycle - The proportion of time during which a device is operated Get job done quickly and go to sleep!

The mote revolution: Low Powr Wireless Sensor Network Devices, Hot Chips Typical WSN Application Periodic –Data Collection –Network Maintenance –Majority of operation Triggered Events –Detection/Notification –Infrequently occurs But… must be reported quickly and reliably Long Lifetime –Months to Years without changing batteries –Power management is the key to WSN success sleep wakeup processing data acquisition communication Power Time

The mote revolution: Low Powr Wireless Sensor Network Devices, Hot Chips Design Principles Key to Low Duty Cycle Operation: –Sleep – majority of the time –Wakeup – quickly start processing –Active – minimize work & return to sleep

The mote revolution: Low Powr Wireless Sensor Network Devices, Hot Chips Minimize Power Consumption Compare to Mica2: a MicaZ mote with AVR mcu and radio Sleep –Majority of the time –Telos: 2.4mA –MicaZ: 30mA Wakeup –As quickly as possible to process and return to sleep –Telos: 290ns typical, 6ms max –MicaZ: 60ms max internal oscillator, 4ms external Active –Get your work done and get back to sleep –Telos: 4-8MHz 16-bit –MicaZ: 8MHz 8-bit

Power Consumption

Energy Consumption Idle listen:receive:send = 1:1.05:1.4

[Introduction_2]: Figure 315 TinyOS Radio Stack

[Introduction_2]: Table 216 Code and Data Size Breakdown

WSN Protocol Stack Ref: [Introduction_1] “A Survey on Sensor Networks,” IEEE Communications Magazine, Aug. 2002, pp

TinyOS 2 An operating system for tiny, embedded, and networked sensors NesC language –A dialect of C Language with extensions for components Three Limitations –Application complexity –High cost of porting to a new platform –reliability Little more that a non-preemptive scheduler Component-based architecture Event-driven Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks”

TinyOS 2 Static binding and allocation –Every resource and service is bound at compile time and all allocation is static Single thread of control Non-blocking calls –A call to start lengthy operation returns immediately –the called component signals when the operation is complete –Split phase –See this link for one example _Execution_Model _Execution_Model Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks” Ref: [TinyOS_3] Section 2.1

TinyOS 2 The scheduler has a fixed-length queue, FIFO Task run atomically Interrupt handlers can only call code that has the async keyword Complex interactions among components Event –In most mote applications, execution is driven solely by timer events and the arrival of radio messages ATmega128 has two 8-bit timers and two 16-bit timers Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks”

TinyOS 2 sync code is non-preemptive, –when synchronous (sync) code starts running, it does not relinquish the CPU to other sync code until it completes Tasks –enable components to perform general-purpose "background" processing in an application –A function which a component tells TinyOS to run later, rather than now The post operation places the task on an internal task queue which is processed in FIFO order Tasks do not preempt each other A Task can be preempted by a hardware interrupt See TinyOS lesson: –Modules and the TinyOS Execution Model

and CC2420 CC2420 hardware signals packet reception by triggering an interrupt The software stack is responsible for reading the received bytes out of CC2420’s memory; The software stack sends a packet by writing it to CC2420’s memory then sending a transmit command Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks”

TinyOS 2 Platforms –MicaZ, Mica2, etc; –Compositions of chips Chips –MCU, radio, etc –Each chip follows the HAA model, with a HIL implementation at the top Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks”

TinyOS 2 A T2 packet has a fixed size data payload which exists at a fixed offset The HIL of a data link stack is an active message interface Zero-copy Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks ”

Scheduler in TinyOS 2.x SchedulerBasicP.nc of TinyOS 2.x

TinyOS Serial Stack Ref: P. Levis, et al. “T2: A Second Generation OS For Embedded Sensor Networks”

Device Drivers in T2 Virtualized Dedicated Shared Ref: Section 3 of [Energy_1]

[TinyOS_1]: Section 528 T2 Timer Subsystem MCU comes with a wide variation of hardware timers –ATmega128: two 8-bit timers and two 16-bit times –MSP430: two 16-bit timers Requirement of Timer subsystem –Different sampling rates: one per day to 10kHz

T2 Timer Subsystem See interface at: –tos/lib/timer/Timer.nc

One Example TinyOS Application - BlinkC ials

One Example of Wiring Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

AppM Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

AppM Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

Sensor Interface Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

Initialize Interface Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

SensorC Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

AppC Ref: D. Gay, et al. “Software Design Patterns for TinyOS”

Notation

CTP Routing Stack

Parameterized Interfaces An interface array Ref: D. Gay, et al. “Software Design Patterns for TinyOS”, Section 2.3

unique and uniqueCount Want to use a single element of a parameterized interface and does not care which one, as long as no one else use it Want to know the number of different values returned by unique Ref: D. Gay, et al. “Software Design Patterns for TinyOS”, Section 2.4

section 4.5 "TinyOS Programming manual" 42 async Functions that can run preemptively are labeled with async keyword Command an async function calls and events an async function signals must be async All interrupt handlers are async atomic keyword –Race conditions, data races

Generic Components and Typed Interface Have at least one type parameter Generic Components are NOT singletons –Can be instantiated within an configuration –Instantiated with the keyword new (Singleton components are just named)

/tos/lib/timer/VirtualizeTimerC.n44 Example - VirtualizeTimerC Use a single timer to create up to 255 virtual timers generic module VirtualizeTimerC(typedef precision_tag, int max_timers) Precision_tag: A type indicating the precision of the Timer being virtualized max_timers: Number of virtual timers to create. How to use it? –Components new VirtualizeTimerC(TMilli, 3) as TimerA This will allocate three timers –Components new VirtualizeTimerC(TMilli, 4) as TimerB This will allocate three timers Ref: –/tos/lib/timer/VirtualizeTimerC.nc –Section 7.1 of “TinyOS Programming Manual”

Virtualized Timer

Figure 4 of [TinyOS_1]46 Timer Stack on MicaZ/Mica2

Timer Subsystem HplTimer[0-3]C provide dedicated access to the two 8-bit and two 16-bit timers of ATmega128 MCU T2 subsystem is built over the 8-bit timer 0 Timer 1 is used for CC2420 radio

message_t tos/types/message.h Ref. TEP 111 Every link layer defines its header, footer, and metadata structures

Relationship between CC1000 Radio Implementation and message_t tos/chips/cc1000/CC1000Msg.h

Relationship between CC2420 Radio Implementation and message_t tos/chips/cc2420/CC2420.h

Relationship between Serial Stack Packet Implementation and message_t tinyos-2.x/tos/lib/serial/Serial.h

Active Message (AM) Why do we need AM? –Because it is very common to have multiple services using the same radio to communicate –AM layer to multiplex access to the radio make micaz install,n –n: unique identifier for a node

Active Message Every message contains the name of an event handler Sender –Declaring buffer storage in a frame –Naming a handler –Requesting Transmission –Done completion signal Receiver –The event handler is fired automatically in a target node No blocked or waiting threads on the receiver Behaves like any other events Single buffering Double Check!!!!!!!

TinyOS Component Two types of components –Module: provide implementations of one or more interfaces –Configuration: assemble other components together

TinyOS Component Model Component has: –Frame (storage) –Tasks: computation –Interface: Command Event Frame: static storage model - compile time memory allocation (efficiency) Command and events are function calls (efficiency) Messaging Component Internal State Internal Tasks CommandsEvents

Structure of a Component TinyOS Component Command Handlers Event Handlers Set of Tasks Frame (containing state information)

TinyOS Two-level Scheduling Tasks do computations –Non-preemptable FIFO scheduling –Bounded number of pending tasks Events handle concurrent dataflows –Interrupts trigger lowest level events –Events prempt tasks, tasks do not –Events can signal events, call commands, or post tasks Hardware Interrupts events commands FIFO Tasks POST Preempt Time commands

TinyOS Applications In most mote applications, execution is driven solely by timer events and the arrival of radio messages

How to Program motes Under TinyOS make telosb install,n mib510,/dev/ttyUSB0 make telosb install,1 mib510,/dev/ttyUSB0

Representative WSN Applications BaseStation – Listen – BlinkToRadio –One-hop WSN application to collect sensed values OscilloScope –one-hop WSN application with GUI interface MultiOscilloScopre –multihop WSN application Octopus –multi-hop WSN application with a more dynamic display of network topology and data dissemination functions

Application Example - BaseStation, Listen and BlinkToRadio

Application Example - Oscilloscope

Application Example - MultihopOscilloscope

Application Example - MViz

MViz

Application Example - Octopus

Octopus

BaseStation – Listen - BlinkToRadio

OscilloScope

MultihopOscilloscope

MViz

Octopus

Class Project Group project Goal –develop a multi-hop data collection tree protocol for WSNs –Use the developed tree to collect light intensity information in Lab 209 Collaboration is important