
844192c90406680b35635b574a2ee575.ppt
- Количество слайдов: 30
Rappit Framework for Synthesis of Host-Assisted Scripting Engines for Adaptive Embedded Systems Jiwon Hahn, Qiang Xie, Pai Chou Center for Embedded Computer Systems, UC Irvine CODES+ISSS September 22, 2005
Embedded Systems Host-involved Standalone GPS tracer Toy ATM Medical Device Embedded Sensor-net Set-top box Copier systems Printer Battery emulator Disk drives Hybrid Vending machine MP 3 player Cell phones Digital camera PDA 2 www. ece. uci. edu/~jhahn/
Embedded Systems Programming Current Methodology Low-level programming (e. g. , C, assembly) Single processor, platform specific approach Unchanged for decades! Drawback Time consuming on re-inventing low-level abstractions eg. , registers, timers, interrupts, I/O ports Error prone Requires frequent firmware update Programming flash or burning EEPROM In-field configuration unsupported Not adequate for emerging large-scale, distributed, adaptive embedded systems 3 www. ece. uci. edu/~jhahn/
Our Solution: Scripting High-level programming Human readable Utilize platform-independent APIs Productivity gain Interactivity Easy communication between user and platform Enables efficient test/debugging Reconfigurability No compilation or F/W update required In-field configuration Code size reduction Scripts are usually x 5 to x 10 shorter than C code [Ousterhout] Reduce memory size & cost, power 4 www. ece. uci. edu/~jhahn/
Comparison of design flow Traditional: 6 -stage debugging cycle F/W coding Enter bootloader mode Compile Execute Erase Flash Load Program Verify Flash Restart Board Scripting: 3 -stage debugging cycle Load script Write script Synthesize scripting engine (F/W) Compile Restart Board Execute 5 Enter bootloader mode Erase Flash Load Program Verify Flash www. ece. uci. edu/~jhahn/
Scripting vs. Runtime Overhead Scripting for General Purpose Computers Assume unlimited resources Full feature scripting engine for convenience Slower than system programming language Scripting for Embedded Systems Limited memory, CPU, power, … Need scripting engine optimization Host assist Language subsetting Library subsetting Efficient memory usage Scripting may be even faster than compiled code! 6 www. ece. uci. edu/~jhahn/
Outline Related Work Our Methodology Code Synthesis Runtime environment Experimental Results Conclusion Future Work 7 www. ece. uci. edu/~jhahn/
Related Work Name Platform Language H I Py. BAR Router Python Y Y Y N/A x 10 Sensor. Ware Sensor tiny. Tcl Y Y Y >237 K ‘high’ Mate Sensor asm-like Y Y 17 K ‘low’ Agilla Sensor asm-like Y Y 45 K ‘low’ Luxdbg General Tcl Y Y N >237 K x 10. 6 Rappit General Python-like + APIs Y Y Y 1 K-17 K None * H: High level I: Interactivity R C R: Reconfigurability PO C: Code size PO: Performance overhead compared to compiled implementation 8 www. ece. uci. edu/~jhahn/
Overview of Rappit Runtime System Provide user one integrated environment of the host and target systems 9 www. ece. uci. edu/~jhahn/
Runtime Flow 10 Scripting Engine (ack) Scripting Engine msg Depacketizer Packetizer Msg Generator (cmd) Packetizer I/O GUI msg Depacketizer Response Parser I/O Script Parser Command Target Platform Comm Link Host Platform Control Platform Response www. ece. uci. edu/~jhahn/
Scripting Engine Optimization Language Subsetting Host Assist “print reg 1” • User friendly Host Parser/ Msg. gen. “ 0 x 4 A 0 x 01” • Easy to parse at node • Efficient command representation Library Subsetting Full-Featured Component Library (compact packet size and runtime repr. ) Customized Library MCU Interrupts RF RF Dataflash SPI UART GPIO Interrupts ADC LCD Joystick Sensor 1 Sensor 2 11 GPIO UART ADC Sensor 1 www. ece. uci. edu/~jhahn/
Our Methodology System Description 1. Code Synthesis Flow 2. Runtime Flow Code Synthesizer Script GUI Host. Assisted Parser 12 Component Library MCU Scripting Engine Application Primitives www. ece. uci. edu/~jhahn/
I. Code Synthesis Input Architecture Application Communication Description Code Synthesis Interactive Language Host S/W Host Output Component Library Target F/W (Scripting (Parser, Engine, Msg. Gen, Compatible Native GUI, …) Message format Routines, …) 13 Binary Executable Target System www. ece. uci. edu/~jhahn/
I. Code Synthesis Packet Format Examples Command Packet Format Dest. Msg ID Opcode Arg 1 Arg 2 Arg 3 CRC Command Message Format Response Packet Format Src. Msg ID Msg Type Data Type Payload CRC EOP Response Message Format 14 www. ece. uci. edu/~jhahn/
II. Runtime Environment Host IDE Parser Cmd prompt GUI Component Library Msg Gen. MCU Packetizer/ packet Packetizer/ Dispatcher Depacketizer Packet Manager Admission Controller Scripting Engine Native Routines command response 15 www. ece. uci. edu/~jhahn/
II. Runtime Environment – Scripting Examples Interactive port setting >> >> >> 0 >> >> 1 PORTA[2] = 1; PORTA[2] = 0 # toggle clock PORTA[1] = 1 # set port A pin 1 PORTA[0] # read input pin PORTA[2] = 1; PORTA[2] = 0 # toggle clock PORTA[0] # read input pin 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’) 16 www. ece. uci. edu/~jhahn/
Experimental Setup I AVR Butterfly board Atmel ATmega 169 8 -bit MCU @ 8 MHz, 512 B EEPROM, 1 KB SRAM, 16 KB program flash Connected to dataflash, speaker, sensors, joystick, LCD USART serial link at 9600 baud AVR Butterfly w/ Wireless module AVR Butterfly 17 www. ece. uci. edu/~jhahn/
Experimental Setup II HC 12 Controller in Mini-FDPM Free. Scale 16 -bit MC 9 S 12 NE 64 16 KB RAM, 64 KB program flash SPI, I 2 C, GPIO, ADC Built-in Ethernet Mini-FDPM HC 12 Host Computer Ethernet 18 www. ece. uci. edu/~jhahn/
Metrics and Modality Observation Metrics Metric Unit Code size Bytes Execution Speed Cmds/sec Execution Modality Approach Programming Method Native 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 19 www. ece. uci. edu/~jhahn/
Experimental Results - Code Size Experiment Test code included 100 cmds, 9 instruction types Same subroutines and packet handlers used Code size observed from compiled code and memory map Result Scripting engine is a thin layer Rappit achieves big reduction in application code size 20 www. ece. uci. edu/~jhahn/
Experimental Results - Execution Speed Experiment Relative comparison by setting host timer with same conditions Same experiment repeated several times 3 different applications Result Batch 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 21 www. ece. uci. edu/~jhahn/
Summary of Results Code size reduction Application Native Rappit Reduction Reg setting 4. 356 KB 1. 664 KB 61. 8% LCD usage 12. 45 KB 4. 2 KB 66. 3% Performance overhead components analysis Native Interactive Batch Communication 1 3 1 RAM Access 3 1 1 ROM Access 3 1 1 Packetization 1 2 2 3: slow Interpretation 1 2 2 (bottleneck) Total cmd/sec 92 4. 75 111 22 1: fast 2: tolerable www. ece. uci. edu/~jhahn/
Conclusion Scripted the embedded systems High-level programming Interactivity Reconfigurability Code size reduction Overcame scripting overhead Host assistance Script subsetting Library subsetting Effective memory usage Synthesis Systematic generation of scripting environment 23 www. ece. uci. edu/~jhahn/
Future Work More dynamic scheme Allow new native code to be added Mapping to richer set of syntax Eg. , http to allow access as web device Memory management in the target Set evaluation order to reduce memory usage Parser optimization Parsing simplicity vs. expressiveness 24 www. ece. uci. edu/~jhahn/
Thank you! 25 www. ece. uci. edu/~jhahn/
Backup Slides 26 www. ece. uci. edu/~jhahn/
Code Size of Each Rappit Components Host Code (. py) Lines Size (KB) GUI 644 21. 8 Cmd 127 Parser & Msg Generator 221 Library MCU Code (. c) Lines Size (KB) 2. 87 Interpreter 260 - 4. 97 Primitives 90 - 300 - 263 6. 396 Packetizer & Depacketizer 82 2. 0 Total 750 1. 484 Packet Mgr 42 0. 92 Total 1379 38. 96 27 www. ece. uci. edu/~jhahn/
Goals of Embedded Systems Fast development cycle High Adaptability Embedded System Low power Goals Low cost Small size High performance (speed) 28 www. ece. uci. edu/~jhahn/
I. Code Synthesis Input: system description script # example: pin mapping for an RF module mcu = MCU(ATmega 169) # instantiate an atmega 169 MCU import RF # load a transceiver module rf = RF(n. RF 2401) # instantiate n. RF 2401 transceiver rf. CS = mcu. PORTB[0] # connect the chip select pin rf. CE = mcu. PORTB[1] # connect the chip enable pin rf. DR 1 = mcu. PORTB[2] # connect the data ready pin rf. CLK 1 = mcu. PORTF[1] # connect the clock pin rf. DOUT 1 = mcu. PORTF[2] # connect the data pin Output: Rappit software for host, firmware for the target platform 29 www. ece. uci. edu/~jhahn/
I. Code Synthesis Command Format Machine-efficient representation of a command Application-specific Pain to reinvent for each application Need auxiliary code to handle each command format Automatic Command Format definition Synthesizer generates the command format Coherent between host and target End user syntax parsed and mapped to command format in the host parser Command format interpreted by the target scripting engine 30 www. ece. uci. edu/~jhahn/