Effective embedded software development through simulation: A case study

Florian Mehrkens

13/06/2024

No more errors when using flash memory! Is a dream within reach with a little effort? Yes, at least you can make your developer's life much easier by preventing errors from the outset or simplifying the system in which you're trying to find a bug. It's not a new idea, but how can it be implemented? In such situations, the simulation or emulation of individual hardware components can be a real lifesaver.

In November 2022, we wrote in the blog post, “Simulation? Why, I have hardware.”, has already dealt in detail with the advantages of simulations in embedded software development and, in addition to numerous application cases, has also mentioned the emulation of flash or EEPROM memories.

The following blog post uses a concrete example to show how such emulation of flash memory hardware could help to find errors faster and develop software in a more targeted and better tested manner.
 

Houston, we have a problem

This, or perhaps slightly less dramatic ones, pop into your head when a system error pops up out of the proverbial nowhere, and at first glance, everything seems odd. This was also the case in our example. It involved an embedded system with external flash memory, which is regularly written to and read from. It's only annoying when the data read doesn't always match the previously written data, but rather discrepancies occur. What's clear is that the error lies in the details; in most cases, everything works as it should, and it only involves a few bytes among the hundreds of thousands on the chip.
 

From theory to practice: approach

In order to get to grips with such or similar errors when dealing with flash memories, certain sections of the logic can be abstracted and recreated through emulation.

The first step is to isolate and reproduce the error. For example, the part of the code responsible for writing and reading the flash memory, i.e., for communication, can be extracted from the project's source code and rebuilt so that it can run in a conventional development environment on a PC. Depending on the complexity, this will require a considerable amount of additional code, which, for example, provides the necessary data structures, classes, or the data to be written.

The core idea, however, is to isolate the problem, so in the second step, the methods responsible for hardware access to the flash are replaced with simple file access. The contents of the flash are thus mapped to a file. Instead of actually accessing the hardware, the desired memory accesses are now simulated.

If you were looking for a memory problem, it's now clear, by process of elimination, whether the error originated in the hardware or the software. Once this has been determined, the error can be narrowed down and found through debugging or further isolation and simplification. Thanks to emulation, significantly more robust software can now be developed for troubleshooting, as specific hardware errors can be easily simulated, and (unit) testing and debugging can be made more comfortable. These and other advantages resulting from preventative simulation can therefore also be interesting for subsequent or new developments.
 

Success through simulation: Benefits at a glance

The advantages of using simulations during development rather than only when an error occurs include:

  • Simplified (unit) testing and debugging
  • Verification of memory layouts (behavior at block boundaries)
  • Checking long-term behavior (e.g. memory overflow of ring buffer implementations)
  • Easy simulation of hardware errors such as flipping bits, defective memory blocks, etc.
  • Better portability through layering, abstraction and encapsulation

 

Conclusion

Simulating hardware components is an extremely valuable practice in embedded software development. Of course, not every hardware component is as easy to simulate as in our example, simply replicating a flash memory. However, this approach greatly simplifies developers' work, and clever abstraction and simulation allow projects to progress faster and identify potential problems early on.

In any case, it's worth considering the possibilities of simulation right at the start of the project and developing creative solutions. We're happy to help, so don't hesitate to contact us with any questions.


Written by Florian Mehrkens


More articles

  • 26/11/2025
  • General, Hardware, Standards, Quality, Testing

Why EMC testing is vital in medical technology: Imagine a patient is lying in the hospital during critical monitoring. Suddenly, a visitor's smartphone rings – and the monitoring device... ...

Read more
  • 20/11/2025
  • General, Hardware, Quality, Technology, Testing

Have you ever considered sourcing inexpensive components from China? The temptation is strong, we know that. And we've already gained some experience, from which I... ...

Read more
  • 13/11/2025
  • General, manufacturing, production, quality, company

In our globalized world, relocating medical technology manufacturing to the Far East seems attractive at first glance: large production capacities and favorable prices. For many years, offshoring has also been ...

Read more
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.