This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b01b93cb54 sim/wamr: add example of WAMR(WebAssembly Micro Runtime)
b01b93cb54 is described below

commit b01b93cb54efc8d1dbd3116fd87287e4aea72426
Author: chao an <[email protected]>
AuthorDate: Thu Mar 2 11:57:15 2023 +0800

    sim/wamr: add example of WAMR(WebAssembly Micro Runtime)
    
    Added compilation rules to support the construction of 
WebAssembly(WASM/WAMR):
    
    1. Compile Toolchain
     1> Download WASI sdk and export the WASI_SDK_PATH path:
    
    $ wget 
https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
    $ tar xf wasi-sdk-19.0-linux.tar.gz
    Put wasi-sdk-19.0 to your host WASI_SDK_PATH environment variable, like:
    $ export WASI_SDK_PATH=`pwd`/wasi-sdk-19.0
    
     2> Download Wamr "wamrc" AOT compiler and export to the PATH:
    $ mkdir wamrc
    $ wget 
https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/WAMR-1.1.2/wamrc-1.1.2-x86_64-ubuntu-20.04.tar.gz
    $ tar xf wamrc-1.1.2-x86_64-ubuntu-20.04.tar.gz
    $ export PATH=$PATH:$PWD
    
    2. Configuring and running
    
     1> Configuring sim/wamr and compile:
    
    nuttx$ ./tools/configure.sh  sim/wamr
    nuttx$ make
    ...
    Wamrc Generate AoT: /home/archer/code/nuttx/n5/apps/wasm/hello.aot
    Wamrc Generate AoT: /home/archer/code/nuttx/n5/apps/wasm/coremark.aot
    LD:  nuttx
    
     2> Copy the generated wasm file(Interpreter/AoT)
    
    nuttx$ cp ../apps/wasm/hello.aot .
    nuttx$ cp ../apps/wasm/hello.wasm .
    nuttx$ cp ../apps/wasm/coremark.wasm .
    
     3> Run iwasm
    
    nuttx$ ./nuttx
    NuttShell (NSH) NuttX-10.4.0
    nsh> iwasm /data/hello.wasm
    Hello, World!!
    nsh> iwasm /data/hello.aot
    Hello, World!!
    nsh> iwasm /data/coremark.wasm
    2K performance run parameters for coremark.
    CoreMark Size    : 666
    Total ticks      : 12000
    Total time (secs): 12.000000
    Iterations/Sec   : 5.000000
    Iterations       : 60
    Compiler version : Clang 15.0.7
    Compiler flags   : Using NuttX compilation options
    Memory location  : Defined by the NuttX configuration
    seedcrc          : 0xe9f5
    [0]crclist       : 0xe714
    [0]crcmatrix     : 0x1fd7
    [0]crcstate      : 0x8e3a
    [0]crcfinal      : 0xa14c
    Correct operation validated. See README.md for run and reporting rules.
    CoreMark 1.0 : 5.000000 / Clang 15.0.7 Using NuttX compilation options / 
Defined by the NuttX configuration
    
    Signed-off-by: chao an <[email protected]>
---
 boards/sim/sim/sim/README.txt             | 63 +++++++++++++++++++++
 boards/sim/sim/sim/configs/wamr/defconfig | 91 +++++++++++++++++++++++++++++++
 boards/sim/sim/sim/src/etc/init.d/rcS     |  6 ++
 tools/ci/testlist/sim-01.dat              |  3 +
 4 files changed, 163 insertions(+)

diff --git a/boards/sim/sim/sim/README.txt b/boards/sim/sim/sim/README.txt
index c6e25de7b9..c6d84bddb6 100644
--- a/boards/sim/sim/sim/README.txt
+++ b/boards/sim/sim/sim/README.txt
@@ -1372,3 +1372,66 @@ vncserver
 vpnkit
 
   This is a configuration with VPNKit support.  See NETWORK-VPNKIT.txt.
+
+wamr
+
+  This is a configuration for WebAssembly sample.
+
+  1. Compile Toolchain
+
+   1> Download WASI sdk and export the WASI_SDK_PATH path:
+
+  $ wget 
https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
+  $ tar xf wasi-sdk-19.0-linux.tar.gz
+  Put wasi-sdk-19.0 to your host WASI_SDK_PATH environment variable, like:
+  $ export WASI_SDK_PATH=`pwd`/wasi-sdk-19.0
+
+   2> Download Wamr "wamrc" AOT compiler and export to the PATH:
+
+  $ mkdir wamrc
+  $ wget 
https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/WAMR-1.1.2/wamrc-1.1.2-x86_64-ubuntu-20.04.tar.gz
+  $ tar xf wamrc-1.1.2-x86_64-ubuntu-20.04.tar.gz
+  $ export PATH=$PATH:$PWD
+
+  2. Configuring and running
+
+   1> Configuring sim/wamr and compile:
+
+  nuttx$ ./tools/configure.sh  sim/wamr
+  nuttx$ make
+  ...
+  Wamrc Generate AoT: /home/archer/code/nuttx/n5/apps/wasm/hello.aot
+  Wamrc Generate AoT: /home/archer/code/nuttx/n5/apps/wasm/coremark.aot
+  LD:  nuttx
+
+   2> Copy the generated wasm file(Interpreter/AoT)
+
+  nuttx$ cp ../apps/wasm/hello.aot .
+  nuttx$ cp ../apps/wasm/hello.wasm .
+  nuttx$ cp ../apps/wasm/coremark.wasm .
+
+   3> Run iwasm
+
+  nuttx$ ./nuttx
+  NuttShell (NSH) NuttX-10.4.0
+  nsh> iwasm /data/hello.wasm
+  Hello, World!!
+  nsh> iwasm /data/hello.aot
+  Hello, World!!
+  nsh> iwasm /data/coremark.wasm
+  2K performance run parameters for coremark.
+  CoreMark Size    : 666
+  Total ticks      : 12000
+  Total time (secs): 12.000000
+  Iterations/Sec   : 5.000000
+  Iterations       : 60
+  Compiler version : Clang 15.0.7
+  Compiler flags   : Using NuttX compilation options
+  Memory location  : Defined by the NuttX configuration
+  seedcrc          : 0xe9f5
+  [0]crclist       : 0xe714
+  [0]crcmatrix     : 0x1fd7
+  [0]crcstate      : 0x8e3a
+  [0]crcfinal      : 0xa14c
+  Correct operation validated. See README.md for run and reporting rules.
+  CoreMark 1.0 : 5.000000 / Clang 15.0.7 Using NuttX compilation options / 
Defined by the NuttX configuration
diff --git a/boards/sim/sim/sim/configs/wamr/defconfig 
b/boards/sim/sim/sim/configs/wamr/defconfig
new file mode 100644
index 0000000000..c3a76fb80d
--- /dev/null
+++ b/boards/sim/sim/sim/configs/wamr/defconfig
@@ -0,0 +1,91 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ALLOW_BSD_COMPONENTS=y
+CONFIG_ALLSYMS=y
+CONFIG_ARCH="sim"
+CONFIG_ARCH_BOARD="sim"
+CONFIG_ARCH_BOARD_SIM=y
+CONFIG_ARCH_CHIP="sim"
+CONFIG_ARCH_SIM=y
+CONFIG_BENCHMARK_COREMARK=y
+CONFIG_BOARDCTL_APP_SYMTAB=y
+CONFIG_BOARDCTL_POWEROFF=y
+CONFIG_BOARD_LOOPSPERMSEC=0
+CONFIG_BOOT_RUNFROMEXTSRAM=y
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEV_GPIO=y
+CONFIG_DEV_LOOP=y
+CONFIG_DEV_ZERO=y
+CONFIG_EXAMPLES_GPIO=y
+CONFIG_EXAMPLES_HELLO=y
+CONFIG_FSUTILS_PASSWD=y
+CONFIG_FSUTILS_PASSWD_READONLY=y
+CONFIG_FS_BINFS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_HOSTFS=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_RAMMAP=y
+CONFIG_FS_ROMFS=y
+CONFIG_GPIO_LOWER_HALF=y
+CONFIG_IDLETHREAD_STACKSIZE=4096
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTERPRETERS_WAMR=y
+CONFIG_INTERPRETERS_WAMR_AOT=y
+CONFIG_INTERPRETERS_WAMR_BULK_MEMORY=y
+CONFIG_INTERPRETERS_WAMR_CLASSIC=y
+CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y
+CONFIG_INTERPRETERS_WAMR_LIBC_WASI=y
+CONFIG_INTERPRETERS_WAMR_LIB_PTHREAD=y
+CONFIG_INTERPRETERS_WAMR_LOG=y
+CONFIG_INTERPRETERS_WAMR_THREAD_MGR=y
+CONFIG_INTERPRETERS_WAMR_VERSION="9f0c4b63ac21c975aee7aae30236e306c8e49d13"
+CONFIG_IOB_NBUFFERS=196
+CONFIG_IOEXPANDER=y
+CONFIG_IOEXPANDER_DUMMY=y
+CONFIG_LIBC_DLFCN=y
+CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_LOCALE=y
+CONFIG_LIBC_LOCALE_CATALOG=y
+CONFIG_LIBC_LOCALE_GETTEXT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
+CONFIG_LIBC_NUMBERED_ARGS=y
+CONFIG_LIBM=y
+CONFIG_MM_IOB=y
+CONFIG_NET=y
+CONFIG_NET_BINDTODEVICE=y
+CONFIG_NET_SOCKOPTS=y
+CONFIG_NET_TUN=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_ARCHROMFS=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FATDEVNO=2
+CONFIG_NSH_FILE_APPS=y
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_ROMFSDEVNO=1
+CONFIG_NSH_ROMFSETC=y
+CONFIG_PATH_INITIAL="/bin"
+CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
+CONFIG_PSEUDOFS_ATTRIBUTES=y
+CONFIG_PSEUDOFS_SOFTLINKS=y
+CONFIG_READLINE_CMD_HISTORY=y
+CONFIG_READLINE_TABCOMPLETION=y
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_HAVE_PARENT=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SIM_HOSTFS=y
+CONFIG_SIM_WALLTIME_SIGNAL=y
+CONFIG_START_MONTH=6
+CONFIG_START_YEAR=2008
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TLS_NELEM=8
+CONFIG_TLS_TASK_NELEM=10
diff --git a/boards/sim/sim/sim/src/etc/init.d/rcS 
b/boards/sim/sim/sim/src/etc/init.d/rcS
index 2cc08c80b4..27f9e961c1 100644
--- a/boards/sim/sim/sim/src/etc/init.d/rcS
+++ b/boards/sim/sim/sim/src/etc/init.d/rcS
@@ -17,3 +17,9 @@
  * under the License.
  *
  ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifdef CONFIG_FS_HOSTFS
+mount -t hostfs -o fs=. /data
+#endif
diff --git a/tools/ci/testlist/sim-01.dat b/tools/ci/testlist/sim-01.dat
index 8816702087..5e74c1131e 100644
--- a/tools/ci/testlist/sim-01.dat
+++ b/tools/ci/testlist/sim-01.dat
@@ -29,3 +29,6 @@
 -Darwin,sim:nx11
 -Darwin,sim:nxlines
 -Darwin,sim:nxwm
+
+# Skip WebAssembly Micro Runtime
+-Darwin,sim:wamr

Reply via email to