• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created about 7 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimental simulator for Mbed OS 5 applications

New repository

I have left Arm (and started Edge Impulse!) and Arm has taken over development of the simulator. See ArmMbed/mbed-simulator for more information.

Experimental simulator for Mbed OS 5 applications

Demo: https://labs.mbed.com/simulator

Screenshot

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

Docs

Installation

Prerequisites

  1. Install Mbed CLI.
  2. Install Python 2.7 - not Python 3!.
  3. Install Git.
  4. Install Mercurial.
  5. Install Node.js v8 or higher.

Make sure that all of these are in your PATH. Verify this by opening a command prompt or terminal, and running:

$ where mbed
C:\Python27\Scripts\mbed.exe

$ where node
C:\Program Files\nodejs2\node.exe

$ where git
C:\Program Files\Git\cmd\git.exe

$ where hg
C:\Program Files\TortoiseHg\hg.exe

On Linux and macOS use which instead of where.

If one of the where / which commands does not yield a path, the utility is not in your PATH.

Installing Emscripten

To install the Emscripten cross-compilation toolchain, open a command prompt and:

  1. Clone the repository and install SDK version 1.38.21:

    $ git clone https://github.com/emscripten-core/emsdk.git
    $ cd emsdk
    $ emsdk install emscripten-1.38.21
    $ emsdk install sdk-fastcomp-tag-1.38.21-64bit
    $ emsdk activate emscripten-1.38.21
    $ emsdk activate fastcomp-clang-tag-e1.38.21-64bit
    
    # on Windows only:
    $ emsdk_env.bat --global
    
  2. Verify that the installation was successful:

    $ emcc -v
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.21
    
  3. Find the folder where emcc was installed:

    Windows

    $ where emcc
    C:\simulator\emsdk\emscripten\1.38.21\emcc
    

    macOS and Linux

    $ which emcc
    ~/toolchains/emsdk/emscripten/1.38.21/emcc
    
  4. Add this folder to your PATH.

    • On Windows:

      • Go to System Properties > Advanced > Environmental variables.
      • Find PATH.
      • Add the folder you found in the previous step, and add it prefixed by ;. E.g.: ;C:\simulator\emsdk\emscripten\1.38.21\
    • On macOS / Linux:

      • Open ~/.bash_profile or ~/.bashrc and add:
      PATH=$PATH:~/toolchains/emsdk/emscripten/1.38.21
      
  5. Open a new command prompt and verify that emcc can still be found by running:

    $ where emcc
    C:\simulator\emsdk\emscripten\1.38.21\emcc
    
  6. All set!

Installing the simulator through npm

Last, install the simulator. Easiest is through npm:

  1. Install the simulator:

    $ npm install mbed-simulator -g
    
  2. Clone an Mbed OS example program:

    $ mbed import mbed-os-example-blinky
    $ cd mbed-os-example-blinky
    
  3. Run the simulator:

    $ mbed-simulator .
    

    Note that this will download all dependencies (including Mbed OS) and will build the common libmbed library so this'll take some time.

Installing the simulator from source

  1. Install the simulator through git:

    $ git clone https://github.com/janjongboom/mbed-simulator.git
    $ cd mbed-simulator
    $ npm install
    $ npm install . -g
    
  2. Build your first example:

    $ node cli.js -i demos\blinky -o out --launch
    

    Note that this will download all dependencies (including Mbed OS) and will build the common libmbed library so this'll take some time.

  3. Done! The Mbed Simulator should now launch in your default browser.

Troubleshooting

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).

How to run the hosted version

  1. Install all dependencies, and clone the repository from source (see above).

  2. Run:

    $ npm install
    
    # Windows
    $ build-demos.bat
    
    # macOS / Linux
    $ sh build-demos.sh
    
  3. Then, start a web server:

    $ node server.js
    
  4. Open http://localhost:7829 in your browser.

  5. Blinky runs!

CLI

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.

Changing mbed-simulator-hal

After changing anything in the simulator HAL, you need to recompile the libmbed library:

  1. Run:

    $ rm mbed-simulator-hal/libmbed.bc
    
  2. Rebuild your application. libmbed will automatically be generated.

Updating demo's

In the out folder a number of pre-built demos are listed. To upgrade them:

macOS and Linux

$ sh build-demos.sh

Windows

$ build-demos.bat

Attribution

More Repositories

1

janpatch

JojoDiff Alternative Patch library - portable C library for memory-efficient binary patching
C
133
star
2

node-native-zip

Zipping in node.js with no external dependencies
JavaScript
106
star
3

Moth

Moth has all the awesomness Steve Souders thaught you about fast websites, but fully integrated in your ASP.NET MVC project!
JavaScript
27
star
4

ttn-sensor-maps

Create pretty looking maps of TTN sensor nodes
JavaScript
18
star
5

mbed-vscode-generator

Generate VSCode intellisense and build configuration for Mbed OS
JavaScript
17
star
6

alpine-opencv-docker

Pre-built OpenCV for armhf Alpine Linux 3.6
C++
15
star
7

arduino-mbed-mashup

Running Arduino sketches on Mbed OS
C
14
star
8

css-reflow-tracer

Helps track down CSS reflows
JavaScript
14
star
9

binary-diff-mbedos5

Using JANPatch to apply a binary diff in Mbed OS 5
C++
12
star
10

rollingspider.xyz

Fly a drone in your browser
JavaScript
10
star
11

mbed-os-example-fota-http

Firmware update over HTTP example for mbed OS 5
C++
7
star
12

neosensory-arduinoble

Talk to NeoSensory from ArduinoBLE
C++
7
star
13

fxos-physical-web

Physical Web app for Firefox OS
JavaScript
7
star
14

b-l475e-iot01a-audio-mbed

Mbed OS example on driving the MEMS microphones on ST IoT Discovery Board
C
6
star
15

sam-lorawan-mbedos5

Mbed OS 5 LoRaWAN stack running on SAML21 and SAMR34 Xplained Pro
C++
6
star
16

jdiff-js

JojoDiff in JavaScript
JavaScript
6
star
17

meetingroom-web

Meetingroom management with Physical Web, web part
JavaScript
5
star
18

stm32-standby-rtc-wakeup

Bring STM32 device into Standby mode and wake it from RTC (Mbed OS 5 library)
C
5
star
19

mbed-delta-update

Delta update library for Mbed OS 5
C
4
star
20

mbed-os-example-cryptoauthlib

Mbed OS 5 example program for interacting with Crypto Authentication secure elements
C
4
star
21

lorawan-fota-signing-tool

LoRaWAN Firmware Update signing tools for Mbed OS 5
JavaScript
4
star
22

mbed-coremark-lm32-printf

Small printf library for Mbed OS 5 - based on https://github.com/jpbonn/coremark_lm32
C
4
star
23

mbed-ws

WIP! Websocket client for Mbed OS
C++
4
star
24

dsa2018-greenhouse-monitor

Greenhouse monitoring system for DSA 2018
C++
4
star
25

mbed-cryptoauthlib

Mbed OS library for interacting with the Crypto Authentication secure elements
C++
4
star
26

janos-tracker-server

Simple server for the tracker
JavaScript
3
star
27

iot-devfest

IoT DevFest workshop 2019
C++
3
star
28

mbed-websocket

WIP!!! Sane, non-blocking websocket client for Mbed OS
C++
3
star
29

apializer

Api'alizer turns a website into an API
JavaScript
3
star
30

sxsw

Demo's for SXSW
C++
3
star
31

jsconf-us

JavaScript
3
star
32

jsconf-asia

Experiments for JSConf.asia
JavaScript
3
star
33

mbed-js-wrapper-generator

WIP C++ <> JerryScript wrapper generator
JavaScript
3
star
34

app-training-dhaka

Some small projects
JavaScript
3
star
35

mbed-lorawan-frag-lib

LoRaWAN fragmentation library
C++
2
star
36

hexiwear-cloud

Hexiwear to mbed Device Connector
C++
2
star
37

push-server

Simple push server and client for FFOS
JavaScript
2
star
38

koehandel

Just a game
JavaScript
2
star
39

mbed-os-example-http-server

HTTP Server for mbed OS 5 - work in progress
C++
2
star
40

c9integration

JavaScript
2
star
41

omg-awesome-homescreen

Simple third-party homescreen template for Firefox OS
JavaScript
2
star
42

apf-demo

JavaScript
2
star
43

mbed-js-simulator

Run mbed.js programs in your browser
JavaScript
2
star
44

mbed-find-dangling-pointers

Find dangling pointers in Mbed OS projects
JavaScript
2
star
45

threejs-dice-physics

A bunch of falling dice
JavaScript
2
star
46

socketioupload

Demonstration on how to use socket.io and nodejs to create a file sharing application
JavaScript
2
star
47

electricity-bus-tracker

Track buses in Gothenburg
JavaScript
1
star
48

mobileeast

Mobile East 2012 demo repository
JavaScript
1
star
49

internal-training-lora-2019

Internal training for LoRaWAN
C++
1
star
50

azure-private-key-extractor

C#
1
star
51

at45-blockdevice

mbed OS 5 block device driver for AT45 flash
C++
1
star
52

mak-maze

Maze game for FFOS
CSS
1
star
53

jsdom-demo

JavaScript
1
star
54

test123

1
star
55

dsa-firmware-2019

Firmware for DSA 2019
C++
1
star
56

lorawan-fragmentation-in-flash

Memory efficient implementation of LoRaWAN Datablock Fragmentation for mbed OS 5
C
1
star
57

arm-objdump-parser

Generate trees of C++ code by parsing objdump files
JavaScript
1
star
58

mbed-js-repl

JS REPL for mbed
C++
1
star
59

doodle-jump-fxos

JavaScript
1
star
60

tech-live-analytics

Tracking physical product engagement with Google Analytics
C++
1
star
61

mbed-os-example-lorawan-skt

SK Telecom LoRaWAN example for Mbed OS 5
C++
1
star
62

ttn-conf-workshop

The Things Network Conference - FOTA workshop material
JavaScript
1
star
63

connector-mqtt

mbed Device Connector over MQTT
JavaScript
1
star
64

md2mbed

Convert Markdown into formatted text for os.mbed.com
JavaScript
1
star
65

emscripten-node-mmap

mmap for emscripten's NODEFS lib
C++
1
star
66

mbed-os-example-lorawan-minimal

Minimal version of mbed-os-example-lorawan for Murata module
C++
1
star
67

mbed-os-example-blinky-no-rtos

Blinky for mbed OS 5 without using mbed RTOS
C++
1
star
68

6lowpan-notes

Notes for 6LoWPAN article
1
star
69

schizophrenia

JavaScript
1
star
70

mbed-tsl2572

Mbed OS driver for the TSL2572 ambient light sensor
C++
1
star
71

pelion-ready-plus-azure

Run Pelion Device Management and Azure IoT Hub Client on the same device
C++
1
star
72

mbed-os-dev-lorawan

SXSW 2018 Temp LoRaWAN fork of Mbed OS
C
1
star
73

mbed-config

Visual configuration system for Mbed OS
HTML
1
star
74

mbed-davis-anemometer

Mbed driver for Davis Anemometer
C++
1
star
75

google-maps-socketio-demo

Google Maps demo that let's you put pins on a map, by clicking or via geocode. Plus it distributes them to all others with the window open as well. Collaboration ftw!
JavaScript
1
star
76

dsa2017-fieldwork-fw

Firmware for fieldwork during DSA2017
C++
1
star