23
mRuby - Powerful Software for Embedded System Development Kyushu Institute of Technology Kazuaki TANAKA mruby developers

mRuby - Powerful Software for Embedded System Development

Embed Size (px)

Citation preview

Page 1: mRuby - Powerful Software for Embedded System Development

mRuby - Powerful Software forEmbedded System Development

Kyushu Institute of TechnologyKazuaki TANAKA

mruby developers

Page 2: mRuby - Powerful Software for Embedded System Development

Lightweight Ruby

● METI Project 2010-2012● Project members:

● Fukuoka CSK● Network Applied Communication Lab(NaCl)● Kyushu Institute of Technology● Toshiba Information Systems● Fukuoka Prefecture● SCSK

Page 3: mRuby - Powerful Software for Embedded System Development

Why using Ruby?

Easy to implement, easy to read

Delivery speed

Decreasing bugs

Maintenance

Team developmentReusability

CostStartup

CostQuality

Software scalability

Software lifetime

Page 4: mRuby - Powerful Software for Embedded System Development

Ruby

● Dynamic Linking

Application

Application

Librariesfor Platform A

Application

Librariesfor Platform B

Dynamic Linkingin Execution

Page 5: mRuby - Powerful Software for Embedded System Development

“Lightweight” Ruby

● Less resources in execution● Memory space

● Language specification● JIS X 3017● ISO/IEC 30170

● Short time to delivery● Apply to any Hardware

Page 6: mRuby - Powerful Software for Embedded System Development

Ruby / mrubyExecution Mechanisms

● “Ruby” is interpreter● Directly execute Ruby codes● Ruby 1.9 uses YARV(VM)

● “mruby” is compiler and VM● Indirectly execute Ruby codes ● Compiler converts Ruby codes into byte-code

(Development environment)● VM executes byte-code

(Execution environment)

Page 7: mRuby - Powerful Software for Embedded System Development

Ruby interpreter

Lexical AnalyzerSyntax Analyzer

Semantic Analyzer

Optimizer

Memory map in execution phase

Memory Management

ExecuterExecution

Preprocess

Page 8: mRuby - Powerful Software for Embedded System Development

Lightweight Ruby

Lexical AnalyzerSyntax Analyzer

Semantic Analyzer

Optimizer

Byte-code Generator

VM

Memory map inCompilation phase

Memory map inExecution phase

Memory Management

Memory Management

● Compiler and VM

VM runs in target device

This phase is done indesktop environment

Byte-code Loader

Page 9: mRuby - Powerful Software for Embedded System Development

Compiler and VM (image)

Byte-code

Ruby Codes

class Motor < Motor3000TS def start @status = :on endend

m1=Motor.newm1.start

LOAD r1, 0 SEND r0, :f0, 1 LOAD r1, 5 SEND r0, :f2, 1

Development

VM

LOAD r1, 0 SEND r0, :f0, 1 LOAD r1, 5 SEND r0, :f2, 1

Target Device

Compiler

Byte-code is portableacross any devices.

Page 10: mRuby - Powerful Software for Embedded System Development

Requirement fromembedded system developers

● Use Ruby language for embedded systems● “Ruby” requires over 20 or more MB memory● Reduce using memory

● Hide Ruby codes● Encryption

● Test and Reliability

Page 11: mRuby - Powerful Software for Embedded System Development

Embedded System Development

● Usual development style● Implement codes in C/C++/Java● Compile and Link, we get executable file● Download executables to target device

Page 12: mRuby - Powerful Software for Embedded System Development

Problems in development

● Implement codes in C/C++/Java● How to keep the quality of programs?

● Compile and Link● Cross-compilation ● Target dependent environment is necessary● Link libraries, we get executable file● We cannot execute this executable in desktop.

● Download executables into target device● We can TEST the executable file. Bugs....fix it

Page 13: mRuby - Powerful Software for Embedded System Development

Development using mruby

● Implement codes in Ruby● Compile, we get an executable file

● We can TEST in desktop.● VM(for desktop) executes byte-code in desktop.

Libraries are linked in execution.

● Download the byte-code into target device● VM(for target) executes byte-code in target device.

Page 14: mRuby - Powerful Software for Embedded System Development

The Mechanism

● VM executes Ruby program+Library● Ruby program(= Byte-code) is

device independent.● Libraries are included in VM

● Target dependent VM is necessary.(Once VM is prepared, we can reuse same VM)

Page 15: mRuby - Powerful Software for Embedded System Development

Dynamic Linking

VM

LOAD r1, 0 SEND r0, :f0, 1 LOAD r1, 5 SEND r0, :f2, 1

Target device

Device dependentmethods

Byte-code

DynamicLinking

● Methods in Libraries are call by “method name”● Even if the library was changed, we can find the

method by seeking method name.

※ “SEND” is like “CALL” instruction.

Page 16: mRuby - Powerful Software for Embedded System Development

Advantages

● Cross-compilation is not necessary● Simple development and test (agile development)● Test in desktop

We don't have to wait the Hardware development.

● Dynamic Linking● Byte-code can be reused across the targets.● Software family management

Page 17: mRuby - Powerful Software for Embedded System Development

Disadvantage

● Execution Speed is slow● C : Ruby ~~ 100:1

● VM is single threaded process● If necessary, multiple VM

● Interruption is not supported● Interruption is catch by C

Ruby is polling request to C

Page 18: mRuby - Powerful Software for Embedded System Development

Application area

● User Interface,Communication● Customize is easy

● Network● Ruby is mainly used in Web applications● Software Deployment in execution time

(Dynamic linking, so we can change libraries in runtime)

● Software Initialization● Boot-up and settings● Tuning, Test in various configurations

Page 19: mRuby - Powerful Software for Embedded System Development

Advisors and their case study

● Toshiba Information System● Solar power regulation and monitoring

● Fuji Electric● Vending machine

● IIJ● Network router

● Manycolors● Bio-informatics

● ILC● GUI Libraries for Embedded Applications

Supported by

Page 20: mRuby - Powerful Software for Embedded System Development

Applications

mruby on FPGA chip

mruby on Industrial manipulatorMultiple VMs on RTOS

Page 21: mRuby - Powerful Software for Embedded System Development

Recent results

● Memory Requirement● RAM 150KB + ROM 250KB

● Target platform:● SH-4, TOPPERS(RTOS)● H8(w/o OS)● NIOS II(FPGA), iTRON

● BeagleBoard(ARM Coretex A8), Linux● GR-SAKURA(Renesas RX63N)(w/o OS)● Of course, Windows, Mac, Linux

Page 22: mRuby - Powerful Software for Embedded System Development

Open Souece Sofrware

● Lightweight Ruby is called 'mruby'● Released in GitHub, beta version

● MIT LicenseYou can use mruby without any chargefor any purpose

● Show the MIT License description and Licenser

https://github.com/mruby

Page 23: mRuby - Powerful Software for Embedded System Development

mruby forum

● NPO mruby forum● Maintain the mruby codes● Support for libraries● License management● Spread

http://forum.mruby.org/