diff --git a/.github/actions/pico/action.yml b/.github/actions/pico/action.yml new file mode 100644 index 00000000..a3d9dbaa --- /dev/null +++ b/.github/actions/pico/action.yml @@ -0,0 +1,30 @@ +name: Install and build Zephyr dependencies +description: Install and build Zephyr dependencies +runs: + using: "composite" + steps: + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends git cmake tar build-essential \ + gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib + shell: bash + + - name: Cache Pico SDK + id: cache-pico-sdk + uses: actions/cache@v4 + with: + path: /opt/pico-sdk + key: pico-sdk-${{ runner.os }} + + - name: Install pico-sdk + if: steps.cache-pico-sdk.outputs.cache-hit != 'true' + run: | + git clone https://github.com/raspberrypi/pico-sdk /opt/pico-sdk + echo "PICO_SDK_PATH=/opt/pico-sdk" >> $GITHUB_ENV + shell: bash + + - name: Set environment variables + run: | + echo "PICO_SDK_PATH=/opt/pico-sdk" >> $GITHUB_ENV + shell: bash \ No newline at end of file diff --git a/.github/actions/zephyr/action.yml b/.github/actions/zephyr/action.yml new file mode 100644 index 00000000..fc83fe52 --- /dev/null +++ b/.github/actions/zephyr/action.yml @@ -0,0 +1,60 @@ +name: Install and build Zephyr dependencies +description: Install and build Zephyr dependencies +runs: + using: "composite" + steps: + - name: Setup environment variables + run: | + echo "SDK_VERSION=0.16.8" >> $GITHUB_ENV + shell: bash + - name: Dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \ + ccache dfu-util device-tree-compiler wget \ + python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ + make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 + shell: bash + - name: Install West + run: pip install west + shell: bash + + - name: Cache SDK + id: cache-zephyr-sdk + uses: actions/cache@v4 + with: + path: /opt/zephyr-sdk-${{env.SDK_VERSION}} + key: zephyr-sdk-${{env.SDK_VERSION}}-${{ runner.os }} + + - name: Install Zephyr SDK + if: steps.cache-zephyr-sdk.outputs.cache-hit != 'true' + run : | + wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${{env.SDK_VERSION}}/zephyr-sdk-${{env.SDK_VERSION}}_linux-x86_64.tar.xz" + wget -O - "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${{env.SDK_VERSION}}/sha256.sum" | shasum --check --ignore-missing + sudo tar xvf "zephyr-sdk-${{env.SDK_VERSION}}_linux-x86_64.tar.xz" --directory /opt/ + shell: bash + + - name: Cache Zephyr RTOS + id: cache-zephyr-rtos + uses: actions/cache@v4 + with: + path: /opt/lf-west-template + key: lf-west-template-${{ runner.os }} + + - name: Download and install Zephyr RTOS with the lf-west-template + if: steps.cache-zephyr-rtos.outputs.cache-hit != 'true' + run: | + cd /opt + git clone https://github.com/lf-lang/lf-west-template && cd lf-west-template + west update + shell: bash + - name: Setup environment variables + run: | + cd "/opt/zephyr-sdk-${{env.SDK_VERSION}}" + sudo ./setup.sh -t all -h -c + echo "ZEPHYR_BASE=/opt/lf-west-template/deps/zephyr" >> $GITHUB_ENV + echo "ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-${{env.SDK_VERSION}}/" >> $GITHUB_ENV + cd /opt/lf-west-template + west zephyr-export + pip install -r deps/zephyr/scripts/requirements.txt + shell: bash \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58f11c88..878c3de4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,9 @@ jobs: - name: Install deps run: | sudo apt-get install lcov - - name: Setup java and gradle for compiling lfc - uses: ./.github/actions/prepare-build-env + # Commented out because we dont do LFC tests at the moment. + # - name: Setup java and gradle for compiling lfc + # uses: ./.github/actions/prepare-build-env # Uncomment to SSH into the runner. # - name: Setup upterm session # uses: lhotari/action-upterm@v1 diff --git a/.github/workflows/pico.yml b/.github/workflows/pico.yml new file mode 100644 index 00000000..c6928e77 --- /dev/null +++ b/.github/workflows/pico.yml @@ -0,0 +1,22 @@ +name: Pico examples + +on: + pull_request: + +jobs: + ci: + name: Build Pico examples + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install dependencies + uses: ./.github/actions/pico + - name: Build examples + run: | + cd examples/pico + cmake -Bbuild && cd build + make + \ No newline at end of file diff --git a/.github/workflows/zephyr.yml b/.github/workflows/zephyr.yml new file mode 100644 index 00000000..3cb88516 --- /dev/null +++ b/.github/workflows/zephyr.yml @@ -0,0 +1,21 @@ +name: Zephyr examples + +on: + pull_request: + +jobs: + ci: + name: Build zephyr examples + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install dependencies + uses: ./.github/actions/zephyr + - name: Build examples + run: | + cd examples/zephyr + ./buildAll.sh + diff --git a/README.md b/README.md index 81794ed8..3a9ef3fa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # reactor-uc `reactor-uc` is a task scheduling runtime implementing the reactor -model-of-computation target at embedded and resource-constrained 32 bit systems. +model-of-computation target at embedded and resource-constrained systems. ## Getting started diff --git a/examples/zephyr/basic_federated/federated_receiver1/src/receiver.c b/examples/zephyr/basic_federated/federated_receiver1/src/receiver.c index ab0fae7e..f7b5ccd9 100644 --- a/examples/zephyr/basic_federated/federated_receiver1/src/receiver.c +++ b/examples/zephyr/basic_federated/federated_receiver1/src/receiver.c @@ -57,6 +57,7 @@ typedef struct { TcpIpChannel chan; ConnRecv conn; FederatedInputConnection *inputs[1]; + deserialize_hook deserialize_hooks[1]; } RecvSenderBundle; void RecvSenderBundle_ctor(RecvSenderBundle *self, Reactor *parent) { @@ -65,7 +66,7 @@ void RecvSenderBundle_ctor(RecvSenderBundle *self, Reactor *parent) { self->inputs[0] = &self->conn.super; NetworkChannel *chan = &self->chan.super; - chan->open_connection(channel); + chan->open_connection(chan); lf_ret_t ret; LF_DEBUG(ENV, "Recv: Connecting"); @@ -74,8 +75,8 @@ void RecvSenderBundle_ctor(RecvSenderBundle *self, Reactor *parent) { } while (ret != LF_OK); LF_DEBUG(ENV, "Recv: Connected"); - FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, (FederatedInputConnection **)&self->inputs, 1, - NULL, 0); + FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, (FederatedInputConnection **)&self->inputs, + self->deserialize_hooks, 1, NULL, NULL, 0); } typedef struct { @@ -104,5 +105,5 @@ ENTRY_POINT_FEDERATED(MainRecv, FOREVER, true, true, 1, false) int main() { setup_led(); - lf_MainRecv_start(); + lf_start(); } \ No newline at end of file diff --git a/examples/zephyr/basic_federated/federated_receiver2/src/receiver.c b/examples/zephyr/basic_federated/federated_receiver2/src/receiver.c index 5ffaafe1..49dc182d 100644 --- a/examples/zephyr/basic_federated/federated_receiver2/src/receiver.c +++ b/examples/zephyr/basic_federated/federated_receiver2/src/receiver.c @@ -57,6 +57,7 @@ typedef struct { TcpIpChannel chan; ConnRecv conn; FederatedInputConnection *inputs[1]; + deserialize_hook deserialize_hooks[1]; } RecvSenderBundle; void RecvSenderBundle_ctor(RecvSenderBundle *self, Reactor *parent) { @@ -74,8 +75,8 @@ void RecvSenderBundle_ctor(RecvSenderBundle *self, Reactor *parent) { } while (ret != LF_OK); LF_DEBUG(ENV, "Recv: Connected"); - FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, (FederatedInputConnection **)&self->inputs, 1, - NULL, 0); + FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, (FederatedInputConnection **)&self->inputs, + self->deserialize_hooks, 1, NULL, NULL, 0); } typedef struct { @@ -104,5 +105,5 @@ ENTRY_POINT_FEDERATED(MainRecv, FOREVER, true, true, 1, false) int main() { setup_led(); - lf_MainRecv_start(); + lf_start(); } \ No newline at end of file diff --git a/examples/zephyr/basic_federated/federated_sender/src/sender.c b/examples/zephyr/basic_federated/federated_sender/src/sender.c index 1d1bbb39..9cbeb486 100644 --- a/examples/zephyr/basic_federated/federated_sender/src/sender.c +++ b/examples/zephyr/basic_federated/federated_sender/src/sender.c @@ -105,6 +105,7 @@ typedef struct { TcpIpChannel chan; ConnSender1 conn; FederatedOutputConnection *output[1]; + serialize_hook serialize_hooks[1]; } SenderRecv1Bundle; typedef struct { @@ -112,6 +113,7 @@ typedef struct { TcpIpChannel chan; ConnSender2 conn; FederatedOutputConnection *output[1]; + serialize_hook serialize_hooks[1]; } SenderRecv2Bundle; void SenderRecv1Bundle_ctor(SenderRecv1Bundle *self, Reactor *parent) { @@ -131,8 +133,8 @@ void SenderRecv1Bundle_ctor(SenderRecv1Bundle *self, Reactor *parent) { validate(ret == LF_OK); printf("Sender: Accepted 1\n"); - FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, NULL, 0, - (FederatedOutputConnection **)&self->output, 1); + FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, NULL, NULL, 0, + (FederatedOutputConnection **)&self->output, self->serialize_hooks, 1); } void SenderRecv2Bundle_ctor(SenderRecv2Bundle *self, Reactor *parent) { @@ -152,8 +154,8 @@ void SenderRecv2Bundle_ctor(SenderRecv2Bundle *self, Reactor *parent) { validate(ret == LF_OK); printf("Sender: Accepted 2\n"); - FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, NULL, 0, - (FederatedOutputConnection **)&self->output, 1); + FederatedConnectionBundle_ctor(&self->super, parent, &self->chan.super, NULL, NULL, 0, + (FederatedOutputConnection **)&self->output, self->serialize_hooks, 1); } // Reactor main typedef struct { @@ -185,6 +187,6 @@ ENTRY_POINT_FEDERATED(MainSender, FOREVER, true, true, 2, true) int main() { setup_button(); setup_led(); - action_ptr = &MainSender_main.sender.action; - lf_MainSender_start(); + action_ptr = &main_reactor.sender.action; + lf_start(); } \ No newline at end of file diff --git a/examples/zephyr/buildAll.sh b/examples/zephyr/buildAll.sh new file mode 100755 index 00000000..24a9e95c --- /dev/null +++ b/examples/zephyr/buildAll.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +# List of folders +FOLDERS=("blinky" "hello" "basic_federated/federated_sender" "basic_federated/federated_receiver1" "basic_federated/federated_receiver2" ) + +BOARD=frdm_k64f + +# Command to execute in each folder +COMMAND="west build -b $BOARD -p always" + +# Iterate over each folder and execute the command +for dir in "${FOLDERS[@]}"; do + echo "Entering $dir" + pushd $dir + $COMMAND + popd +done \ No newline at end of file