framework for synthesis of host-assisted scripting engines for adaptive embedded systems jiwon hahn,...
Post on 11-Jan-2016
228 Views
Preview:
TRANSCRIPT
Framework for Synthesis of Framework for Synthesis of Host-AssistedHost-Assisted Scripting Scripting
EnginesEngines for Adaptive for Adaptive Embedded SystemsEmbedded Systems Jiwon Hahn, Qiang Xie, Pai Chou
Center for Embedded Computer Systems, UC Irvine
CODES+ISSSSeptember 22, 2005
RappitRappit
2 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Embedded Systems
Embedded
systems
Host-involved Standalone
Hybrid
Medical Device
GPS tracer
Printer
Sensor-net
Battery emulator
MP3 player
PDA
Cell phones
Digital camera
Set-top box
Toy ATM
Copier
Disk drives
DVD
SD
DATAX
eZ 128K TAER DR RS/C CS SO/T RD/R CD/1
32 16 8 4 2 1 SYNCOVFERR -
ALM TEST PWR
ERR INS ERR RSTMODE
0 1
RATE ST SP NCRMODE RATE
+ +
SD
Smart-UPS
6 2 0
www.apcc.com
Vending machine
3 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Embedded Systems Programming Embedded Systems Programming
Current MethodologyLow-level programming (e.g., C, assembly)
Single processor, platform specific approach
Unchanged for decades!
DrawbackTime consuming on re-inventing low-level abstractions
eg., registers, timers, interrupts, I/O ports
Error prone
Requires frequent firmware updateProgramming flash or burning EEPROM
In-field configuration unsupported
Not adequate for emerging large-scale, distributed, adaptive embedded systems
4 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Our Solution: ScriptingOur Solution: Scripting
High-level programmingHuman readable Utilize platform-independent APIsProductivity gain
InteractivityEasy communication between user and platformEnables efficient test/debugging
ReconfigurabilityNo compilation or F/W update requiredIn-field configuration
Code size reductionScripts are usually x5 to x10 shorter than C code [Ousterhout]Reduce memory size & cost, power
5 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Traditional: 6-stage debugging cycle
Scripting: 3-stage debugging cycle
Comparison of design flow
F/W coding Compile
Restart BoardExecute
Write script
Erase Flash Load
Program Verify Flash
Synthesize scripting engine (F/W)
Execute
Load script Compile
Restart Board
Enter bootloader mode
Erase Flash Load
Program Verify Flash
Enter bootloader mode
F/W coding Compile
Restart BoardExecuteErase Flash
Load Program
Verify Flash
Enter bootloader mode
Write script Execute
Load script
6 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Scripting vs. Runtime Overhead Scripting vs. Runtime Overhead
Scripting for General Purpose Computers Assume unlimited resourcesFull feature scripting engine for convenienceSlower than system programming language
Scripting for Embedded SystemsLimited memory, CPU, power, …Need scripting engine optimization
Host assistLanguage subsettingLibrary subsettingEfficient memory usage
Scripting may be even faster than compiled code!
7 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
OutlineOutline
Related Work
Our MethodologyCode Synthesis
Runtime environment
Experimental Results
Conclusion
Future Work
8 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Related Work Related Work
Name Platform Language H I R C PO
PyBAR Router Python Y Y Y N/A x10
SensorWare Sensor tinyTcl Y Y Y >237K ‘high’
Mate Sensor asm-like Y Y 17K ‘low’
Agilla Sensor asm-like Y Y 45K ‘low’
Luxdbg General Tcl Y Y N >237K x10.6
Rappit General Python-like + APIs
Y Y Y 1K-17K None
* H: High level I: Interactivity R: Reconfigurability C: Code size
PO: Performance overhead compared to compiled implementation
9 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Overview of Rappit Runtime SystemOverview of Rappit Runtime System
Provide user one integrated environment Provide user one integrated environment
of the host and target systemsof the host and target systems
H/ W Device
Device Drivers
#include <stdio.h>void main(void){ int a; . . For(i=0;i<2;i++) { . a =b * c; } . . return;}
Rappit F/ W
ApplicationScript
Target SystemHostRappit S/W
Wired/Wireless link
10 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Runtime FlowRuntime FlowHost Comm
LinkTarget
Platform
Scriptmsg
(cmd)P
arse
r
Msg
Gen
erat
or
Pac
keti
zer
Dep
acke
tize
r
Scr
ipti
ng
En
gin
e
Platform
Control
Command
I/O
GUI
Pac
keti
zer
Scr
ipti
ng
En
gin
e
Par
ser
Dep
acke
tize
r
Response
I/O
msg
(ack)
Platform
Response
11 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Scripting Engine OptimizationScripting Engine Optimization
Language Subsetting
Host Assist
Library Subsetting
RF SPI InterruptsGPIOUART ADC
MCUFull-Featured
Component LibraryRFInterrupts
GPIO UART
ADC Sensor1
Customized Library
“print reg1” Host Parser/Msg. gen.
“0x4A0x01”
• User friendly • Easy to parse at node
• Efficient command representation
(compact packet size and runtime repr.)
JoystickLCD Sensor1 Sensor2Dataflash
12 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Our MethodologyOur Methodology
Host-AssistedParser
ComponentLibrary
CodeSynthesizer
GUIMCU
Scripting Engine
ApplicationPrimitives
1. Code Synthesis Flow
2. Runtime Flow
ScriptScript
SystemSystem
DescriptionDescription
13 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Output
I. Code SynthesisI. Code Synthesis
ComponentLibrary
CodeSynthesis
Target F/W(Scripting
Engine,Native
Routines, …)
Architecture
Description
Application
Description
Communication
Description
CompatibleMessage format
Interactive
LanguageBinary
Executable
HostTarget System
Host S/W(Parser, MsgGen,GUI, …)
Input
14 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
I. Code Synthesis - I. Code Synthesis - Packet Format ExamplesPacket Format Examples
Command Packet Format
Response Packet Format
Dest. Msg ID Opcode Arg1 Arg2 Arg3 CRC
Src. Msg ID Msg Type Data Type Payload CRC EOP
Command Message Format
Response Message Format
15 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
II. Runtime EnvironmentII. Runtime Environment
Parser
ComponentLibrary
Packetizer/Dispatcher
PacketManager
GUI
Cmd prompt
IDE Packetizer/Depacketizer
ScriptingEngine
AdmissionController
Native Routines
Host
command
response
packet
MCU
Msg Gen.
16 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
II. Runtime Environment – II. Runtime Environment – Scripting ExamplesScripting Examples
Interactive port setting >> PORTA[2] = 1; PORTA[2] = 0 # toggle clock>> PORTA[1] = 1 # set port A pin 1>> PORTA[0] # read input pin0>> PORTA[2] = 1; PORTA[2] = 0 # toggle clock>> PORTA[0] # read input pin1
System configuration >> mcu.sysclock = 1 MHz # set system clock speed>> uart.baudrate = 9600 bps # set baudrate for UART>> rf.power = -5 db # set RF tx power>> rf.speed = 1 Mbps # set RF throughput>> rf.config # query the configuration{’payload’: 1, ’power’: -5, ’speed’: 1000000, ’channel’:100, ’mode’: ’TX’}
Scheduling>> every(50 ms, ’sample’) >> stop(’sample’)
17 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Experimental Setup IExperimental Setup I
Atmel ATmega169
8-bit MCU @ 8MHz, 512B EEPROM, 1KB SRAM, 16KB program flash
Connected to dataflash, speaker, sensors, joystick, LCD
USART serial link at 9600 baud
AVR Butterfly board
AVR ButterflyAVR Butterfly AVR Butterfly w/ Wireless moduleAVR Butterfly w/ Wireless module
18 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Experimental Setup IIExperimental Setup II
HC12 Controller in Mini-FDPMFreeScale16-bit MC9S12NE64
16KB RAM, 64KB program flash
SPI, I2C, GPIO, ADC
Built-in Ethernet
AmplitudeDetector
PhaseDetector
Mixer
PowerSplitter
CrystalFilter
Laser 1
Laser 2
Laser 3
Laser 4
RFSwitch FilterMixer
Mixer
PowerDivider
Filter
Filter
Amp
Amp
PowerCoupler
LocalOscillator
BroadbandOscillator
2
BroadbandOscillator
1
TCXO
16bit microcontroller with ethernet
Host ComputerHost Computer
Mini-FDPMMini-FDPM
HC12HC12
EthernetEthernet
19 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Metrics and ModalityMetrics and Modality
Observation Metrics
Execution Modality
Metric UnitCode size Bytes
Execution Speed Cmds/sec
Modality Approach Programming MethodNative Compiled Program the firmware onto the Flash
Batch Scripting Preload a script program onto the RAM
Interactive Scripting Send one line of command to the RAM
20 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Experimental Results - Code Size Experimental Results - Code Size
ExperimentTest code included 100 cmds, 9 instruction types
Same subroutines and packet handlers used
Code size observed from compiled code and memory map
ResultScripting engine is a thin layer
Rappit achieves big reduction in application code size
21 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Experimental Results - Execution SpeedExperimental Results - Execution Speed
ExperimentRelative comparison by setting host timer with same conditions
Same experiment repeated several times
3 different applications
ResultBatch mode scripting can be faster than native!
Same pattern observed in other experiments
Observed up to 25.7% speed-up
Memory access could be the key
22 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Summary of ResultsSummary of Results
Code size reduction
Performance overhead components analysisNative Interactive Batch
Communication 1 3 1
RAM Access 3 1 1
ROM Access 3 1 1
Packetization 1 2 2
Interpretation 1 2 2
Total cmd/sec 92 4.75 111
Application Native Rappit Reduction
Reg setting 4.356 KB 1.664 KB 61.8%
LCD usage 12.45 KB 4.2 KB 66.3%
1: fast
2: tolerable
3: slow
(bottleneck)
23 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
ConclusionConclusion
Scripted the embedded systems High-level programming
Interactivity
Reconfigurability
Code size reduction
Overcame scripting overheadHost assistance
Script subsetting
Library subsetting
Effective memory usage
Synthesis Systematic generation of scripting environment
24 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Future WorkFuture Work
More dynamic schemeAllow new native code to be added
Mapping to richer set of syntaxEg., http to allow access as web device
Memory management in the targetSet evaluation order to reduce memory usage
Parser optimizationParsing simplicity vs. expressiveness
25 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Thank you!Thank you!
26 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Backup SlidesBackup Slides
27 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Code Size of Each Rappit ComponentsCode Size of Each Rappit Components
Host Code (.py) Lines Size (KB)
GUI 644 21.8
Cmd 127 2.87
Parser &
Msg Generator
221 4.97
Library 263 6.396
Packetizer &
Depacketizer
82 2.0
Packet Mgr 42 0.92
Total 1379 38.96
MCU Code (.c) Lines Size
(KB)
Interpreter 260 -
Primitives 90 -
Packetizer &
Depacketizer
300 -
Total 750 1.484
28 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
Goals of Embedded SystemsGoals of Embedded Systems
Embedded Embedded SystemSystem
GoalsGoals
High Adaptability
Low power
Low cost
High performance (speed)
Small size
Fast development cycle
29 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
I. Code SynthesisI. Code Synthesis
Input: system description script# example: pin mapping for an RF modulemcu = MCU(ATmega169) # instantiate an atmega169 MCUimport RF # load a transceiver modulerf = RF(nRF2401) # instantiate nRF2401 transceiverrf.CS = mcu.PORTB[0] # connect the chip select pinrf.CE = mcu.PORTB[1] # connect the chip enable pinrf.DR1 = mcu.PORTB[2] # connect the data ready pinrf.CLK1 = mcu.PORTF[1] # connect the clock pin
rf.DOUT1 = mcu.PORTF[2] # connect the data pin
Output: Rappit software for host, firmware for the target platform
30 www.ece.uci.edu/~jhahn/www.ece.uci.edu/~jhahn/
I. Code SynthesisI. Code Synthesis
Command FormatMachine-efficient representation of a commandApplication-specificPain to reinvent for each applicationNeed auxiliary code to handle each command format
Automatic Command Format definitionSynthesizer generates the command formatCoherent between host and target
End user syntax parsed and mapped to command format in the host parserCommand format interpreted by the target scripting engine
top related