Skip to content

Commit

Permalink
Version 0.3.0 (TOPLLab#158)
Browse files Browse the repository at this point in the history
* 👷 Bump actions/checkout from v3 to v4

Bump actions/setup-python from v2 to v4

* Fix/pause (TOPLLab#147)

* 🔨 Refactor `pthreads` to `std::thread`

* Sleep during pause

Uses std::condition_variable to wait for new messages.
Fixes TOPLLab#145

* Feat/update globals (TOPLLab#151)

Add the `UPDATEGlobal` debug message.

---------

Co-authored-by: tolauwae <[email protected]>

* 👷 Add unit tests to CI (TOPLLab#153)

* add yml unit test file

* add unit test github workflow

* bug fix: cmake . -> cmake ..

* remove redundant tests

* 🔨 Refactor action title for GitHub

---------

Co-authored-by: tolauwae <[email protected]>

* Improve Arduino staging (TOPLLab#159)

* Use templates and config in Arduino staging

The new staging disables the paused start by default.

* Remove `dump.txt`

* Add update stackvalue message (TOPLLab#155)

* use new deserialiseStackValue

* add updateStackValue interrupt handler

* add fixture + tests for deserialization U32

* add tests for deserialization I32

* add tests for deserialization F32

* add tests for deserialization F64

* bug fix: add missing white space

* add missing default case

* add test for invalid wasm type

* format doc

* deactivate type update for handleUpdateStackValue

* Fix util.h

---------

Co-authored-by: Carlos Rojas <[email protected]>
Co-authored-by: tolauwae <[email protected]>

* 🐛 Fix unopened channel in ProxySupervisor (TOPLLab#165)

Co-authored-by: Carlos Rojas <[email protected]>

* 🐛 Fix deserialisation of float results in proxy call (TOPLLab#166)

Co-authored-by: Carlos Rojas <[email protected]>

* 🐛 Add newline to event notification  (TOPLLab#171)

* Fix issue TOPLLab#168 (TOPLLab#169)

* Fix memory leaks of guard blocks (TOPLLab#167)

* alloc in the same way as callback guard

allocate both a callback guard block and proxy block in the similar manner so to free both blocks in a similar manner

* bug fix: free dynamically allocated guard blocks

blocks of type event or proxy guard are allocated at runtime at the occurrence of a proxyCall or event. These blocks need to be freed when freeing the module state

* buf fix: free callback or proxy block before popping next frame

* set block to nullptr after free & free only non null blocks

* refactor: rename class

* refactor: renamed file name

* add freeing module skeleton fixture code

* moved unit tests to freeingmodule_test.cpp

* bug fix proxy call: setup call back should occur prior to push guard

* bug fix proxy call: block type should be 0xfe and not 0xff

* bug fix pushing event: exclude the interruptnumber from the json parse

* 🔨 Rename WOODDUMP to snapshot

Remove references to WOOD.

* 🚨 Latch test suites (TOPLLab#176)

* 🚨 Add Latch suites

* Add core spectest folder

* Remove deprecated built-in spectests

* 🐛 Fix latch test suites

* 🔖 Bump version number to 0.3.0

---------

Co-authored-by: Carlos Rojas <[email protected]>
Co-authored-by: Carlos Rojas <[email protected]>
  • Loading branch information
3 people authored May 16, 2023
1 parent 6cd2bf6 commit 62aa3b5
Show file tree
Hide file tree
Showing 428 changed files with 17,506 additions and 1,461 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/[email protected]
with:
Expand All @@ -29,7 +29,7 @@ jobs:
os: [ubuntu-20.04, ubuntu-22.04, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand Down Expand Up @@ -68,10 +68,10 @@ jobs:
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
sketches: |
- platforms/Arduino
- tests/compilation/esp32/esp32.ino
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
platform-name: esp32:esp32
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand Down
64 changes: 27 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
name: WASM Spectests
on: [push, pull_request]
name: Tests
on: [ push, pull_request ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true # Cancel in-flight jobs for the same branch or PR
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true # Cancel in-flight jobs for the same branch or PR

jobs:
test:
name: Run official testsuite
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Build warduino cli
run: cmake . -D BUILD_EMULATOR=ON ; cmake --build .

- name: Build WABT # Build latest version
run: |
git clone --recursive https://github.com/WebAssembly/wabt
cd wabt
git submodule update --init
mkdir build; cd build
cmake ..
cmake --build .
- name: Verify wat2wasm
run: ./wabt/build/wat2wasm --version

- name: Install Python dependencies
run: pip install -r requirements.txt

- name: Clone and run tests
run: ./tests/integration/run_spec_tests.py --compiler "./wabt/build/wat2wasm" --interpreter "./wdcli" --ignore "./tests/integration/ignore.txt"
unit:
name: Run VM unit tests
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Create build folder
run: mkdir build-unit-tests

- name: Build unit tests
run: cmake .. -D BUILD_UNITTEST=ON ; cmake --build .
working-directory: build-unit-tests

- name: Run unit tests
run: ctest -VV
working-directory: build-unit-tests

11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (BUILD_ESP)
include($ENV{IDF_PATH}/tools/cmake/project.cmake "${PROJECT_BINARY_DIR}/../include")
endif (BUILD_ESP)

project(WARDuino VERSION 0.2.3)
project(WARDuino VERSION 0.3.0)

set(WARDUINO_VERSION_STRING "${PROJECT_VERSION}")
configure_file(src/config.h.in include/warduino/config.h)
Expand All @@ -52,11 +52,6 @@ if (BUILD_EMULATOR)
src/Edward/proxy_supervisor.cpp
src/Edward/RFC.cpp)

set(TEST_FRAMEWORK
tests/integration/wasm_tests.cpp
tests/integration/assertion.cpp
tests/integration/sexpr-parser/src/sexpr.c)

add_definitions(-DINFO=0)
add_definitions(-DDEBUG=0)
add_definitions(-DTRACE=0)
Expand All @@ -71,7 +66,7 @@ if (BUILD_EMULATOR)
endif (CMAKE_COMPILER_IS_GNUCXX)

# WARDuino CLI
add_executable(wdcli platforms/CLI-Emulator/main.cpp ${SOURCE_FILES} ${TEST_FRAMEWORK})
add_executable(wdcli platforms/CLI-Emulator/main.cpp ${SOURCE_FILES})
target_link_libraries(wdcli PRIVATE Threads::Threads)
target_include_directories(wdcli PRIVATE ${EXTERNAL_LIB_HEADERS} "${PROJECT_BINARY_DIR}/include")
endif (BUILD_EMULATOR)
Expand Down Expand Up @@ -119,7 +114,7 @@ if(BUILD_UNITTEST)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

set(PATH_TO_UNIT_TEST ${PROJECT_SOURCE_DIR}/tests/vm_unit_tests)
set(PATH_TO_UNIT_TEST ${PROJECT_SOURCE_DIR}/tests/unit)

file(GLOB TEST_SRC_FILES ${PATH_TO_UNIT_TEST}/*.cpp)

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=WARDuino
version=0.2.3
version=0.3.0
author=Robbert Gurdeep Singh <[email protected]>, Christophe Scholliers <[email protected]>, Tom Lauwaerts <[email protected]>, Carlos Rojas Castillo <[email protected]>, Joel Martin <[email protected]>
maintainer=Robbert Gurdeep Singh <[email protected]>, Christophe Scholliers <[email protected]>, Tom Lauwaerts <[email protected]>
sentence=A library that enables the use of WebAssembly on Arduino boards with debugging support
Expand Down
4 changes: 4 additions & 0 deletions platforms/Arduino/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
.config
Arduino.ino
*.wasm
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
// WARDuino - WebAssembly interpreter for embedded devices.
//
//
//#include <cstdio>

#include <WARDuino.h>

#include "Arduino.h"
#include "upload.h"

// unsigned int wasm_len = _tmp_warduino_upload_wasm_len;
// unsigned char* wasm = _tmp_warduino_upload_wasm;
#include "bin/upload.h"

unsigned int wasm_len = upload_wasm_len;
unsigned char* wasm = upload_wasm;
Expand Down Expand Up @@ -62,8 +57,7 @@ void loop() {
m = wac->load_module(wasm, wasm_len, {});

printf("LOADED \n\n");
uint8_t command[] = {'0', '3', '\n'};
wac->handleInterrupt(3, command);
{{PAUSED}}
xTaskCreate(startDebuggerStd, "Debug Thread", 5000, NULL, 1, NULL);
printf("START\n\n");

Expand Down
47 changes: 42 additions & 5 deletions platforms/Arduino/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
# Arduino Platform

PORT = /dev/ttyUSB0
FQBN = esp32:esp32:esp32wrover
CONFIG = .config
-include ${CONFIG}

flash:
arduino-cli upload -p $(PORT) --fqbn $(FQBN) Arduino.ino
ifdef PAUSED
COMMAND := uint8_t command[] = {'0', '3', '\\\n'}; wac->handleInterrupt(3, command);
else
COMMAND :=
endif

compile:
clean:
rm Arduino.ino -f
rm bin -rf

bin:
mkdir bin

bin/upload.h: bin
ifndef BINARY
$(error BINARY is not set. Use a .config file)
endif
cp $(BINARY) bin/upload.wasm
cd bin; xxd -i upload.wasm > upload.h

Arduino.ino: bin/upload.h Arduino.ino.template
cat Arduino.ino.template > $@
sed -i "s/{{PAUSED}}/$(COMMAND)/" $@


flash: Arduino.ino
ifndef PORT
$(error PORT is not set. Use a .config file)
endif
ifndef FQBN
$(error FQBN is not set. Use a .config file)
endif
arduino-cli upload -p $(PORT) --fqbn $(FQBN) Arduino.ino

compile: Arduino.ino
ifndef FQBN
$(error FQBN is not set. Use a .config file)
endif
arduino-cli compile --fqbn $(FQBN) Arduino.ino

monitor:
ifndef PORT
$(error PORT is not set. Use a .config file)
endif
arduino-cli monitor -p $(PORT) -c baudrate=115200

27 changes: 27 additions & 0 deletions platforms/Arduino/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Arduino platform for WARDuino

This folder contains the code for staging and flashing WARDuino with the `arduino-cli`.

To upload a program take the following steps:

1. compile your program to a `.wasm` WebAssembly binary
2. compile Arduino hexfile with:
```bash
make compile BINARY={{Path to .wasm file}} FQBN={{fqbn of target device}}
```
3. flash to device
```bash
make flash PORT={{serial port}} FQBN={{fqbn of target device}}
```

Alternatively you can pass the make arguments via a `.config` file that looks like this:

```make
PORT = /dev/ttyUSB0
FQBN = esp32:esp32:esp32wrover
PAUSED = true
BINARY = test.wasm
```

Place this file in the same directory as the `Makefile`, you can now just run `make compile`.

25 changes: 0 additions & 25 deletions platforms/Arduino/WASM.h

This file was deleted.

Loading

0 comments on commit 62aa3b5

Please sign in to comment.