Skip to content

Development & delivery

Virtual ECUs and software-in-the-loop

Running vehicle software without vehicle hardware — what a virtual ECU actually is, the four levels of fidelity, and why this is the change that makes everything else in an SDV possible.

Intermediate8 minVirtual ECU · Testing · Shift left

Of everything in this section, this is the topic with the largest practical effect on your working day. Not the most glamorous — the most consequential.

The bottleneck it removes#

What a virtual ECU actually is#

A is the ECU's software running on a development machine instead of its target hardware, with the vehicle around it simulated.

The word covers four quite different things, and confusion between them causes real arguments. Be specific about which one you mean.

LevelWhat is realWhat is simulatedSpeedGood for
1 — ApplicationYour application logic, compiled for the hostEverything below itInstantLogic, algorithms, unit tests
2 — PlatformApplication plus the real middleware stackHardware, bus, sensorsSecondsIntegration, API behaviour, most day-to-day work
3 — InstructionThe actual target binary, on an emulated CPUThe chip and peripheralsSlowCompiler and toolchain issues, memory layout
4 — Cycle-accurateTarget binary with real timingEverything, preciselyVery slowTiming analysis, worst-case execution

Gotcha

When someone says "we have virtual ECUs", ask which level. A level-1 vECU proves your algorithm is right. It proves nothing about whether your SOME/IP client handles a service going away mid-request. Teams have shipped bugs straight past a vECU suite that never exercised the layer containing them.

Software-in-the-loop, concretely#

SIL is one stage in a progression, and it is worth seeing where it sits before looking at how it is built.

Push testing left — each step right costs more and there is less of itMILmodel in the loopsecondsSILsoftware in the loopminutes · no hardwareHILhardware in the loophours · real ECUVehiclethe real thingdays · scarcecheap · fast · unlimitedexpensive · slow · queueda defect found in SIL costs minutesthe same defect found in a vehicle costs a test slot, a driver and a week
The testing progression, from model to real vehicleEach step to the right is more faithful, more expensive and scarcer. SIL is the rightmost stage that still runs on a laptop, which is why so much value concentrates there.

SIL means the software under test runs against a simulated environment rather than physical hardware. For a cockpit team, a working setup looks like this:

┌─── your laptop ──────────────────────────────────────────────┐
│                                                              │
│  ┌────────────────┐   ┌────────────────┐  ┌───────────────┐  │
│  │ Android        │   │ Cluster        │  │ Test scripts  │  │
│  │ emulator (AAOS)│   │ renderer       │  │ / pytest      │  │
│  └───────┬────────┘   └───────┬────────┘  └───────┬───────┘  │
│          │ VHAL               │ subscribe          │ set     │
│          └─────────┬──────────┴────────────────────┘         │
│                    ▼                                         │
│          ┌───────────────────────┐                           │
│          │  data broker (VSS)    │                           │
│          └───────────┬───────────┘                           │
│                      │                                       │
│          ┌───────────┴───────────┐                           │
│          │  vehicle simulation   │  ← drive cycles, faults,   │
│          │  or recorded traces   │    battery models          │
│          └───────────────────────┘                           │
└──────────────────────────────────────────────────────────────┘

Where virtual stops being enough#

Being clear-eyed about this protects you from the failure mode where a team trusts simulation past its limits.

Building this on an Android programme#

Practical steps, roughly in order of value:

  1. Get a broker into the loop. Point the VHAL at a data broker behind a build flag, so the same APK runs against a vehicle or a simulator. This is the highest-value change and often the smallest.
  2. Model your properties in VSS. Even if the vehicle does not speak VSS, agreeing a signal vocabulary makes traces portable and tests readable.
  3. Record real drives. A library of captured traces — cold start, motorway, low battery, charging, fault injection — is worth more than any synthetic generator.
  4. Make scenarios files, not procedures. A YAML scenario in the repository can run in CI. A page of manual steps in a wiki cannot.
  5. Run it on every commit. A vECU suite that runs nightly catches things. One that runs per commit changes behaviour, because the feedback arrives while the author still has the context.

Gotcha

The trap is building an elaborate vehicle simulation nobody trusts. Fidelity is earned by comparing against recorded reality, repeatedly.

Start with replayed real traces, which are trustworthy by construction, and add synthetic models only where you have a reason and a way to validate them.

Next#

What to do with all that automated testing — continuous integration for vehicles.

References & further reading

Code links target the main branch on cs.android.com. AOSP moves — if a path 404s, search the symbol instead.