Testing embedded software is challenging, especially when the target hardware is not readily available and may not be for months.
Software engineers typically need immediate and frequent access to the physical target hardware during development. This often leads to delays and resource contention, which results in inadequate testing and high development costs. This is where hardware emulation tools like QEMU (Quick Emulator) come into play to help accelerate embedded development.
Here, we explore how QEMU will help embedded software engineers emulate hardware setups and overcome typical bottlenecks of hardware dependency.
- What is QEMU?
- Simulating hardware setups with QEMU
- Challenges of working with QEMU
- The bottom line: Why QEMU matters
What is QEMU?
QEMU is open source software that allows you to emulate various hardware architectures. QEMU offers full-system emulation, allowing engineers to create a virtual replica of their embedded device’s hardware. This capability is crucial for validating application behaviour under representative conditions without requiring access to the target hardware.
QEMU is highly adaptable to many development scenarios, from emulating state-of-the-art CPU accelerations to full-scale rig simulation for software-in-the-loop (SIL/SWIL) testing. With QEMU, you can test features, find bugs, and gauge performance, all within a controlled and repeatable environment.
Simulating hardware setups with QEMU
QEMU allows each software team member to have an emulated system-under-test (SUT) for when hardware doesn’t yet exist. This lets software teams start early and hit the ground running on critical, specific tasks once hardware becomes available. That’s not to say QEMU isn’t of value following the early stages of a software project. QEMU continues to be a valuable tool beyond hardware availability for testing anywhere, instant scaling, and ease of scripting.
Additionally, with software engineers working on an emulated system, expensive and rare hardware is freed up for complex testing. Since QEMU is an emulated system, time/signal-dependent simulations can also be accelerated.
QEMU & Continuous Integration
While requiring upfront investment, automated testing — specifically continuous integration (CI) — frees up expensive engineer time. CI allows for regression testing and in-depth system analysis through variable changes, which would otherwise be difficult due to the human input required. QEMU enhances these practices by enabling interactions to be easily scripted.
When QEMU is combined with the openQA testing tool, it is possible to expand automated QEMU testing to cover the user interface (UI) with automated screen presses, for example. Implementing QEMU in CI allows teams to spot errors quickly before code is merged, freeing up hardware for complex hardware-in-the-loop (HIL) tests that are difficult to automate. This ultimately aids in avoiding costly errors. As a bonus, this approach is also language-agnostic.
The use of QEMU in CI allows parallelised test runs for multiple software versions by utilising emulated hardware on CI runners, a task that would otherwise require teams of testers. This shortens the development cycle time. In addition, due to features such as tracing and an internal GDB server (allowing debugging as if running on hardware), QEMU is significantly more straightforward to debug.
In addition, QEMU will emulate devices such as CAN buses, memory-mapped IO (MMIO), and serial-attached devices, including GPS, Trusted Platform Modules (TPMs), and USB. This capability allows for complex emulated hardware setups, including multiple displays and physical networks.
Challenges of working with QEMU
While QEMU is an essential development tool, it cannot fully replace hardware. This is because QEMU is not cycle-accurate or executed in exactly the same way as the hardware would.
While still efficient due to its Tiny Code Generator (TCG), there is still overhead for emulating or translating. QEMU’s aim is to be fast, which means trade-offs between accuracy and speed.
There may be issues with coverage of all the hardware instructions which may not be supported in QEMU. Also the driver models may not support all exceptions as these are unlikely to be useful in an emulated environment.
QEMU is an expansive project covering user and system-level emulation across 31 architectures, with AArch64 supporting 47 CPUs and 419 devices. As a result, developing complex setups can be challenging.
The bottom line: Why QEMU matters
QEMU is a powerful solution for testing embedded software, helping prioritise hardware for critical, complex testing and development.
Integrating QEMU for embedded software into your workflow will significantly accelerate early-stage development, ease system debugging, and facilitate automated testing throughout the software project. QEMU provides full system emulation, allowing thorough testing and debugging in a virtual machine for embedded systems. This flexibility ensures your system is tested in conditions close to real hardware, reducing the risks and challenges of late-stage bugs.
Ultimately, QEMU will accelerate your development process with emulation that gets close to the actual hardware. A well-configured QEMU will bring you much closer to the results and experience your software team needs.
Explore some of our recent QEMU projects:
- ‘Adding RISC-V Vector Cryptography Extension support to QEMU’
- ‘Developing a cryptographically secure bootloader for RISC-V in Rust’
- ‘Testing in a Box: Streamlining Embedded Systems Testing’
How are you using QEMU?
Send us your thoughts or comments via the form below.
Other Content
- Open Source Summit Europe (OSSEU) 2024
- Watch: Real-time Scheduling Fault Simulation
- Improving systemd’s integration testing infrastructure (part 2)
- Meet the Team: Laurence Urhegyi
- A new way to develop on Linux - Part II
- Shaping the future of GNOME: GUADEC 2024
- Developing a cryptographically secure bootloader for RISC-V in Rust
- Meet the Team: Philip Martin
- Improving systemd’s integration testing infrastructure (part 1)
- A new way to develop on Linux
- RISC-V Summit Europe 2024
- Safety Frontier: A Retrospective on ELISA
- Codethink sponsors Outreachy
- The Linux kernel is a CNA - so what?
- GNOME OS + systemd-sysupdate
- Codethink has achieved ISO 9001:2015 accreditation
- Outreachy internship: Improving end-to-end testing for GNOME
- Lessons learnt from building a distributed system in Rust
- FOSDEM 2024
- QAnvas and QAD: Streamlining UI Testing for Embedded Systems
- Outreachy: Supporting the open source community through mentorship programmes
- Using Git LFS and fast-import together
- Testing in a Box: Streamlining Embedded Systems Testing
- SDV Europe: What Codethink has planned
- How do Hardware Security Modules impact the automotive sector? The final blog in a three part discussion
- How do Hardware Security Modules impact the automotive sector? Part two of a three part discussion
- How do Hardware Security Modules impact the automotive sector? Part one of a three part discussion
- Automated Kernel Testing on RISC-V Hardware
- Automated end-to-end testing for Android Automotive on Hardware
- GUADEC 2023
- Embedded Open Source Summit 2023
- RISC-V: Exploring a Bug in Stack Unwinding
- Adding RISC-V Vector Cryptography Extension support to QEMU
- Introducing Our New Open-Source Tool: Quality Assurance Daemon
- Achieving Long-Term Maintainability with Open Source
- FOSDEM 2023
- Think before you Pip
- BuildStream 2.0 is here, just in time for the holidays!
- A Valuable & Comprehensive Firmware Code Review by Codethink
- GNOME OS & Atomic Upgrades on the PinePhone
- Flathub-Codethink Collaboration
- Codethink proudly sponsors GUADEC 2022
- Tracking Down an Obscure Reproducibility Bug in glibc
- Web app test automation with `cdt`
- FOSDEM Testing and Automation talk
- Protecting your project from dependency access problems
- Porting GNOME OS to Microchip's PolarFire Icicle Kit
- YAML Schemas: Validating Data without Writing Code
- Full archive