ESP32: QEMU Emulation within a Docker Container

Michael Howard,R. Bruce Irvin
2023-03-26
Abstract:The ESP32 is a popular microcontroller from Espressif that can be used in many embedded applications. Robotic joints, smart car chargers, beer vat agitators and automated bread mixers are a few examples where this system-on-a-chip excels. It is cheap to buy and has a number of vendors providing low-cost development board kits that come with the microcontroller and many external connection points with peripherals. There is a large software ecosystem for the ESP32. Espressif maintains an SDK containing many C-language sample projects providing a starting point for a huge variety of software services and I/O needs. Third party projects provide additional sample code as well as support for other programming languages. For example, MicroPython is a mature project with sample code and officially supported by Espressif. The SDK provides tools to not just build an application but also merge a flash image, flash to the microcontroller and monitor the output. Is it possible to build the ESP32 load and emulate on another host OS? This paper explores the QEMU emulator and its ability to emulate the ethernet interface for the guest OS. Additionally, we look into the concept of containerizing the entire emulator and ESP32 load package such that a microcontroller flash image can successfully run with a one-step deployment of a Docker container.
Operating Systems
What problem does this paper attempt to address?
The main goal of this paper is to explore how to build and simulate an ESP32 load on another host operating system and evaluate the feasibility of containerizing this process. Specifically, the researchers aim to achieve the following objectives: 1. Build an ESP32 target load that includes the operating system, device drivers, and a simple HTTP application (such as a web server). 2. Execute this load on native hardware to ensure its functionality is correct. 3. Customize the build of QEMU to support ESP32 for macOS and modify it as needed to run the target load. 4. Develop a Docker container around the QEMU toolchain to provide an isolated environment for all dependencies. 5. Generate some basic HTTP traffic between the application and the external world. 6. If it works correctly, trace the call stack as much as possible to determine how the simulation is proceeding. 7. Document the experiments and system architecture in detail. The motivation for the paper is to easily simulate the ESP32, as this microcontroller is used as an edge device in the author's energy auction research. Therefore, being able to easily deploy and destroy multiple containers containing the ESP32 load (with the simulator) will aid in load testing and automated functional testing. Additionally, a deep understanding of the QEMU architecture and API can assist in the development and debugging of edge device applications. To achieve these goals, the researchers used the ESP32 microcontroller, the software development kit provided by Espressif (ESP-IDF), the QEMU simulator, and Docker containers. With these tools and technologies, the researchers successfully built, simulated, and containerized the ESP32 application, including the ability to handle network traffic.