topllab / warduino Goto Github PK
View Code? Open in Web Editor NEW📟 A dynamic WebAssembly VM for embedded systems
Home Page: https://topllab.github.io/WARDuino/
License: Mozilla Public License 2.0
📟 A dynamic WebAssembly VM for embedded systems
Home Page: https://topllab.github.io/WARDuino/
License: Mozilla Public License 2.0
Add WebAssembly SIMD instructions proposal: https://github.com/WebAssembly/simd/blob/main/proposals/simd/SIMD.md
Overview of new opcodes: https://github.com/WebAssembly/simd/blob/main/proposals/simd/NewOpcodes.md
Full list of current opcodes: https://webassembly.github.io/spec/core/appendix/index-instructions.html?highlight=opcode
Spectests that fail because of this missing proposal:
This function shoud replace fn with
(topic,payload)=>{fn()}
WARDuino/examples/assemblyscript/lib/warduino.ts
Lines 48 to 50 in f2ea06a
The MQTT unsubscribe function removes the callback from the callback list, but there may be multiple callbacks for the same topic. As long as there are callbacks left, the subscription should remain.
WARDuino/src/Primitives/primitives.cpp
Lines 709 to 731 in f2ea06a
Note: I did not test this and could be entirely wrong, to me the code seems to not handle this case correctly
recvCallbackmapping
interruptdumpCallbackmapping
interruptWe should fix this properly. That way we can also remove the sdkconfig
file from the repository.
I am unable to connect to Wifi when using the smartlamp.ts example.
However if I change the following function:
function until_connected(connect: () => void,
connected: () => boolean): void {
while (!connected()) {
wd.delay(1000);
connect();
}
}
into
function until_connected(connect: () => void,
connected: () => boolean): void {
while (!connected()) {
connect();
wd.delay(5000);
}
}
the program connects to Wifi.
Requested features:
We must make sure we know immediately when changes might break the VS Code plugin.
I'm not sure whether this is an issue or not but I rather mention it just in case.
I noticed that to correctly use primitive subscribe_interrupt the executed Wasm needs to use a memory page and provide the function that needs to be used as callback as a table index.
I can understand why we need the memory page since this is the location where MQTT payloads get stored but are we 100% sure that compilers will always generate Wasm that uses at least one memory page? And also is there a reason why we need to pass the callback identifier through the table? Can the function identifier of the callback simply be passed as an argument to subscribe_interrupt
?
Trying to run the AssemblyScript example without the mqtt fails. (= programming demo example)
When the busy loop is empty, binaryen optimizes away callback functions. It eliminates the funcref
table and passes the function's own index to the subscribe_interrupt
primitive.
while (true) {
wd.sleep(5); // Sleep for 5 seconds
}
The resulting index is obviously out of range since there is no table. This causes an unhandled exception whenever the VM wants to resolve an event.
It seems users of Asyncify have run into similar problems: WebAssembly/binaryen#4484
Debugging wasm opcode execution doesn't seem very useful. Is source-level debugging available? If yes, are there any docs on this?
100 files from the official spectests fail due to changes from newly standardized WASM proposals:
OOP doesn't seem to work anymore:
set_pinmode
, subscribe_interrupt
, ... So no events are generated from the device.Tasks:
Spectests that fail because of this missing proposal:
Once WARDuino reaches a breakpoint, sending a RUN
interrupt to WARDuino does not resume the computation, but instead WARDuino gets stuck at the currently reached bp.
The reason is the if-statement responsible to determine whether the current pc_ptr
contains a breakpoint (see interpret function file instructions.cpp line nr. 1490). When you resume computation after reaching a bp, the if statement re-evaluates the pc_ptr
to be a bp and thus pauses the execution once again. I guess this is not desired behavior?
If needed I can make a pull request for this.
CallbackHandler::push_event
: sends event to emulator (as json)Event
CallbackHandler::push_event
)json interface:
{
"topic":"topic string",
"payload":"payload as a string"
}
The #47 pull request works, but there are a lot of outstanding issues before it can be merged into master.
#ifndef ARDUINO
as much as possibleRelated issues in the plugin:
After adjusting the benchmarks for the new project structure, and adding edward benchmark (c85bc8e), the benchmarks are 5 to 6 times as slow.
Primitives are now implemented in separate implementation files for each platform with one common header.
We should add an implementation file for ESP-IDF.
Instead of reflashing a drone version of the Arduino.ino
file to the board after we pull the debugsession, we should add a dronify or zombify message which simply tells the device to turn into a drone.
Arduino-socket.ino
Our goal is to allow the full VM to be tested with the emulated version.
The most challenging part is testing OOP with the emulator because a lot of inherited code is microcontroller specific.
Things to fix in order:
This will allow for manual testing of OOP with 2 emulated VMs. As part of #53 we can add automated API tests in a next step.
Are you missing a detachInterrupt
at unsubscribe_interrupt primitive?
If so, I'll provide a PR.
When debugging larger files, the offset reported by warduino is sometimes wrong (off by one)
The cause is probably somewhere here:
Lines 314 to 327 in 07cf2b6
Lines 335 to 339 in 07cf2b6
@carllocos could you supply 2 files: one with correct offset, one with a wrong offset
We should look into supporting WASI.
On branch feat/wood
there are a lot of temporary and unnecessary files.
We should clean the repo before merging #47.
Remove the following files:
do_build.sh
platforms/Arduino/upload
platforms/Arduino-socket/*
scripts/*
examples/blinkm5stickc
examples/factorial
I'm writing a python client to WARDuino and noticed that when sending an interrupt through the socket, the interrupt payload has to end with a space and a new line in order to be processed by WARDuino: '60 \n'
works fine but '60\n'
or '60 '
does not work.
However, when sending interrupts through Telnet the space is not needed i.e., it suffices to type '60'
and press enter
.
Block types may be expressed in one of two forms; (1) as a type index of an existing function type or (2) as a value type.¹
Currently the VM only supports the latter. (see WARDuino.cpp#L57)
However, to avoid collision with the type indices, the value types are encoded as negative numbers.
In WARDuino we only use unsigned integers.
This means that simply adding type indices to the switch statement in the get_block_types function, like we did in commit fc5c1df, means collisions are technically possible.
How would we best resolve this?
¹ https://webassembly.github.io/spec/core/valid/types.html?highlight=block#block-types
Changes to the memory are not forwarded to the drone.
This means that calling primitives with pointers (start + length of string for example) may fail, as the memory is not kept in sync.
Hi! I would like to know if there is a list of supported mcu's other than esp32/esp8266. If not, it is possible to get some instructions on how to build WARDuino for other Arduino compatible mcu's??
Thanks.
Some frames contain a stack pointer that is less than -1, causing a buffer underflow in pop_block
when save the top value as result.
The emulator must be able to instruct the proxy device to register for a specific callback.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.