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.