Back to blog

OTA firmware updates using Mender on ESP32

Working with numerous IoT devices may be difficult in a case when you need to change something in your software or fix a bug. Especially in a case when your devices are spread around your place, or even around the world and you don’t have an easy way to physically access them. The solution to this problem is wireless software updating called OTA (Over-The-Air). The main principle of OTA on microcontrollers is to update the new firmware on a web server, and all connected devices should download it, save it on a secondary partition, and reboot from the new partition with the new software. 

There are several services to help you to manage your over-the-air updates. One of them is Mender which we have lately tested on an ESP32 microcontroller. Mender is an open-source tool with a big community of users. It integrates with any Linux-based operating system, running the mender client. Mender features application and system updates, state scripts to control the release and installation process, partial updates, configuring the connected devices, and troubleshooting. Apart from that, some of the more advanced features allow for mutual TLS authentication for more secure updates, an automatic retry of deployments in case something fails, logs, real-time monitoring, and a remote terminal. 


You may have noticed, that we tested Mender on a microcontroller, that is not capable to run any Linux distribution. We achieved that thanks to the mender-mcu-client library, created by Joel Guittet. The library is a light version of mender-client written in C for devices running on FreeRTOS or Zephyr. After creating a mender account, you get the Mender-server-tenant-token, which allows your device to connect with your mender account. The connection is secured by authentication keys generated by the device. You also have to accept the device that tries to connect on the mender interface. Once it is accepted, and mender-client is running, you can create a new deployment. For that, you have to build your firmware, create a mender artifact using the mender-artifact tool and upload it to the mender server. On the Mender web-ui, all devices are shown with their current software version, online status, and last check-in time. You can group your devices and create new deployments for groups. You can also select when the update should start, how many times it should attempt to apply the update, or how many devices at a time. The web-ui also allows monitoring of the update status of each device. In case of a failure, the device will perform a rollback to the last, working version. 

To sum up, Mender is a great tool to manage OTA on your devices. It provides an easy-to-use interface, security features like encryption and firmware rollback, and a server to host your firmware. In the trial plan of Mender, you can add up to 10 devices for 12 months and since the code is open source, you can host it yourself on any Linux machine. 

Recent entries

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.