Mbed OS Simulator

A deployment journey

Stavros Kalapothas
4 min readMar 10, 2020

Mbed OS Simulator is an interesting open source project created by an ex-ARM developer (Jan Jongboom) that facilitates embedded development specifically for the Mbed Platform directly in your browser. It incorporates cool web technologies (like web-assembly) and can even work as a LoRaWAN gateway to send sensor data to The Things Network. And because of all these stacked features it is why I always wanted to try it out.

There’s already a Demo of the simulator available online where you can test some basic examples but, you can’t upload any custom code. My initial plan was to deploy it on a vps(cloud) and test some C++ code. Surprisingly enough, I found an open ‘time slot’ and immediately got into work!

So, I started by following the installation guidelines available on the website:

https://os.mbed.com/blog/entry/introducing-mbed-simulator/

starting with the prerequisites:

git(2) and nodejs(5) was already available on my dev environment and with the parts missing, I had no issue installing them. Next step was to clone the project’s code directly from the git repo:

git clone https://github.com/janjongboom/mbed-simulator

and run the server:

node server.js

mbed_os_simulator_console

and boom server is up and running:

mbed_os_simulator_first_run

While I’m about to feel the joy of having my first custom code build… I check in the console:

libmbed_build_failure

ok a library failed to build… nothing new here, I am used to this kind of stuff (I say to myself) but, I could never imagine that this would be a start of a debug marathon that would eventually last ~3h. Tried to rebuild from scratch, reinstall the toolchain, check prereqs, etc but, libmbed was still failing. Digging for more info in forums, soon revealed that I was not the only one experiencing the issue:

https://os.mbed.com/questions/82015/Offline-mbed-simulator-not-working/

continued debugging efforts, I noticed that the issue is related to the emsdk version as it was tested working up to 1.38.28 but, it seemed that were no older releases of emsdk available. A new installation procedure provided that only the latest upstream version and up to the last 20 older were available so, from the latest 1.39.8 version, there was no way to find the older but reported working 1.38.28 version:

emsdk_versions_listed

I gave the oldest available (1.38.33) a try, no luck though, there were still problems with the build… I was starting to be frustrated especially when I read that even the Mbed OS Simulator developer (Jan) was wondering:

“Question though: why can’t emcc 1.38.28 be installed anymore?”

luckily, the “nice” developers of emsdk were good enough to keep an archived list of the older versions, with a bit different names and available to install.

emsdk_list_old_versions

The ‘tip’ was well hidden in the help message (see above). I know, RTFM! Finally, I could find the working version and install it:

emsdk_installed

Mbed OS Simulator was up and running and I was able to compile custom code!

Now, I could try some serious game development :)

mbed_os_simulator_running_code

game play:

mbed_os_game

It took me 3h to finish that game!

mbed_os_game

Unfortunately, the project’s code is no longer developed. Nevertheless, I commented about the workaround on github to help other users facing the same issue in the future.

Last but not least, it’s worth mentioning that you can also run uTensor and test Machine Learning inference on Mbed.

uTensor_code_on_mbed_os_simulator

If you have reached to this section, then I most probably have written something interesting for you (I hope) :)

Happy hacking!

--

--