D officially supported on Apache NuttX RTOS

Matheus Catarino matheus-catarino at hotmail.com
Sun Jun 9 23:19:44 UTC 2024


On Sunday, 9 June 2024 at 11:43:30 UTC, Sergey wrote:
>D
> For those who far away from embedding maybe you can add a 
> couple of words about this system, and which applications it 
> allows to create with D?
> I suppose only betterC mode is supported, so there is no Phobos 
> on those tiny machines?

NuttX (RTOS) is POSIX compliant. Unlike the popular FreeRTOS 
(task scheduler), NuttX is a more robust system, ideal for 
seeking a top-down view (Linux/MacOS/BSD dev).

NuttX has not only (now) integrated support for one of the D 
compilers into the settings (Kconfig). However, it will serve as 
one of the already integrated alternatives like Zig/Nim/C++/Rust.

- [Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 
BL808 SBC](https://lupyuen.codeberg.page/articles/nim.html)
- [Porting .NET nanoFramework for Linux and 
NuttX](https://microhobby.com.br/blog/2021/06/24/porting-net-nanoframework-for-linux-and-nuttx/)

The idea is to be able to interactive applications (CLI) from 
your host system (Unix-like) to NuttX without completely 
rewriting. It is also possible to develop GUI interfaces using 
LVGL or anything similar (e.g. slint-rs).

About **betterC**, it will not be an imposition of exclusivity. 
In other words, only the available example uses **betterC** as an 
initial solution.

Note that the **D.defs** configuration does not have a 
**betterC** flag (intentional decision).
https://github.com/apache/nuttx/blob/ce0c98f0fd24422af4f9acef1318eca9ac56efd7/tools/D.defs#L23

**Hello D - Makefile**
https://github.com/apache/nuttx-apps/blob/6db9d5e58235640a5419669e82bdb8c426954506/examples/hello_d/Makefile#L29

**Why? Is it possible to use DRT and phobos2?**

To support phobos it is necessary to adapt the DRT, especially 
when it involves dynamic allocation.

After Adam Ruppe's experiments to running miniDRT in Webassembly, 
another user choose to port an old Sega video-game Dreamcast 
(arch: **SH4**) using 
[tinyDRT](https://github.com/KitsunebiGames/tinyd-rt).

- [Tetris in Wasm - D runtime 
section](https://dpldocs.info/this-week-in-d/Blog.Posted_2020_08_10.html#druntime)
- https://dreamcast.wiki/D_on_Dreamcast

So, I take the opportunity to carry out some tests with the 
architectures available through NuttX (stm32/esp32/riscv/arm, 
etc...)

**Note:** NuttX also runs on WebAssembly!! Need tinyEMU (riscv64)
- [Apache NuttX RTOS in a Web Browser? Adventures with TinyEMU 
and VirtIO](https://lupyuen.github.io/articles/tinyemu)

The selling point of D that applied in the NuttX community is FFI 
with C and C++ (w/TMP). Less painful than trying to use `cxx-rs` 
or doing `extern"C"` at all!!

What prevents from porting [ETLcpp](https://www.etlcpp.com/) 
(static containers) to Dlang or making an alternative solution?

For those who already develop in C++ (embedded), they constantly 
hear about avoiding using STL.

And for those interested in learning about NuttX, there is 
mentoring support for GSOC (Google Summer of Code), this year 
Rust was chosen (previously).


More information about the Digitalmars-d-announce mailing list