Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zephyr: unable to build simple example targeting the nucleo_f767zi board with libc wasi #2846

Open
deadprogram opened this issue Dec 2, 2023 · 9 comments · May be fixed by #3086
Open

zephyr: unable to build simple example targeting the nucleo_f767zi board with libc wasi #2846

deadprogram opened this issue Dec 2, 2023 · 9 comments · May be fixed by #3086

Comments

@deadprogram
Copy link

deadprogram commented Dec 2, 2023

I am trying to build the product-mini/platforms/zephyr/simple example targeting the nucleo_f767zi board with WAMR_BUILD_LIBC_WASI so that a WASM module compiled for wasi can execute on the board itself.

This is the command I am trying to use to build:

ZEPHYR_BASE=~/zephyrproject/zephyr west build -b nucleo_f767zi . -p always -- -DWAMR_BUILD_TARGET=THUMBV7 -DWAMR_BUILD_LIBC_WASI=1

However, the code is unable to build without errors:

-- Zephyr version: 3.5.99 (/home/ron/zephyrproject/zephyr), build: zephyr-v3.5.0-2399-gc94cd30cecbf                                                                          
[30/177] Building C object CMakeFiles/app.dir/home/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c.obj             FAILED: CMakeFiles/app.dir/home/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c.obj                                
ccache /home/ron/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBH_FREE=wasm_runtime_free -DBH_MALLOC=wasm_runtime_malloc -DBH_PLATFORM_ZEPHYR -DBUILD_TARGET=\"
THUMBV7\" -DBUILD_TARGET_THUMB -DCORE_CM7 -DHSE_VALUE=8000000 -DKERNEL -DPICOLIBC_LONG_LONG_PRINTF_SCANF -DSTM32F767xx -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -DWASM_DISABLE_H
W_BOUND_CHECK=0 -DWASM_DISABLE_STACK_HW_BOUND_CHECK=0 -DWASM_DISABLE_WAKEUP_BLOCKING_OP=0 -DWASM_ENABLE_AOT=1 -DWASM_ENABLE_BULK_MEMORY=1 -DWASM_ENABLE_FAST_INTERP=0 -DWASM_
ENABLE_GLOBAL_HEAP_POOL=1 -DWASM_ENABLE_INTERP=1 -DWASM_ENABLE_LIBC_BUILTIN=1 -DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_MINI_LOADER=0 -DWASM_ENABLE_MODULE_INST_CONTEXT=1 -DWASM_ENABLE_MULTI_MODULE=0 -DWASM_ENABLE_SHARED_MEMORY=0 -DWASM_GLOBAL_HEAP_SIZE=131072 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_ST
ART -D__ZEPHYR__=1 -I/home/ron/Development/wasm-micro-runtime/core/iwasm/interpreter -I/home/ron/Development/wasm-micro-runtime/core/iwasm/aot -I/home/ron/Development/wasm-m
icro-runtime/core/iwasm/libraries/libc-builtin -I/home/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include -I/home/ron/Deve
lopment/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src -I/home/ron/Development/wasm-micro-runtime/product-mini/platforms/zephyr/simple/../
../../../core/iwasm/include -I/home/ron/Development/wasm-micro-runtime/core/shared/platform/zephyr -I/home/ron/Development/wasm-micro-runtime/core/shared/platform/zephyr/../
include -I/home/ron/Development/wasm-micro-runtime/core/shared/mem-alloc -I/home/ron/Development/wasm-micro-runtime/core/iwasm/common -I/home/ron/Development/wasm-micro-runt
ime/core/shared/utils -I/home/ron/zephyrproject/zephyr/include -I/home/ron/Development/wasm-micro-runtime/product-mini/platforms/zephyr/simple/build/zephyr/include/generated
 -I/home/ron/zephyrproject/zephyr/soc/arm/st_stm32/stm32f7 -I/home/ron/zephyrproject/zephyr/drivers -I/home/ron/zephyrproject/zephyr/soc/arm/st_stm32/common -I/home/ron/zeph
yrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/ron/zephyrproject/zephyr/modules/cmsis/. -I/home/ron/zephyrproject/modules/hal/stm32/stm32cube/stm32f7xx/soc -I/home/r
on/zephyrproject/modules/hal/stm32/stm32cube/stm32f7xx/drivers/include -I/home/ron/zephyrproject/modules/hal/stm32/stm32cube/stm32f7xx/drivers/include/Legacy -I/home/ron/zep
hyrproject/modules/hal/stm32/stm32cube/common_ll/include -isystem /home/ron/zephyrproject/zephyr/lib/libc/common/include -std=gnu99 -ffunction-sections -fdata-sections      
                                    -Wall -Wno-unused-parameter -Wno-pedantic -mthumb -fno-strict-aliasing -Os -imacros /home/ron/Development/wasm-micro-runtime/product-mini
/platforms/zephyr/simple/build/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m7 -mthumb -mabi
=aapcs -mfp16-format=ieee -mtp=soft --sysroot=/home/ron/zephyr-sdk-0.16.4/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/ron/zephyrproject/zephyr/include/zephyr/toolchain/ze
phyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit
-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/ron/Devel
opment/wasm-micro-runtime/product-mini/platforms/zephyr/simple=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/ron/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/ron/ze
phyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT CMakeFiles/app.dir/home/ron/Development/wasm-micro-runtime/core/iwasm/lib
raries/libc-wasi/sandboxed-system-primitives/src/posix.c.obj -MF CMakeFiles/app.dir/home/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-p
rimitives/src/posix.c.obj.d -o CMakeFiles/app.dir/home/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c.obj -c /home
/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
/home/ron/Development/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:18:10: fatal error: libc_errno.h: No such file or directory
   18 | #include "libc_errno.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.
....

Any ideas? Thanks in advance!

@deadprogram deadprogram changed the title zephyr: unable to build simple example targeting the nucleo_f767zi board with wasi libc zephyr: unable to build simple example targeting the nucleo_f767zi board with libc wasi Dec 2, 2023
@deadprogram
Copy link
Author

deadprogram commented Dec 2, 2023

If I try to execute my WASM code compiled targeting wasi but without the WAMR_BUILD_LIBC_WASI=1 I get the following log from the board after flashing:

Connected to /dev/ttyACM0. Press Ctrl-C to exit.
*** Booting Zephyr OS build zephyr-v3.5.0-2399-gc94cd30cecbf ***
WASM module instantiate failed: allocate memory failed
elapsed: 14

@deadprogram
Copy link
Author

If I compile iwasm for Linux, and I set WAMR_BUILD_LIBC_WASI 0 then I get the following error:

$ ./iwasm ../../../app-samples/hello-world-tinygo/test.wasm 
[16:13:34:719 - 7FCAE7617B80]: warning: failed to link import function (wasi_snapshot_preview1, fd_write)
Exception: lookup the entry point symbol (like main, _main, __main_argc_argv) failed

If I compile iwasm with WAMR_BUILD_LIBC_WASI 1 then the code executes as I expect:

$ ./iwasm ../../../app-samples/hello-world-tinygo/test.wasm 
Hello world!

@hasheddan
Copy link
Contributor

@deadprogram thanks for reporting! I've been working on the zephyr support and will look into this!

@deadprogram
Copy link
Author

Thanks @hasheddan

@deadprogram
Copy link
Author

Hello @hasheddan any updates on this by any chance? 😸

@deadprogram
Copy link
Author

👋 😺

@hasheddan
Copy link
Contributor

@deadprogram thank you for the ping and my apologies on the delay here! I have just opened #3086 to address the primary issue you encountered here, but am also investigating additional rough spots regarding WASI support with Zephyr. Feel free to try out the patch and report any further problems you encounter!

@salva00
Copy link

salva00 commented Jan 25, 2024

Hello, I have the same issue with build to qemu_cortex_a53 :(
I am running the latest wamr version (I've just pulled from main branch)

@srberard
Copy link
Contributor

Is there any update on this issue? I'm having similar problems building with WAMR_BUILD_LIBC_WASI 1 on Zephyr. I'm still targeting WASI preview 1 so I'm on the release/1.3.x branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants