lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
237 stars 63 forks source link

Explore Lingua Franca on Zephyr #1262

Closed Soroosh129 closed 1 year ago

Soroosh129 commented 2 years ago

It would be a nice exploratory project to try to get Lingua Franca running in some capacity on Zephyr. Afterward, we should explore how we could utilize the features offered by Zephyr to enhance parallelism, guarantee deadlines, etc.

A potential good starting point would be to experiment with the native POSIX execution first.

lhstrh commented 2 years ago

Is there any particular hardware platform you would recommend we do this on?

Soroosh129 commented 2 years ago

This sounds like a nice starting point.

lhstrh commented 2 years ago

Hm, this page appears to describe a Windows FreeRTOS port?

Soroosh129 commented 2 years ago

The first sentence is misleading. See the section titled "Building and Executing the Demo on Linux" on that page.

georgedlu commented 2 years ago

Would you entertain Zephyr? https://docs.zephyrproject.org/latest/boards/posix/native_posix/doc/index.html

Zephyr also supports devicetree like Linux.

Soroosh129 commented 2 years ago

FreeRTOS was suggested by @edwardalee. It looks like Zephyr is also actively developed and supports quite a variety of hardware. @edwardalee, do you have a preference between FreeRTOS and Zephyr?

edwardalee commented 2 years ago

Zephyr looks very interesting. The protocol stacks it supports will prove quite useful, I think.

erlingrj commented 2 years ago

Thanks for pointing me to this. Zephyr can also be used for single-threaded. You just use 1 thread. In fact, Nordic is going full Zephyr now. Their new nRF Connect SDK is based on Zephyr and UART library etc are Zephyr device drivers. They argue that people wanting bare-metal can use Zephyr with 1 thread which gives minimal overhead. If I understand them correctly they don't support bare-metal software on their newer nRF53 chips. There is also support for an impressive number of boards already. Also the newer Arm-based Arduinos.

This might be the "platform-independent" API on which we might want to build our Reactor library. Moreover, a LF microkernel implementation could be a fork/extension of Zephyr where we re-implement threads or extend it with a new concurrent execution context, namely a Reactor.

This would, however, really tie us to Zephyr for the embedded systems. I have never programmed anything in Zephyr yet, but it seems to be a lot of hype and that it is aiming for being the Linux of MCUs,

Have you looked into Zephyr before @cmnrd ?

erlingrj commented 2 years ago

This might have been premature excitement. I have spent the afternoon playing around with Zephyr and thinking about how to run LF ontop of it, which I don't think will be very hard. The big problem is that it is not very straightforward to get accurate timing. The OS uses the systick timer for timing and sleeps etc are in msec granularity.

erlingrj commented 2 years ago

That might have been premature rejection haha. In any case, I have started the process of implementing the platform API for Zephyr. I have run simple LF programs using the Single Threaded API on the NRF52. I track the progress here. AFter discussion with Edward we think that it might indeed be promising as a "wrapper" for the most common embedded platforms. Will continue working on this.