Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Zephyr support for the C target #1536

Merged
merged 69 commits into from
Jan 16, 2023
Merged

Zephyr support for the C target #1536

merged 69 commits into from
Jan 16, 2023

Conversation

erlingrj
Copy link
Collaborator

@erlingrj erlingrj commented Jan 11, 2023

Adds plug-and-play support for running LF programs ontop of Zephyr RTOS. It has a dependency on Zephyr which can be met by following this simple guide. We require Zephyr version 3.2.0. A proper guide should be written on our webpage.

To compile and emulate a LF program on a Arm Cortex M3 emulation

target C {
  platform: {
    name: Zephyr
    board: qemu_cortex_m3
    flash: true
  }
}

To compile and flash onto a connected nrf52dk board

target C {
  platform: {
    name: Zephyr
    board: nrf52dk_nrf52832
    flash: true
  }
}

The code generator will create, in src-gen a project that can be compiled easily by just cding in and calling west build`.

@erlingrj erlingrj added the c Related to C target label Jan 11, 2023
@erlingrj erlingrj marked this pull request as draft January 11, 2023 02:52
@erlingrj erlingrj changed the title Draft: C zephyr support Add Zephyr support to the C-target Jan 13, 2023
@erlingrj erlingrj linked an issue Jan 13, 2023 that may be closed by this pull request
@erlingrj erlingrj marked this pull request as ready for review January 13, 2023 02:36
Copy link
Contributor

@arengarajan99 arengarajan99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, follows the Arduino approach which as long as it passes all the tests should be fine.

@petervdonovan
Copy link
Collaborator

It looks like the test failures are mostly just network issues 😢 and not actual failures.

Copy link
Collaborator

@petervdonovan petervdonovan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me. I left some comments, but none of them are important enough to justify delaying this PR.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java Outdated Show resolved Hide resolved
Path buildPath = fileConfig.getSrcGenPath().resolve("build");
String board = targetConfig.platformOptions.board;
LFCommand cmd;
if (board == null || board.startsWith("qemu")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a way to change the type of board back to an enum (as it was before this PR), and thereby to avoid having to do this sort of string-matching -- or at least, to restrict the string-matching to a single place that is not buried deep in org.lflang.generator.c. Enums can be constructed with parameters, so even though the total number of boards might be too large to enumerate, you could have a few types of boards (e.g., ARDUINO, QEMU, ...) that also come with a String that specifies the exact name of the board.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. @arengarajan99 and I will have to figure out something clever here. Or wait until it is all factored out into the package manager...

org.lflang/src/org/lflang/generator/c/CGenerator.java Outdated Show resolved Hide resolved
Co-authored-by: Peter Donovan <33707478+petervdonovan@users.noreply.github.com>
Path buildPath = fileConfig.getSrcGenPath().resolve("build");
String board = targetConfig.platformOptions.board;
LFCommand cmd;
if (board == null || board.startsWith("qemu")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. @arengarajan99 and I will have to figure out something clever here. Or wait until it is all factored out into the package manager...

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@erlingrj erlingrj merged commit 788ba74 into master Jan 16, 2023
@lhstrh lhstrh changed the title Add Zephyr support to the C-target Zephyr support for the C target Jan 26, 2023
@lhstrh lhstrh added the feature New feature label Jan 26, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
c Related to C target feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore Lingua Franca on Zephyr
4 participants