Experimental simulator for Mbed OS 5 applications
While we have worked hard to improve embedded development tooling in Mbed (e.g. via the Online Compiler), the development for microcontrollers is still very similar to how it was in the 90s. Compilation is slow, and flashing is even slower. When fixing a bug, you need to get the device into the exact state as before encountering the bug. This makes for a very slow feedback loop, which hinders productivity and often pulls you out of the zone.
To make this feedback loop much shorter, we're releasing an alpha version of the Mbed Simulator. The simulator allows you to run your Mbed OS 5 applications directly on your computer, so that you can quickly test and verify applications without flashing them on a real board. This is a valuable learning tool, as you quickly learn how Mbed works. It is also very useful for developing complex applications. Within Arm, we have been using the simulator for work on mbed-http, the Mbed LoRaWAN stack and uTensor.
Note: The Mbed Simulator is part of Mbed Labs. The Mbed Labs projects showcase interesting side projects developed by Mbed engineers. However, these projects are not actively supported by Arm, and may be added, removed or break at any time.
- Installation, see below.
- Configuration and compiler options
- File systems and block devices
- Pelion Device Management
How to run the hosted version
Install a recent version of node.js.
Install Mbed CLI.
Install the Emscripten SDK v1.38.21 - and make sure
emccis in your PATH.
$ npm install $ sh build-demos.sh
Then, start a web server:
$ node server.js
Open http://localhost:7829 in your browser.
The simulator comes with a CLI to run any Mbed OS 5 project under the simulator.
- Install a recent version of node.js.
- Install Mbed CLI.
- Install the Emscripten SDK v1.38.21 - and make sure
emccis in your PATH.
Then, install the simulator via:
$ npm install mbed-simulator -g
Or if you cloned the project, via:
$ npm install /path/to/simulator -g
This will create a new
mbed-simulator binary somewhere in your PATH.
Then run from an Mbed OS 5 project:
$ mbed-simulator .
The project will build and a web browser window will open for you.
To see if your program runs in the simulator, check the
Running in headless mode
You can also run the simulator in headless mode, which is great for automated testing. All output (through
printf and traces) will be routed to your terminal. To run in headless mode, add the
--launch-headless option. You might also want to limit the amount of logging the server does through
--disable-runtime-logs to keep the output clean.
After changing anything in the simulator HAL, you need to recompile the libmbed library:
$ rm mbed-simulator-hal/libmbed.bc
Rebuild your application. libmbed will automatically be generated.
out folder a number of pre-built demos are listed. To upgrade them:
macOS and Linux
$ sh build-demos.sh
viewer/img/controller_mbed.svg- created by Fritzing, licensed under Creative Commons Attribution-ShareALike 3.0 Unported.
- Thermometer by https://codepen.io/mirceageorgescu/pen/Ceylz. Licensed under MIT.
- LED icons from https://pixabay.com/en/led-icon-logo-business-light-1715226/, Licensed under CC0 Creative Commons.