Minimal Downtime: In-flight Drone Firmware Upgrade in Erlang

Erlang is a programming language written with two principles in mind: “Errors will ALWAYS occur” and “The system must NEVER go down”.

These two add up to the philosophy of keeping the processes in larger structures isolated, the structures themselves easy to recover and general rules of action simple. One of the features that enables developers create systems with minimal downtime is the hot code loading/swapping facilities available in the runtime system.

Quoting the “Compilation and Code Loading” section of the Erlang Documentation:

Erlang supports change of code in a running system. Code replacement is done on module level.

The code of a module can exist in two variants in a system: current and old. When a module is loaded into the system for the first time, the code becomes ‘current’. If then a new instance of the module is loaded, the code of the previous instance becomes ‘old’ and the new instance becomes ‘current’. Both old and current code is valid, and may be evaluated concurrently.

If a third instance of the module is loaded, the code server will remove (purge) the old code and any processes lingering in it will be terminated. Then the third instance becomes ‘current’ and the previously current code becomes ‘old’.

Feuerlabs, one of our partners in the embedded domain, recently published a YouTube video demonstrating this language feature alongside their Exosense framework, upgrading the flight control system of an AR Drone while in the air. You can find the video embedded below or by clicking this link.

Interested in learning more about Erlang? Join part two of our series of “Learning Erlang – Easier than you think” webinar by Robert Virding (one of the co-creators of the Erlang programming language) and Francesco Cesarini (O’Reilly author and Technical Director at Erlang Solutions) on Nov 13 (Wednesday) at 6:00 PM GMT! More information available at this link.

Erlang plays pool!

We thought you might be interested in meeting the newest member of our London office who likes spending time on pool tables…

You can find the code driving this buggy, along with instructions to get up and running at Ivan’s ebuggy repository. Leave a comment on this post or drop us an email if you’d like more information.

fpdays_logo_redInterested in learning more about Erlang/ALE on the Raspberry Pi? We will be running a hands-on workshop at FP Days 2013 on 25th October in Cambridge. Places are limited so sign up now if you’re up for some Erlang tinkering on the Pi. Robert Virding, co-inventor of the Erlang language and robot aficionado, will also be there giving a keynote.

New Erlang package for small devices: erlang-mini

We’re pleased to announce the availability of erlang-mini, a minimal version of the Erlang packages that we distribute on our downloads page, designed specifically with embedded devices in mind (no GUI related dependencies etc, weighing in under 20 megabytes).

Installing erlang-mini on a freshly imaged Raspberry Pi or a Parallella board is a very simple processes. Using your favourite text editor, add the following line to your /etc/apt/sources.list

For Raspberry Pi:

deb wheezy contrib

For Parallella:

deb oneiric contrib

Import the Erlang Solutions public key:


sudo apt-key add erlang_solutions.asc && rm erlang_solutions.asc

Update the package database:

sudo apt-get update

Install erlang-mini:

sudo apt-get install erlang-mini

Finally, test your installation by running the Erlang shell using erl.

Happy hacking and do get in touch if you run into any problems!

Resurrection, Part I

Blog negligence is a huge problem of our times and we certainly have been doing a terrible job of keeping you updated with our progress, sorry about that. I can assure you that the Erlang Embedded project is alive and kicking, despite the lack of activity on this blog and our Twitter stream. We even have cool stickers now!

Stickers! In an effort to fill you in on almost a year of progress, we will be publishing a two part post covering the areas we have been working on in the past couple of months. Let’s get started…

Talks and Tutorials

From Istanbul to San Francisco, we have presented our explorations in using Erlang in the Embedded domain at numerous gatherings. While the presentations varied slightly at each delivery, the two main points we focused on were:

  • The suitability of the Actor Model in today’s heterogeneous and multi-core embedded  systems.
  • Erlang’s role in orchestrating concurrent, distributed, connected systems (or: The Internet of Things, for the cool kids)

Here’s a video of my presentation from Erlang Factory SF Bay Area 2013:

(I was fighting a wicked combination of cold and allergies at the time so please pardon my voice/general drowsiness)

Alongside these talks, we have also been running practical workshops. The first of these, “Hands on hardware fun with the Raspberry Pi using Erlang”, made its debut at QCon London and with slight modifications we ran it again at Erlang Factory SF Bay Area. The reception was good and many LEDs were blinked so all in all it was a good start.

The Erlang Embedded Demo Board

A stack of Demo BoardsIn order to make our workshops a little more interesting and to actually simulate real-world embedded applications, we have developed a simple demo board for the Raspberry Pi, aptly named: erlhwdemo. It is an open-source hardware design and more information about it can be found here. We might organize a mini-hackathon of sorts introducing our framework (hints below) using these demo boards so get in touch if you’re interested.

Introducing Erlang/ALE

ALE (Actor Library for Embedded) is the embedded framework that we have been working on for a while. We will be writing a lengthy post about this soon but for now, click here for a sneak peek.

Quoting the Erlang Priest:

The actor model is nice to work with for embedded problems and Erlang is great for implementing actors, so it is a natural fit.

We have hidden a number of (nasty) things in a C driver and some Erlang modules to make it easier for the application engineer to solve problems. Similar to how the OTP library makes it easier to write rock solid Erlang programs.

Erlang is – by design – pretty good at interfacing with low level things. The C libraries for gluing C code together with Erlang are really good, so it is a viable way to harness the power of more low-level things.

We will be testing an alpha version of ALE at the tutorial session we are running as part of the Erlang User Conference 2013 in a couple of days and will be pushing it to a public repo soon after we recover from the excitement of EUC.

That’s it for part I, stay tuned for part II where we will talk about some of the architectural explorations we have been doing and other miscellaneous bits. Until then, here’s a photo of Joe Armstrong and Robert Virding hacking a cupcake at the soldering session we held as part of the Erlang Factory SF Bay Area :)

Cupcake hackery!

London Erlang User Group Meeting, 18 September 2012

Date/Time: Tuesday, September 18, 2012 – 18:30

Location: Room TBC, New Loom House,
101 Back Church Lane E1 1LU, London

The next London Erlang User Group Meeting is taking place in London, 18 September 2012.

Interested in Rasbperry Pi? Among speakers we have Omer Kilic, Embedded Systems Engineer at Erlang Solutions, giving his talk on: “The Actor Model applied to the Raspberry Pi and the Embedded Domain”. He will demonstrate how, due to creating a layered architecture for hardware modules and partitioning up complex systems in smaller units, testing becomes much easier, runtime errors are contained, and the architecture becomes maintainable.

If you are fond of Erlang or feel like learning, exchanging views and sharing your ideas, and experience with other folks from functional programming world, then join us in London. Free to attend but registration needed!

For more information and registration, please visit the event page.

esl-erlang package for Raspberry Pi

Last week we released the first version of our esl-erlang package, compiled and tested on the current recommended distro for the Raspberry Pi: Raspbian.

You can find details about this at our downloads page.

We will be releasing more packages for other commonly used embedded distros in the future. Please get in touch if there is a particular distro/architecture combination you would like to see packages for.