- While some of the instructions from the original readme work, most of them don't anymore because of version mismatches and whatnot.
- What's extra frustrating is that even the docker image doesn't work
- I mean is anyone really surprised? That a docker image doesnt "just works out of the box"?
- Not all the demos that are online exist in the original repository nor the originally original repository.
- I need my Embedded Systems students to have an independent (of internet, arm server outages etc.) development environment.
- Has a stdin serial demo also thanks to @janjongboom
- We almost made the MQTT demo work (but socket.recv function does not timeout so the program hangs).
- Dockerfile fixed, local installation scripts for Ubuntu/Debian & Manjaro/Arch is included.
- Readme below is modified to reflect updated/advised setup methods.
- A quick introduction video (youtube) can be found here and advice on running it on a VM can be found here.
- Neither mbed OS 6 nor mbed 2 (which used to keep showing up on google search) is not even remotely compatible with 5.x. So please don't refer to those docs.
- Original mbed documentation is neatly hosted at https://os.mbed.com/docs/mbed-os/v5.15/introduction/index.html
- As much as 5.15 API is mostly compatible with 5.10, some things may not be. And it will surely be deprecated soon.
- Original documentation can be accessed from here: https://github.com/ARMmbed/mbed-os-5-docs/blob/5.10/docs/introduction/introduction.md
- If that's gone too by the time you're here, head here for last resort: https://github.com/alpsayin/mbed-os-5-docs/tree/5.10/docs/introduction/introduction.md
- Of course this isn't as navigable as the original hosted version. Let me know if you know what's the builder for this and I'll apply and host.
- Run
setup-ubuntu.bash
OR - Run
setup-manjaro.bash
OR - Run
docker build . -t mbed-simulator && docker run -dp7829:7829 -it mbed-simulator
(whatever's left of it from my modifications...)
Demo: https://mbed-simulator.alpsayin.com
Demo (dark): https://mbed-simulator-dark.alpsayin.com
(I had to take them down because they expose potential security holes in my network, I'll start hosting them again if I can find a throwaway host)
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.
More information in the introductionary blog post
- Installation, see below.
- Configuration and compiler options
- Peripherals
- File systems and block devices
- Pelion Device Management
- Debugging
- Architecture
- Install Docker
- Build the Docker image (run below command from inside repository folder):
docker build . -t mbed-simulator
- Run the Docker image:
docker run -dp7829:7829 -it mbed-simulator
- The simulator can now be accessed at:
http://localhost:7829
Note that setup scripts will download all dependencies (including Mbed OS) and will build the common libmbed
library so this'll take some time.
I highly advise to give the scripts a quick skim before running;
- They'll call sudo,
- They'll install nvm, npm and emsdk environments. While this is great for a student with a fresh VM, may be disastrous if you've a finely aged development environment (but then you should also know better than running arbitrary scripts from internet :)).
Arch Linux (Manjaro advised for students)
-
Run the setup script and follow the prompts.
$ ./setup-manjaro.bash
-
Run the simulator (this will activate some environment variables):
$ ./start_mbed_simulator.bash
Debian (Ubuntu advised for students)
-
Run the setup script and follow the prompts.
$ ./setup-ubuntu.bash
-
Run the simulator (this will activate some environment variables):
$ ./start_mbed_simulator.bash
Windows
- Use the docker image with:
- Docker Desktop for Windows (easiest)
- Docker daemon running inside WSL2 instance provided by Windows Subsystem for Linux
- Or follow the above instructions inside
- An ubuntu instance provided by Multipass by Canonical (easiest)
- WSL instance provided by Windows Subsystem for Linux (WSL) and follow the commands inside (untested)
- Or any other Virtualisation choice (e.g. Virtualbox)
MacOS
Get a real computer or use the docker image?
p.s. this is still unlikely to work properly in M1 macs. You really need to get a proper development computer, not an overglorified smartphone.
You must either port forward 7829 from your instance to your host machine, or your guest machine's 7829 must be accesible.
- If it's the former; open http://localhost:7829 in your browser.
- If it's the latter; open http://<ip.address.of.guest>:7829 in your browser
- If it's the latter; alternatively, open http://[guest-hostname].local:7829 in your browser
- Blinky runs!
The simulator comes with a CLI to run any Mbed OS 5 project under the simulator.
Running
To run 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 TARGET_SIMULATOR
macro.
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:
-
Run:
rm mbed-simulator-hal/libmbed.bc
-
Rebuild your application. libmbed will automatically be generated.
In the out
folder a number of pre-built demos are listed. To upgrade them:
npm run build-demos
No WebAssembly support found. Build with -s WASM=0 to target JavaScript instead. This error is thrown in new Microsoft Edge browser when you enable "Enhance your security on the web". You need to add an exception for your guest vm/docker etc. address. Firefox has not caused this issue so far.
The connection for this site is not secure This error is thrown when you try to access the simulator guest via its bonjour/avahi/mdns hostname. Most of the modern browsers don't like when you try to establish an unsecured HTTP connection to a hostnamed address so they try to upgrade connection. This does not occur if you use IP addresses. Sometimes they will ask if you'd like to proceed, sometimes they won't allow you to proceed at all. It's clear that disallowing plain HTTP connections will be the norm, so easiest way around is to find the ip address of the guest and use it. A trick is to ping the hostname and grab its IP by response as shown below.
PS C:\Users\alpsa> ping -4 mbedsimulator.local
Pinging mbedsimulator.local [192.168.111.6] with 32 bytes of data:
Reply from 192.168.111.6: bytes=32 time<1ms TTL=64
Reply from 192.168.111.6: bytes=32 time<1ms TTL=64
...
Pointer_stringify Issues This error is thrown when you use too high an emscripten version. According to release notes 1.38.27 version of Emscripten aborts by default when Pointer_stringify is called. I tried 1.38.26 which didn't quite compile. So I decided to use 1.38.21 as per the original docs. Further reading below:
Windows: [Error 87] The parameter is incorrect
This error is thrown on Windows systems when the path length limit is hit. Move the mbed-simulator
folder to a folder closer to root (e.g. C:\mbed-simulator
).
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.
- Some of the demo/component JS sources were taken from https://simulator.mbed.com.