www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - D officially supported on Apache NuttX RTOS

reply Matheus Catarino <matheus-catarino hotmail.com> writes:
ref.: https://x.com/MisterTechBlog/status/1798918878350950840

**Note:** Currently, ldc2 compiler only for 
riscv/arm/sim[ulator]. gdc and dmd need PR!

**Preview - qemu-armv7a:nsh**

```bash
$ qemu-system-arm -cpu cortex-a7 -nographic -M 
virt,virtualization=off,gic-version=2 -net none -chardev 
stdio,id=con,mux=on -serial chardev:con -mon 
chardev=con,mode=readline -kernel nuttx
psci_detect: Detected PSCI v1.1
nx_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS1
work_start_highpri: Starting high-priority kernel worker thread(s)
nxtask_activate: hpwork pid=1,TCB=0x4013b2d8
nx_start_application: Starting init thread
task_spawn: name=nsh_main entry=0x4010b18c file_actions=0 
attr=0x4013afbc argv=0x4013afb8
nxtask_activate: nsh_main pid=2,TCB=0x4013c690
lib_cxx_initialize: _sinit: 0x4012c000 _einit: 0x4012c000

NuttShell (NSH) NuttX-12.5.1
nsh> nx_start: CPU0: Beginning Idle Loop
nsh> hello_d
task_spawn: name=hello_d entry=0x4011e824 file_actions=0x4013d8e4 
attr=0x4013d8ec argv=0x4013d980
spawn_execattrs: Setting policy=2 priority=100 for pid=3
nxtask_activate: hello_d pid=3,TCB=0x4013dd80
Hello World, [cortex-a7]!
hello_d_main: Saying hello from the dynamically constructed 
instance
DHelloWorld.HelloWorld: CONSTRUCTION FAILED!
hello_d_main: Saying hello from the instance constructed on the 
stack
DHelloWorld.HelloWorld: Hello, World!!
nxtask_exit: hello_d pid=3,TCB=0x4013dd80
```
Jun 07
parent reply Sergey <kornburn yandex.ru> writes:
On Friday, 7 June 2024 at 12:23:54 UTC, Matheus Catarino wrote:
 ref.: https://x.com/MisterTechBlog/status/1798918878350950840

 **Note:** Currently, ldc2 compiler only for 
 riscv/arm/sim[ulator]. gdc and dmd need PR!
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?
Jun 09
parent reply Matheus Catarino <matheus-catarino hotmail.com> writes:
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).
Jun 09
parent reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
On Sunday, 9 June 2024 at 23:19:44 UTC, Matheus Catarino wrote:

 So, I take the opportunity to carry out some tests with the 
 architectures available through NuttX (stm32/esp32/riscv/arm, 
 etc...)
Official esp32 software environment (ESP IDF) internally uses FreeRTOS. Thus, if you write hello_world_LED_blink snippet and compile it by ESP IDF your binary will contain FreeRTOS
Jun 10
parent Matheus Catarino <matheus-catarino hotmail.com> writes:
On Monday, 10 June 2024 at 14:59:53 UTC, Denis Feklushkin wrote:
 Official esp32 software environment (ESP IDF) internally uses 
 FreeRTOS. Thus, if you write hello_world_LED_blink snippet and 
 compile it by ESP IDF your binary will contain FreeRTOS
Exactly! However, NuttX can replace ESP-IDF if desired. Espressif itself approves and provides an HAL for this access. (Same goes for Zephyr) https://github.com/espressif/esp-hal-3rdparty
Jun 10