MBed simulator/sandbox for RTOS features

TL;DR: We need an MBed simulator of RTOS features that can run on the x86 platform on a desktop operating system. We are asking whether there are any existing solutions and if there’s an interest in an open-source version should we write one ourselves.


On MIT Rocket Team, we’ve just started using MBed OS and we love it! Especially, we like how unlike most other embedded solutions, it is using idiomatic C++ features (operator overloading etc.) and great separation of concerns, which make the code more clear and readable.

One of our main requirements is extensive testing: from unit-testing to testing on hardware. Hence, we need to be able to compile the code in the following configurations:

  1. Unit testing: compiled for a desktop OS. Each unit test is its own target, and it consists of the cpp file under test, as well as stubs. This was partially inspired by this guide, and partially emerged as a replacement for our more complicated dependency injection patterns when previously compiling all unit tests into the same target and only using GoogleMocks (and not stubs)
  2. Hardware-out-of-the-Loop (HOOTL) testing: compiled for a desktop OS. Here, we would compile most of our code (excluding the HAL and device drivers) into a single target, and run it in a simulated environment. This is the target that will require an implementation of RTOS features for desktop environments, which is what this post is about.
  3. Hardware-in-the-Loop (HITL) driver testing: compiled for ARM targets. We will create a target for each device driver so that we can test the driver on the target hardware.
  4. Production firmware target: compiled for ARM targets. This is the actual firmware for our flight computer that we are developing.

We are using the CMake build system, which lets us use different compilers (one for 1 and 2, and one for 3 and 4). For 3 and 4, we are using mbed-cmake - (check out this forum post), which lets us create separate hardware targets for our different HITL tests and the main target.

RTOS Simulator

Number 2 is where we are currently stuck. We want to be able to simulate running on the actual targets, using all RTOS features: Threads, Queues, Mutexes, etc., but without a particular need for any hardware interaction features. That’s because we will abstract out the whole Hardware Abstraction Layer, and replace it with a simulated implementation, removing the dependency on hardware functions, and simplifying feeding fake data into our code.

The closest to what we need would be the MBed simulator, although it seems to be the opposite of what we need - with support for simulated hardware but no RTOS features. We would be open to running our code on a more fully-fledged simulation, and simply not use the hardware features, but that might make it harder for us to compile in the stubbed HAL that we can feed with fake data.

If such an implementation of MBed RTOS components does not exist yet, we will create one for ourselves. Then the question becomes whether there is interest (either from MBed staff, or the open-source community) to help maintain that. If we limit ourselves to the RTOS features, that shouldn’t be too big of an implementation.

Please, let me know your thoughts!


Hi Luka,

Currently in mbed OS we provide support for Fast Models FVPs, which is an Arm architecture simulator on x86 created by Arm. mbed OS documentations .

However, the FastModels is a proprietary software might not suitable for your needs. one of the option is use QEMU. in QEMU there is an arm platform named mps2-an511 which I believe is the identical to FVP_MPS2_M3 of fastmodel.
personally I haven’t try that QEMU platfrom. but I think if you build the images for FVP_MPS2_M3 and run it with QEMU MPS2-AN511, you got fairly good chance it just works.

If you think the QEMU is good for your needs and porting it over, you are more than welcome to upstream to mbed OS as this is an open source project
BTW, we have some initiatives related to cmake, you can find it in here

1 Like

@lgovedic big interest on our end here! we’ve started using mbed-cmake with great success, can’t wait to see what comes out of this new project.

Good news: as a joint effort between USCRPL and MIT Rocket team, we created mbed-benchtest, which is supposed to be a desktop simulator of MBed. A part of it is also RTXOff, which is an implementation of RTX (the CMSIS API implementation MBedOS’s RTOS uses) for x86 using pthreads. Check it out here: https://github.com/USCRPL/mbed-benchtest

1 Like

We’ve compiled a small boilerplate project for a quick start with mbed-cmake and mbed-benchtest (it’s very easy to also just use the Mbed’s new own CMake build system) - you can find it here: https://github.com/ProExpertProg/mbed-boilerplate