-
Notifications
You must be signed in to change notification settings - Fork 471
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
NodeMCU examples throw errors #26
Comments
I just spent some time debugging this. It looks like A Git bisect pointed me to 73c990a where the |
Yes you're right. After the initial support of different platforms was added (as an experiment), wasm3 changed a lot. So examples for MCUs are a bit left behind (I'm surprised they worked at all ;). |
You should enable |
Super that you'll be able to get around to fixing/updating the MCU examples - being able to run WASM on MCU's is a great prospect! Enabling I don't know if it is of any use, but the latest esp-pio based // ESP-PIO Fibonacci test, Wasm3, no-WASI, 4c01ba4, Dec 12th
#include <stdio.h>
#include <time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#define FATAL(msg, ...) { printf("Fatal: " msg "\n", ##__VA_ARGS__); return; }
#include "m3/m3.h"
#include "m3/m3_core.h"
#include "m3/extra/fib32.wasm.h"
void run_wasm()
{
M3Result result = c_m3Err_none;
u8* wasm = (u8*)fib32_wasm;
u32 fsize = fib32_wasm_len-1;
printf("Loading WebAssembly...\n");
IM3Module module;
result = m3_ParseModule (& module, wasm, fsize);
if (result) FATAL("m3_ParseModule: %s", result);
IM3Runtime env = m3_NewRuntime (1024);
if (!env) FATAL("m3_NewRuntime");
result = m3_LoadModule (env, module);
if (result) FATAL("m3_LoadModule: %s", result);
IM3Function f;
result = m3_FindFunction (&f, env, "fib");
if (result) FATAL("m3_FindFunction: %s", result);
printf("Running...\n");
const char* i_argv[2] = { "24", NULL };
result = m3_CallWithArgs (f, 1, i_argv);
if (result) FATAL("m3_CallWithArgs: %s", result);
}
void wasm_task(void*)
{
printf("\nwasm3 on ESP32, build " __DATE__ " " __TIME__ "\n");
clock_t start = clock();
run_wasm();
clock_t end = clock();
printf("Elapsed: %d ms\n", (end - start)*1000 / CLOCKS_PER_SEC);
for(;;) {
vTaskDelay(0xFFFF);
}
}
extern "C"
void app_main()
{
/* Print chip information */
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
chip_info.cores,
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
printf("silicon revision %d, ", chip_info.revision);
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
xTaskCreate(&wasm_task, "wasm_m3", 32768, NULL, 5, NULL);
for(;;) {
vTaskDelay(0xFFFF);
}
} Which, when run on an ESP32-WROOM-32, indeed correctly calculates the 24th term of the Fibonacci sequence:
|
Thanks for the info!
I will try to get esp* working again asap.
I doubt it WASI can be reasonably supported on MCUs (and if this is needed
at all). We'll see.
…On Sat, 28 Dec 2019, 14:26 Robin van Emden, ***@***.***> wrote:
Super that you'll be able to get around to fixing/updating the MCU
examples - being able to run WASM on MCU's is a great prospect! Enabling
d_m3AllocateLinearMemory by itself does not seem enough to make things
work yet, probably there is something I am still missing.
I don't know if it is of any use, but the latest esp-pio based wasm3
example we ran was based on commit 4c01ba4, about 17 days ago. We just
removed the unfinished WASI files from the m3 directory and included
m3/m3_core.h:
// ESP-PIO Fibonacci test, Wasm3, no-WASI, 4c01ba4, Dec 12th
#include <stdio.h>
#include <time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#define FATAL(msg, ...) { printf("Fatal: " msg "\n", ##__VA_ARGS__); return; }
#include "m3/m3.h"
#include "m3/m3_core.h"
#include "m3/extra/fib32.wasm.h"
void run_wasm()
{
M3Result result = c_m3Err_none;
u8* wasm = (u8*)fib32_wasm;
u32 fsize = fib32_wasm_len-1;
printf("Loading WebAssembly...\n");
IM3Module module;
result = m3_ParseModule (& module, wasm, fsize);
if (result) FATAL("m3_ParseModule: %s", result);
IM3Runtime env = m3_NewRuntime (1024);
if (!env) FATAL("m3_NewRuntime");
result = m3_LoadModule (env, module);
if (result) FATAL("m3_LoadModule: %s", result);
IM3Function f;
result = m3_FindFunction (&f, env, "fib");
if (result) FATAL("m3_FindFunction: %s", result);
printf("Running...\n");
const char* i_argv[2] = { "24", NULL };
result = m3_CallWithArgs (f, 1, i_argv);
if (result) FATAL("m3_CallWithArgs: %s", result);
}
void wasm_task(void*)
{
printf("\nwasm3 on ESP32, build " __DATE__ " " __TIME__ "\n");
clock_t start = clock();
run_wasm();
clock_t end = clock();
printf("Elapsed: %d ms\n", (end - start)*1000 / CLOCKS_PER_SEC);
for(;;) {
vTaskDelay(0xFFFF);
}
}
extern "C"void app_main()
{
/* Print chip information */
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
chip_info.cores,
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
printf("silicon revision %d, ", chip_info.revision);
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
xTaskCreate(&wasm_task, "wasm_m3", 32768, NULL, 5, NULL);
for(;;) {
vTaskDelay(0xFFFF);
}
}
Which, when run on an ESP32-WROOM-32, indeed correctly calculates the 24th
term of the Fibonacci sequence:
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
wasm3 on ESP32, build Dec 28 2019 12:53:11
Loading WebAssembly...
Running...
Result: 46368
Elapsed: 410 ms
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#26?email_source=notifications&email_token=AALP3FEODT4UDO54EAL4XBTQ25AXVA5CNFSM4KAA2XF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYIZDY#issuecomment-569412751>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALP3FFKVYEXR25CJMPC4YDQ25AXVANCNFSM4KAA2XFQ>
.
|
Thanks again! As an aside: one of the main reasons of our interest in WASI is that often even basic C/C++ scripts compiled with |
@vshymanskyy Would you be interested in a PR to add CI tests for the ESP32 platform (in QEMU)? |
@igrr it would be much appreciated ;) I've already considered QEMU for this kind of tests. |
First step, just adding the build test: #27. |
@robinvanemden @hberntsen should work now with |
Both Also great work on the CI tests for the ESP32, @igrr .. |
That is very cool! Thanks! Is it now mainly a question of including |
@robinvanemden this isn't yet available on guthub, and currently requires PSRAM, 64Kb of native stack, and so on. I think it can be included as a separate example, but it also requires a lot of cleanup ;) |
@igrr FYI ;) |
Very interested as well! Can help with cleanup for this new example. |
@robinvanemden For WASI on the ESP32 you need to integrate with the FreeRTOS/ESP32 API. I am doing some experiments with Rust -> Webassembly -> wasm3 on ESP32. I already got a simple |
@igrr @robinvanemden @hberntsen A basic ESP32-WASI example has landed here: https://github.com/wasm3/wasm3/tree/master/platforms/esp32-idf-wasi |
@vshymanskyy that is great news - thanks for making the ESP32-WASI example available! I should be able to test the code on some of our ESP32s tomorrow :) |
Hi @vshymanskyy, I was just able to do a quick test-run of the basic ESP32-WASI example on an ESP32-WROVER-B with 4MB of flash memory and 8MB of PSRAM, and received the following error message:
I presume that I should, in principle, be able to get the example to run on an ESP32-WROVER-B? I am able to put some time into a further investigation of this issue later this week. Of course, suggestions and tips are always welcome :) |
It might also be useful to know the exact ESP32 make and model you made the examle work for - then I could compare specs and get an idea of where you are starting from. |
@robinvanemden I don't think your ESP32 is different too much. |
@robinvanemden fixed in 0edc1af |
Yay! That commit solved my final issue - your example code now runs perfectly on three different types of ESP32 WROVER:
Thanks once again! |
About two weeks ago, we were able to run several WebAssembly modules on NodeMCU ESP microcontrollers following the
esp32-pio
andesp8266
platform examples.In the meanwhile, work on
wasm3
has clearly continued - we are particularly happy with the WASI support!I am, however, now unable to run our WASM modules using the latest code base. For instance, on adapting the
esp8266
example as follows:... one of our ESP8266's throws the following error:
Also, updating the code of the esp32-pio example along the same lines throws a Guru Meditation error, followed by a boot loop.
Might it be possible to provide a minimal working example that runs, for instance,
fib32_wasm
on ESP8266 and ESP32 using the latest version ofwasm3
?(Separately, linking WASI gives rise to the following error on the ESP8266:
/home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/time/clock.c:62: undefined reference to _times_r
... but that is of course a different issue)
The text was updated successfully, but these errors were encountered: