concurrent blinkenlights and more! · pdf fileconcurrent blinkenlights and more! omer kilic |...

32
Erlang Embedded Concurrent Blinkenlights and More! Omer Kilic || @OmerK [email protected]

Upload: hoangque

Post on 18-Mar-2018

223 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

Erlang EmbeddedConcurrent Blinkenlights and More!

Omer Kilic || @[email protected]

Page 2: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 2/32

Agenda

● Overview of the KTP Project● Challenges in Modern Embedded Systems● Current State of Erlang in Embedded Domain● Our Plans for Erlang Embedded● Questions

Page 3: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 3/32

Knowledge Transfer Partnership“Erlang for a New Era of Embedded Computing”, Ulf Wiger, EUC 2011

Page 4: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 4/32

Knowledge Transfer Partnership

“The aim of this KTP project is to bring the benefits of concurrent systems

development using Erlang to the field of embedded systems; through investigation, analysis, software development and evaluation.”

Page 5: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 5/32

Challenges in Embedded Systems (I)

● Larger, more complex systems than ever before● Multi-core processing

● Harder to develop for using the standard embedded development flow

● Harder to utilise the full processing potential● Much harder to debug (and fix!)

Page 6: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 6/32

Challenges in Embedded Systems (II)

● Increasingly higher degrees of heterogeneity in terms of:● Cores● Hardware acceleration (GPU, co-processor etc)● Interconnect● Memory hierarchies

Page 7: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 7/32

Challenges in Embedded Systems (III)

● Low power● Efficient use of batteries

● “Always connected”

Page 8: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 8/32

Internet of Things (I)

Page 9: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 9/32

Internet of Things (II)

http://blogs.cisco.com/news/the-internet-of-things-infographic/

Page 10: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 10/32

Erlang Advantage (I)

● Declarative● Functional programming language, high abstraction

level, concise readable programs.● Concurrent and Parallel

● Highly scalable, transparent or explicit concurrency, lightweight processes. Takes full advantage of multicore architectures.

Page 11: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 11/32

Erlang Advantage (II)

● Robust● Simple and consistent error recovery and supervision

hierarchies.● Portable, Distributed

● Runs on a variety of platforms, network-aware runtime, supports heterogeneous networks.

Page 12: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 12/32

Erlang Advantage (III)

● External Interfaces● NIFs and ports used to interface external world to the

Erlang runtime.● Soft Real-Time

● Response time (can be) in the order of milliseconds, per-process garbage collection.

● Hot-code loading● Dynamic reconfiguration.

Page 13: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 13/32

Limitations

● No hard real-time guarantees● Underlying OS dependency

● Not “bare-metal”● Lack of unified hardware/peripheral abstraction

Page 14: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 14/32

Erlang, the Maestro

(flickr/dereckesanches)

Page 15: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 15/32

Erlang, Embedded?

● Using standard tools/runtime/modules● Cross-compiled for specific architecture● Specific features disabled

● Bare metal● Here be dragons.

Page 16: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 16/32

Current State

et al.

Page 17: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 17/32

Hardware is cheap and plentiful

Page 18: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 18/32

Special Mention: Raspberry Pi● 700 MHz ARM11● 256 MB DDR2 RAM● 10/100Mb Ethernet● 2x USB 2.0● (HDMI, Composite

Video, 3.5mm Stereo Jack, DSI, CSI-2) $35

Page 19: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 19/32

Special Mention: Raspberry Pi● The Raspberry Pi Foundation

is a UK registered charity.

● Mission statement: "...to promote the study of computer science and related topics, especially at school level, and to put the fun back into learning computing."

● Future Erlang hackers?Future Erlang hackers?

(flickr/lebeus)

Page 20: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 20/32

The ErlBuggy!

Page 21: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 21/32

The ErlBuggy!

PWM

Motor Motor

Sensor

Sensor

Sensor

MotorController

“The Brain”

Page 22: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 22/32

Controlling a motor

MotorL = motor:start({21, 22}).

MotorL ! cw.

MotorL ! ccw.

MotorL ! halt.

Page 23: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 23/32

Component API

Universal Peripheral/Component Modules

Peripheral API

Peripheral Implementation Platform Specific

Universal

Page 24: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 24/32

Universal Peripheral/Component Modules

An Example:

TMP102 Temperature Sensor

I2C Bus Driver

Linux Kernel Driver

Sensor API

I2C Bus Driver

Linux sysfs

TMP102 Temperature Sensor

I2C Bus Driver

Linux Kernel Driver

Sensor API

I2C Bus Driver

BSD sysctl

TMP102 Temperature Sensor

I2C Bus Driver

Linux Kernel Driver

Sensor API

I2C Bus Driver

mmap()'ed register voodoo

Temperature Sensor with I2C Interface

Page 25: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 25/32

Our Plans● Establish a user community, following existing

succesful models● Design a generic software framework that will

allow Erlang programs to interface with a range of embedded devices

● Develop software tools and libraries for quick and easy evaluation and adoption of embedded systems development using Erlang

Page 26: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 26/32

The Arduino Approach

HardwarePlatform

IDE with software librariesprogramming/debug tools

Community

Page 27: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 27/32

Video Series

Page 28: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 28/32

erlang-embedded.com

Page 29: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 29/32

Standing on the shoulders of giants

Ångström

Page 30: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 30/32

Future ExplorationsXilinx Zynq Extensible Processing Platform

Page 31: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 31/32

Get involved!

Page 32: Concurrent Blinkenlights and More! · PDF fileConcurrent Blinkenlights and More! Omer Kilic | ... 28/05/2012 Erlang User Conference 2012 Slide 9/32 ... Linux Kernel Driver Sensor API

28/05/2012 Erlang User Conference 2012 Slide 32/32

Thank you

● www.erlang-embedded.com● [email protected] ● @ErlangEmbedded