Hardware In The Loop

What does it involve?

In electronics, hardware-in-the-loop (HIL) is a technique used for the development and validation of embedded systems. Instead of limiting validations to simulation environments or unit tests, HIL allows verifying the behavior of applications running directly on the physical system (the target).

Increasing system complexity in embedded electronics makes simulation-only validation insufficient. Autonomous systems, automotive ECUs, aerospace control units, and industrial automation require real hardware feedback. Also, HIL allows safe testing of scenarios that might be risky to replicate physically.

As embedded systems become increasingly complex and safety-critical, relying only on simulations is insufficient. HIL testing enables developers to validate real-time responses under conditions that are difficult or unsafe to reproduce in a purely simulated environment.

This way, every software change can be validated under real operating conditions, ensuring that the interaction between hardware, drivers, and the embedded operating system behaves as expected.

Workflow in one of our projects

- Repository update
Several developers work in parallel on the same project. Each time a developer pushes to different branches, or even to the same branch, the pipeline can be triggered.

- Pipeline execution on the host PC (runner)
The host PC running the GitLab runner is connected to the same network as the target. This runner executes all pipeline tasks automatically or manually, depending on its configuration.

Pipeline stages
The pipeline is divided into several phases:

  • Setup: Preparation of the build environment and required dependencies.

  • Build: Generation of a new Linux image using Yocto or another tool.

  • Deploy: Update of the TFTP server (kernel and device tree) and the NFS server (rootfs).

  • Reboot: Restart of the target board so it boots from the new kernel/rootfs. Booting is handled by U-Boot, which retrieves the files directly from the TFTP/NFS servers configured on the host.

  • Run integration tests: Automated execution of integration tests written in pytest. These tests run against the real hardware and verify both software functionality and its interaction with the embedded system.

- Results reporting
The pytest results are collected and sent back to the GitLab pipeline. GitLab generates reports visible through the web interface, allowing developers to quickly check whether the new version passed or failed hardware validations.

Test coverage measures how much of the codebase is executed when the test suite runs. High coverage provides confidence that most functionality has been tested and reduces the risk of undetected defects.

Pytest, together with specific plugins, can automatically calculate coverage during test execution. This report provides a visual and interactive overview of coverage at multiple levels:

  • File level coverage: Each source file is annotated with the percentage of lines executed by the tests.

  • Line by line detail: Lines of code that were executed are highlighted in green, while untested lines stand out. This allows developers to quickly identify gaps in testing.

In summary, the benefits of HIL are:

  • Validation: Tests are executed on the same hardware that will be used in production.

  • Full automation: Depending on the configuration, no manual intervention may be required to install images or run tests. Everything is controlled by the GitLab pipeline.

  • Early error detection: Running tests enables the early detection of issues when they occur.

  • Reproducibility: All developers go through the same test sequence, on the same hardware, eliminating environment variability.

  • Reports: Test reports remain available for internal use or as supporting documentation to provide to the customer.

  • Traceability: Results are automatically associated with each commit, simplifying tracking.

With HIL, organizations achieve faster development cycles, higher software reliability, and more confidence in deploying safety-critical systems. As the complexity of embedded electronics continues to grow, HIL is becoming an indispensable tool in modern embedded engineering pipelines.

For further information, please contact us: info@emtech.com.ar