npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mbed-simulator

v1.9.7

Published

Mbed OS 5 simulator

Downloads

199

Readme

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 sdk-1.38.21-64bit
    $ emsdk activate sdk-1.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.

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

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