-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1536 from lf-lang/c-zephyr-support
Add Zephyr support to the C-target
- Loading branch information
Showing
22 changed files
with
386 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: C Zephyr tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
compiler-ref: | ||
required: false | ||
type: string | ||
runtime-ref: | ||
required: false | ||
type: string | ||
use-cpp: | ||
required: false | ||
type: boolean | ||
default: false | ||
scheduler: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: zephyrprojectrtos/zephyr-build:latest | ||
options: -u root --entrypoint /bin/sh | ||
steps: | ||
- name: Install Java 17, Maven and set JAVA_HOME | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y openjdk-17-jdk | ||
sudo apt-get install -y maven | ||
echo "JAVA_HOME_17_X64=/usr/lib/jvm/java-17-openjdk-amd64" >> $GITHUB_ENV | ||
- name: Initialize zephyr | ||
run: | | ||
west init /workdir/zephyrproject --mr v3.2.0 | ||
cd /workdir/zephyrproject | ||
west update | ||
echo "ZEPHYR_BASE=/workdir/zephyrproject/zephyr" >> $GITHUB_ENV | ||
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.15.2/" >> $GITHUB_ENV | ||
- name: Check out lingua-franca repository | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: lf-lang/lingua-franca | ||
submodules: true | ||
ref: ${{ inputs.compiler-ref }} | ||
fetch-depth: 0 | ||
- name: Prepare build environment | ||
uses: ./.github/actions/prepare-build-env | ||
- name: Check out specific ref of reactor-c | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: lf-lang/reactor-c | ||
path: org.lflang/src/lib/c/reactor-c | ||
ref: ${{ inputs.runtime-ref }} | ||
if: ${{ inputs.runtime-ref }} | ||
- name: Try to get around git safe issues | ||
run: chown root:root . | ||
|
||
- name: Perform Zephyr tests for C target with default scheduler | ||
run: ./gradlew test --tests org.lflang.tests.runtime.CZephyrTest.runZephyrTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
org.lflang.tests/src/org/lflang/tests/runtime/CZephyrTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/************* | ||
Copyright (c) 2023, The University of California at Berkeley. | ||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
***************/ | ||
package org.lflang.tests.runtime; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Assumptions; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.lflang.Target; | ||
import org.lflang.tests.Configurators; | ||
import org.lflang.tests.RuntimeTest; | ||
import org.lflang.tests.TestRegistry.TestCategory; | ||
|
||
/** | ||
* Collection of Zephyr tests for the C target. | ||
* | ||
* @author Erling Rennemo Jellum <erling.r.jellum@ntnu.no> | ||
*/ | ||
public class CZephyrTest extends RuntimeTest { | ||
|
||
public CZephyrTest() { | ||
super(Target.C); | ||
} | ||
|
||
@Test | ||
public void runZephyrTests() { | ||
Assumptions.assumeTrue(isLinux(), "Zephyr tests only run on Linux"); | ||
super.runTestsFor(List.of(Target.C), | ||
Message.DESC_ZEPHYR, | ||
TestCategory.ZEPHYR::equals, Configurators::platformZephyrQemuNoFlash, | ||
false); | ||
} | ||
} | ||
|
Submodule reactor-c
updated
15 files
+1 −0 | core/CMakeLists.txt | |
+2 −0 | core/platform/Platform.cmake | |
+2 −2 | core/platform/lf_arduino_support.c | |
+1 −1 | core/platform/lf_linux_support.c | |
+1 −1 | core/platform/lf_macos_support.c | |
+1 −1 | core/platform/lf_nrf52_support.c | |
+1 −1 | core/platform/lf_windows_support.c | |
+531 −0 | core/platform/lf_zephyr_support.c | |
+9 −3 | core/reactor.c | |
+14 −2 | core/reactor_common.c | |
+0 −1 | core/threaded/reactor_threaded.c | |
+15 −5 | include/core/platform.h | |
+99 −0 | include/core/platform/lf_zephyr_board_support.h | |
+101 −0 | include/core/platform/lf_zephyr_support.h | |
+1 −1 | lingua-franca-ref.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
source "Kconfig.zephyr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
&timer0 { | ||
status = "okay"; | ||
}; |
1 change: 1 addition & 0 deletions
1
org.lflang/src/lib/platform/zephyr/boards/nrf52dk_nrf52832_lf.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_COUNTER_TIMER1=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Lingua Franca Zephyr configuration file | ||
|
||
# This is a generated file, do not edit. | ||
# To supply additional configuration parameters add an additional | ||
# configuration file to the build with | ||
# west build -b qemu_cortex_m3 -- -DOVERLAY_CONFIG=my_conf.prj | ||
|
||
# Enable printf | ||
CONFIG_PRINTK=y | ||
# Use the newlib C library | ||
CONFIG_NEWLIB_LIBC=y | ||
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y | ||
# Enable the counter API used for hi-res clock | ||
CONFIG_COUNTER=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.