Skip to content

utsavm9/wasm-for-arduino-mbed

Repository files navigation

WASM for Mbed OS

Website | Video | Presentation

Primary Project Contribution


Folders

  • builds/: Contains binary image of WAMR+Mbed for Arduino Nano and STM32 Nucleo boards generated from this project. Also has thoughts on further work needed to flash to Arduino Nano.
  • docs/: Contains code for website and the presentation.
  • mbed/: Submodule of USC Mbed-CMake
  • measurements/: Code related to measuring the performance hit of using WASM interpreters on various boards
  • scripts/: Helpful scripts used in this project
  • wasm-micro-runtime/: Submodule of WAMR

Using WAMR with Mbed

  • Create a folder, say custom_app inside mbed/ folder to store the source files. Copy Mbed mini-product files inside wasm-micro-runtime/product-mini/platforms/mbed/ to that folder.

  • Make a soft-link to the root of WAMR repo, inside the mbed/ directory and name the soft-link as wamr.

# Bash
ln -s ~/wasm-micro-runtime/ ~/mbed/wamr
# Powershell run as Admin
New-Item -Name ~/mbed/wamr -ItemType SymbolicLink -Value ~\wasm-micro-runtime\
  • Copy build_mbed.ps1 inside mbed/.

  • The name of the executable specified here in CMakeLists.txt should be the same as in the build_mbed.ps1 script specified here and here.

  • The CMakeLists.txt of the current directory determines which project will be built. So, cd custom_app.

  • Compile with ../build_mbed.ps1.

  • A .bin file would be generated inside the mbed/build/. This can be copied to the drive to which an Mbed-enabled board mounted to flash the file onto the board.

Using WAMR with Zephyr

  • See scripts/ directory for help on using gen_wasm.sh to get C-byte array representing your WASM program.

  • Verify that a blinky program can be compiled and flashed to the board. Follow steps in "Getting Started Guide - Zephyr" or latest guide and get blinkly program flashed to board using west.

    • If using the same board as us (Nordic nRF528040), then the target name is nrf52840dk_nrf52840
  • Copy the Zephyr mini-product files from wasm-micro-runtime/product-mini/platforms/zephyr/simple/ to a new folder inside zephyr/samples/. Assume we copied the mini-product files into zephyr/samples/custom_app.

  • Make a soft-link to the root of WAMR repo, inside the custom_app directory and name the soft-link as wamr.

# Bash
ln -s ~/wasm-micro-runtime/ custom_app/wamr
# Powershell run as Admin
New-Item -Name custom_app/wamr -ItemType SymbolicLink -Value ~\wasm-micro-runtime\
  • Remove all files inside the custom_app/src folder and then place these files inside that foler:

    • measurements/nordic-wamr/main.c
    • measurements/fib_timed.c.wasm
  • With current directory the same as custom_app, so that the CMakeList.txt file is in the current directory, compile the app. A memory map of the program should be shown when successfully compiled.

west build -b nrf52840dk_nrf52840 . -p always -- -DWAMR_BUILD_TARGET=THUMB -DWAMR_BUILD_AOT=0
  • Connect board to USB with power switched on. Flash to the board using west flash.

  • Use Serial-Monitor script to find the associated COM port of the board. With default baud rate of 115200, Serial-Monitor script can be used to see the output from printf().

Measuring Rutime with WASM3

  • Recording time to finish computing fibonacci • See file

Team Members

About

ECE M202A Project: WASM for Arduino/Mbed

Resources

Stars

Watchers

Forks

Releases

No releases published