Rapid Firmware Development with the Barracuda App Server

In this article, we show how the Barracuda App Server can be used to rapidly and interactively develop control logic in an embedded FreeRTOS system without having to compile or upload new firmware during the development process.

Without using C/C++, we will show how to interactively create IoT firmware that turns an LED on and sends an SMS to your phone via an online IoT service when a button is pressed.

The high level Lua language included in the Barracuda App Server is really well suited for running on embedded systems, including microcontrollers. You may have used other high level languages such as Python, and you will find Lua very similar to Python. In general, high level languages, including JavaScript, have much in common. We like to refer to Lua as a high level language, and not a scripting language, since the code is compiled into machine code. However, the machine code is run on a Lua virtual machine and not natively on the microcontroller. In general, you will find Lua being fast when it is used for what it is good at.

The real benefit with Lua comes when mixing real time modules implemented in C code with control logic designed in Lua. The dynamic nature of Lua enables the developers to interactively test control code in an embedded device without having to build and upload new firmware.

The flexibility of Lua together with its ability to significantly speed up the development time can greatly benefit any company seeking to optimize the development flow.

In the following video tutorial, we will look into how Lua can significantly speed up the interactive development time of an IoT enabled headless device. A headless device simply means it has no graphical user interface, neither onboard or remotely via web. However, we will use a web based IDE and the Barracuda App Server running on the microcontroller during the interactive development process to speed up the development time. When the development is complete, the web based IDE will be removed and the final IoT application implemented in Lua will be embedded as a ZIP file inside the firmware image.

From Interactive Development to Released Product

The following video shows the complete development process from rapid interactive development to creating the final firmware release. The video starts by providing an introduction to the available tools and documentation.

We use an ESP32 in the video tutorial below, but Lua can run on most embedded systems. You can follow along the video tutorial with your own ESP32 if you install the Barracuda App Server for ESP32.


ESP32 Lua boot

Download video example code.

Why Lua and not Python?

Python may be the king of the desktop, but Lua rocks in embedded systems. Python's main focus is to be a generic and easy to use command line scripting language, while Lua is designed to be a C Library with its main focus on being easy to integrate into a larger program. Lua is found in many games such as World of Warcraft. Lua has traditionally been selected when speed and size matters. Developers generally find Lua to be much faster and less resource hungry than Python. A developer that knows Python will find it easy to learn Lua since both languages are similar.

Why Use Lua in Embedded Systems?

The C/C++ programming languages dominate embedded systems programming, but developers often run into issues such as buffer overflows, memory leaks, and other memory corruption errors. With Lua you avoid these problems, particularly in larger projects where many computer programmers with varying skills are involved.

Lua abstracts out the details for the underlying microcontroller hardware. Instead of worrying about the bits and the bytes, a developer simply accesses methods of a peripheral object to control the hardware. Hardware control is done via a so called Lua binding. The abstraction of the hardware layer allows developers to focus on the application specifics rather than on the workings of the low-lying hardware.

Learn Lua in 15 Minutes:

Posted in Whitepapers