Virtualising Hardware

I have a client that would like to build virtual versions of their integrated hardware. Ie its C code uploaded to a microcontroller of various types. I think one is atmega-like and the other is a via cortex m3 or so. Has anyone ever looked into building this firmware in a way it can be run on a desktop so you can run tests against it?

If it were say python, I’d spin up a linux vm and install some things and bada bing bada boom. But firmware? tricky. The end goal is to have a sort of contained box that we can communicate with over a virtual serial port (so even if it can be turned into some kind of binary, that binary would probably get chucked on its own vm and they’d all talk together via virtual serial ports)

Yes I’ve done a bit of this. The thing to remember is its just another c
compiler target… so u can use makefile voodoo and #ifdef s to compile the
same code for dire rent platforms. Ardupilot does this, and calls it a
“sitl” build ( software in the loop ).

I have also looked into doing this type of thing.

There are many gotcha’s in this approach of software testing for embedded
devices. Some that come to mind are…

  1. Silicon Bugs, Software is emulating what the spec says the chip should
    do and not what it does due to errors in silicon.
  2. Hardware Bugs, This could be problems with design of the bits that go
    around the chip, though this usually found and fixed as the revisions go on.

Ahhh thats super interesting. A great place to start googling at least.

Yeah, we have real hardware to test on for that stuff. This is mainly around ‘if the communicating peripherals are on magical perfect hardware, does everyone talk nicely’ ie, its kind of half about testing the code that it works ideally, and half that it integrates with the rest of the (crazy convoluted) software stack.

here’s the “newest” doco regarding SITL:
http://dev.ardupilot.com/wiki/setting-up-sitl-on-linux/

and here’s an older, but more comprehensive page about it:
http://code.google.com/p/ardupilot-mega/wiki/SITL

this link is old, but may also help…
http://wiki.ardupilot-mega.googlecode.com/git-history/5ae3d7e766bbb668c28f93a031c28f13284ef649/SITL.wiki

and here’s a link to the core part/s of the “desktop” build for
ArduPlane/Copter… ( “Desktop build” is another name for SITL)

( the reason I linked to the old 2.8.1 branch, is because they added a
Hardware Abstraction Layer (HAL) in later versions that is both way more
awesome, and totally useless to your needs here at this time, as its very
specific to what they do ) :slight_smile:

Buzz.