Real-Time Software Components A Scalable Component Model for Embedded C Development Dave Russo, Texas Instruments Introducing Real-Time Component (RTSC) © 2008 Texas made available under the EPL v1.0 © 2008 by Texas Instruments; made Software available under the EPL| v1.0 | by Feb 12,Instruments; 2008 1 Outline what problem does RTSC solve what distinguishes RTSC from existing solutions “brief” technical overview of RTSC existing use of RTSC and what’s next summary and questions Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 2 In 25 Words Or Less .... RTSC is a C-based software component model for developing, delivering, and deploying re-usable real-time software targeted for diverse embedded platforms QUALITY without compromising system performance ! Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 3 RTSC Components Key Characteristics dual-existence Benefits increased design-time optimizations • target-code: runs on resource limited HW • meta-code: runs on rich client platforms meta-code manages component lifecycle • build of component (including target-side) • integration during application assembly • monitoring during test and after deployment • transparently bind alternate implementations • objects can be created at design-time • no embedded runtime requirements enables new tooling opportunities • meta-code can proxy for target-code • components differentiate in meta-domain Application Application RTSC Component C RTSC Component B target-code meta-code RTSC A A Component target-code meta-code (C) (JavaScript) target-code meta-code (C) (JavaScript) target-code C B target-code A target-code (C) (C) target-code (C) (JavaScript) Rich Client Platform Embedded Platform Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 4 Component-Based Systems Essential Characteristics S R S R S′ INTERCHANGABILITY R T C REUSABILTY Basic Requirements FORMAL SPECIFICATIONS UNIFORM PACKAGING CONFIGURABLE ASSEMBLY Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 5 Programming-In-The-Large logical & physical software container headers, libraries, progs, scripts, docs, ... managed, versioned, delivered as a whole 7 multiple targets, platforms, configurations explicit dependencies on other packages 106 – 10 lines of source code concrete & closed abstract & open encapsulates cohesive { types, fxns } external client contract — “spec” internal implementation — “body” abstract module — spec but no body extended & implemented by others enables generic client applications PACKAGE MODULE INTERFACE standard C functions & structs 10s 100s 1000s Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 6 RTSC Specification separates specification from implementation INTERFACE SPECIFICATION C-like declarations, assertions, commentary bridges SW design • development phases package ti_std; interface IA { enum E {E1, E2}; Int fxn1(); } RTSC .h eliminates tedious maintenance of headers leverages advanced programming patterns readily integrates with other SW tooling .xdc #include MODULE IMPLEMENTATION MODULE SPECIFICATION package my_pkg; module ModA inherits ti_std.IA { config Int max; Int32 fxn2(E e); } RTSC .h #include generated headers .xdc // natural map to ANSI C // formalize best practices // implement specified fxns // access specified configs // call legacy C or ASM fxns // fun-to-write, easy-to-read .c Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 7 RTSC Packaging physical organization reflects logical design PACKAGE SPECIFICATION contents remain intact during deployment requires your_pkg [1,3]; version dependencies to ensure integrity package my_pkg [2,4,5] { interface … ; module … ; } portable makefiles for build • test • release manage diverse set of targets & platforms .xdc PACKAGE MANIFESTATION universal OS-independent + CM-agnostic PACKAGE DEPLOYMENT package-repository path c:/work; h:/share; … my_pkg/ source files generated files my_pkg/ special files your_pkg/ ti_std/ Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 8 RTSC Configuration CONFIGURATION META-PROGRAM model program structure prior to link / load expressed in powerful C-like meta-language // include modules ModA = xdc.useModule("my_pkg.ModA"); ModB = xdc.useModule("your_pkg.ModB"); per-package participation during validation per-package contribution during generation // initialize module-wide configs ModA.max = 64; automate error-prone integration processes // create static instances inst = ModB.create({x:10, y:20}); enable new levels of program optimization // assign program-level properties Program.global.inst = inst; Program.stack = 256; .cfg XDCscript package agents TARGET APPLICATION PROGRAM #include <my_pkg/ModA.h> #include <your_pkg/ModB.h> main() { ModA_fxn1(); ModB_fxn2(inst); … } JavaScript Program information model program validation program generation target libraries data tables misc code linker cmds .c .obj COMPONENT ASSEMBLY Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 9 Multiple Implementations Application Configuration platform: 'ti.platforms.evm6446' 'ti.platforms.omap3430' target: 'ti.targets.C64' Benefits platform binding Task = xdc.useModule('ti.bios.Task'); MP4 = xdc.useModule('ti.omapsw.mpeg4.ENC'); app G723 = xdc.useModule('3p.codecs.g723.ENC'); config MP4.profile = "base"; script : Platform Package ti.platforms.omap3430 ti.platforms.evm6446 C64 rev 3 2 HWA21 timer21 Targets Package ti.targets C64 C28 C55 … DSP/BIOS Package ti.bios platform independent timer3 timer 2 timer 1 DMA3 DMA DMA1 2 extensible to any platform and target app-specific implementation selection package-specific platform adaptation config, package, and platform validation one configuration tool for all content Package MEG4MEG4 Package ti.omapsw.mpeg4 ti.omapsw.mpeg4 G723 Package 3p.codecs.g723 platform independent platform platform independent independent G726 Package 3p.codecs.g726 timerBC timer C timer timer HWA B C timer BC B HWA Btimer timer HWA timer B DMA HWA B HWA HWA 1 HWA DMA1 1 1B HWA B platform independent RTSC enables rapid tuned (re)assembly of binary components Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 10 Extended Object Lifecycle 1needs implementation, runtime memory 2 usage manager models no memory allocation required uniform “run-once” instance instance lifecycle creation APIs code no runtime initialization errors built-in dead error lifecycle handling monitoring code only “core” module methods used // include modules ModB = xdc.useModule("your_pkg.ModB"); #include <stdlib.h> <your_pkg/ModB.h> #include <your_pkg/ModB.h> ModB_Handle mybee; ModB_Handle mybee; main() { main(int argc, char *argv[]) { /* initialize system */ /* initialize system */ ModB_Params params; ModB_Params params; ModB_Params_init(&params); ModB_Params_init(&params); params.x = 10; params.y = 20; params.x = atoi(argv[1]); mybee = ModB_create(&params); mybee = ModB_create(&params); if (mybee == NULL) … if start (mybeereal-time == NULL) processing … /* */ forstart /* (;;) real-time { processing */ for ModB_fxn2(mybee); (;;) { … } ModB_fxn2(mybee); … } } } // create static instances Program.global.mybee = ModB.create({x:10, y:20}); RTSC #include <your_pkg/ModB.h> #include <xdc/cfg/global.h> main() { for (;;) { ModB_fxn2(mybee); … } } A single RTSC module supports both static and runtime use Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 11 Real-Time Monitoring /* create a decoder for the app */ var dec = Packages.my_pkg.Decoder("app.out"); /* open stream of of events */ var file = java.io.FileReader("output.dat"); /* read next event from the file into buf */ while (readEvent(file, buf) != -1) { /* decode the event and print it */ var e = dec.apply(buf); print(e.eventMsg); } package my_pkg; public class Decoder { public Decoder(File file) { } : } public class Server { public Server (Decoder decoder,InputStream in){…} public Event getNextEvent() {…} public bool enable() {…} public bool disable() {…} } fast deterministic “printf” trace minimal footprint (100’s of bytes vs. 35K bytes) host-side control, interpretation, analysis rich package-specific interpretation #include <my_pkg/Log.h> void Log_printf(char Log_value(int value) *fmt,{…) { `copy args valueto tocircular circularbuf` buf` } H Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 12 Real-Time Monitoring Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 13 Case Study: DSP/BIOS 4th most popular* embedded RTOS single binary bundle of RTSC packages supports 19 targets and over 120 devices 1. VxWorks 2, 3. WinCE, XP 4. DSP/BIOS 5. RH Linux used in cell phones, barcode scan, heart defib scales from 2KB MSP430 to 60KB C64x Sources are 94% platform independent * 2006 Embedded System Design DSP/BIOS Lines of Code Targets 20 6% 15 31% C64-specific IDL 10 42% XDCscript Portable C 5 21% 0 2000 2001 2002 2003 2004 … 2008 Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 14 XDCtools Accelerate Adoption focus on “ease-of-use” emphasize compatibility better docs — RTSCpedia Eclipse integration (CDT, …) open-source XDCtools (EPL) basic tools & utilities package life-cycle support program life-cycle support program run-time support meta-language — XDCscript ANSI C specification language — XDCspec XDCtools 1.x 1999 2004 xDAIS 2.x 2006 DSP/BIOS 5.x CodecEngine 3.x 2007 2009 SYS/BIOS 6.x % target software managed content specified content Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 15 What’s Next? Tooling Content CDT Integration (new targets …) Inter-Component-Comm Framework(s) Unit-Test Framework (TPTP) Application-Specific Frameworks (SDR) UML & Modeling Integration (EMF) Advanced Diagnostics & Trace (SODA) Refactoring & Design Tools (???) OS Integration (Linux, VxWorks, …) Infrastructure Enhanced RT Monitoring Design-By-Contract Portable RPC Support C++ Binding basic tools & utilities package life-cycle support program life-cycle support meta-language — XDCscript program run-time support ANSI C specification language — XDCspec Community suggestions (and contributions) are welcome Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 16 Summary RTSC enables “write once, deploy widely” for deeply embedded SW Dual-domain breaks the “generality vs. application-optimized” standoff XDCtools is successfully being used by thousands of TI customers RTSC bridges the gap between embedded-C and component-centric tools http://wiki.eclipse.org/DSDP/RTSC RTSC Project Proposal: currently in the proposal stage RTSC White Paper: high-level overview of the XDCtools technology RTSC Component Primer: how to create & use RTSC components XDCtools: the starting point for the RTSC project’s code base Introducing Real-Time Software Component (RTSC) | © 2008 by Texas Instruments; made available under the EPL v1.0 17