ttx2005-haa

advertisement
The Hardware Abstraction Architecture
of TinyOS 2.x
Vlado Handziski*, Joseph Polastre†, Jan Hauer*,
Cory Sharp†, Adam Wolisz* and David Culler†
*Telecommunication
Networks Group
Technische Universität Berlin
†Computer
Science Department
University of California, Berkeley
Energy efficient sensor networks
Hardware Abstraction in WSN Operating Systems

What is the most appropriate level of hardware abstraction?

Two seemingly conflicting requirements
Energy-efficient implementation
 Low level of abstraction

Rapid application development
 High level of abstraction


How to effectively reconcile this gap?
Reconfigurable operating system
architecture

TinyOS
 Let the application programmer choose
the appropriate level of abstraction


How to organize the hardware
abstraction into components?
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
2
Application
HA
Hardware
Abstraction
HA
HA
Hardware
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Hardware Abstraction Architecture for TinyOS 2.x
Combine the component model with a flexible,
three-tier organization of the hardware abstraction
Cross-platform applications
Platform-specific
applications
Platform-specific
applications
Hardware independence
Platform-independent hardware interface
HIL 1
HIL 2
HAL 1
HAL 2
HPL 1
HPL 2
HIL 3
HIL 4
HAL 3
HAL 4
HPL 3
HPL 4
HW/SW
boundary
HW platform 1
Telecommunication Networks Group
Technische Universität Berlin
HW platform 2
HW platform 3
TinyOS Technology Exchange II
3
HW platform 4
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Outline


Hardware Abstraction for WSN Operating Systems
Three-layer Hardware Abstraction Architecture





Flexibility of the Architecture
Application to Specific Hardware Modules


Hardware Presentation Layer (HPL)
Hardware Adaptation Layer (HAL)
Hardware Interface Layer (HIL)
Analog-to-Digital Converters (ADC)
Conclusion
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
4
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Hardware Presentation Layer (HPL)


“Present” the capabilities of the hardware
using the native concepts of the OS
Interfaces fully determined by the HW
module capabilities, but have a common
structure





Initialization, starting and stopping
Getting and setting of the control registers
Enabling/disabling of interrupts
Service routines for the generated interrupts
Stateless, does not provide substantial
abstraction over the hardware, but hides
the most hardware-dependent code

Higher abstractions can change between HW
modules of the same class with rewiring
instead of rewriting
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
5
Cross-platform
application
HIL
HAL
HPL
HW platform
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Hardware Adaptation Layer (HAL)



Uses the raw interfaces provided by the
HPL to build useful abstractions
Exposes the “best” possible abstraction
for the given hardware without
compromising efficiency for convenience
Exports domain specific interfaces
instead of narrow and overloaded
abstractions


Cross-platform
application
HIL
HAL
Alarm, ADC Channel, EEPROM Page…
Maintains state, performs arbitration and
resource control if needed
HPL
HW platform
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
6
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Hardware Interface Layer (HIL)



Convert the platform-specific HAL
abstractions into hardware-independent
interfaces
Tension between keeping this API
“contract” unchanged and efficient use of
the capabilities on new hardware
Evolution in discrete jumps




Realign the HIL interfaces with the HAL
abstractions of the newer platforms
New platforms get “thinner” HIL components
Old platforms will require more “boosting”
Cross-platform
application
ver. 1
HIL
HIL
HIL
HAL
HPL
Support for legacy platforms


HIL interface versioning
Write applications using legacy interfaces
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
7
HW platform
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Properties: Why three-layers?



Why not expose the platformindependent interfaces
directly at the HAL level?
Because of the increased
flexibility resulting from the
separation!
Platform-specific
application
HIL
HAL
For maximum performance, the platformspecific applications can directly tap to
the HAL interfaces that provide optimized
access to the hardware


Cross-platform
application
HAL
HPL
Similar in spirit with MIT’s Exokernel work
Layering does not mean overhead
because of the nesC heavy in-lining
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
8
HW platform
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
First Experiences with the Architecture

First used during the porting of TinyOS to the Texas
Instruments MSP430 microcontroller family



Contained abstractions of the ADC, timer and bus modules
Implementation official part of TinyOS since ver.1.1.7
Code successfully used for a year by at least two platforms,
Telos and Eyes
MainM
Main
Clock
System
60 KB
Flash
2 KB
RAM
12-Bit ADC
USART0
RISC CPU
16-Bit
16-Bit
Bus Conv
16-Bit
BusArbitrationC
HPLInitC
USART1
4-Bit
MAB
8-Bit
MDB
HPLInitM
MSP430ClockC
MSP430ClockM
BusArbitrationM
TimerB
I/O port 1/2
Interrupt
Capability
I/O port 3-6
TimerC
TimerM
MSP430InterruptM
HPLSpiM
HPLUARTM
HPLUSART0M
HPLUSART1M
ADCM
MSP430ADC12M
TimerA
MSP430InterruptC
MSP430TimerC
MSP430TimerM
HPLUARTC
ADCC
MSP430ADC12C
RefVoltM
RefVoltC
HPLADC12M
The TI MSP430F149 μC
The MSP430 platform in TinyOS 1.1.7
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
9
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Example: Abstraction of the ADC modules

Challenge


High variability in the capabilities of the ADC hardware

Resolution

Conversion modes

Number of channels

Reference voltages

Conversion clock sources

Sample-and-hold times

Triggering
Goal

Gradually adapt these differences and provide useful
platform-independent ADC abstraction to the application
programmer while offering direct access when needed
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
10
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Example: HPL ADC interface (MSP 430 platform)


Completely defined by the capabilities of the ADC12
Provides low-level access to the hardware module
HPL Commands
 Standard Control







…
init()
start()
stop()


setControl0()
getControl0()
setMemControl()
getMemControl()


…
setIEFlags()
getIEFlags()
isInterruptPending()
Telecommunication Networks Group
Technische Universität Berlin




setConversionMode()
isBusy()
setSHT()
setRefOn()
getRefOn()
setRef2_5V()
getRef2_5V()
…
Interrupt flag manipulation

Configuration flag manipulation

Full register reading/writing



HPL Events



TinyOS Technology Exchange II
11
memOverflow()
timeOverflow()
converted()
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Example: HAL ADC interface (MSP430 platform)

Based on a “ADC channel” abstraction exported as
parameterized interface




“bind” call used to configure each interface with the settings
supported by the hardware module
Data requested using the traditional getData()
Available data signaled via dataReady() events
“reserve” call for low-latency sampling support
HAL Commands






bind()
getData()
getDataRepeat()
reserve()
reserveRepeat()
unreserve()
HAL Events

dataReady()
Telecommunication Networks Group
Technische Universität Berlin
HAL supported settings








input channel
reference voltage
reference voltage level
clock source sample-hold-time
sample-hold-time
clock source sampcon signal
clock divider sampcon
clock divider sample-hold-time
TinyOS Technology Exchange II
12
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Example: HIL ADC interface (cross-platform)


Wrapper that transforms a platform-independent
“sensor” abstraction into platform-specific HAL calls
and settings for the “bind” command
Exported interface is a compromise between the
capabilities of the supported HW platforms
HIL Commands
ADCHIL
StdControl


TemperatureC
TemperatureM
MSP430ADC12

MSP430ADC12C
Temperature sensor HIL wrapper
on the MSP430 platform
Telecommunication Networks Group
Technische Universität Berlin

TinyOS Technology Exchange II
13

getData()
getDataContinuous()
reserve()
reserveContinuous ()
unreserve()
HIL Events

dataReady()
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Conclusion

The new HAA continues TinyOS philosophy of making
it possible to operate at higher levels of abstraction
without forcing that on all applications




Code in HPL: trivial - just gives an interface to the raw
hardware
Code in HAL: implements a useful abstraction efficiently
Code in HIL: adapt the platform-specific capability into a
hardware independent form
Application to the ADC module


The new “sensor” stack offers richer functionality
Now available as a common abstraction on several
platforms
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
14
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Questions?
More information available:
TEP 2: Hardware Abstraction Architecture
TEP 102: Analog-to-Digital Converter Abstraction
Energy efficient sensor networks
BACKUP

Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
16
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Properties: Mixing Levels of Abstraction


Sometimes only parts of the
application require efficient
access to the hardware
MAC
Example: OscilloscopeRF


Sample values from a temperature sensor and
send them over the radio
Temperature sampling is not critical
use the cross-platform HIL interfaces

Application
Application
Temperature
HIL
HAL
MAC requires efficient use of the ADC
use the platform-specific HAL interfaces

We end up with a concurrent use of the same
ADC hardware module with two different levels
of abstraction
HPL
 more complex arbitration and resource control
ADC module
functionality in the HAL components
Telecommunication Networks Group
Technische Universität Berlin
TinyOS Technology Exchange II
17
Computer Science Department
University of California, Berkeley
energy efficient sensor networks
Download