Greetings, I've been working on [Nephyr](https://github.com/EmbeddedNim/nephyr) 
a wrapper around the Zephyr RTOS! Zephyr is a fantastic truly open source 
initiative that has backing from multiple hardware vendors including many of 
the biggest ones like Nordic, TI, NXP, and Intel among others. The project is 
part of the Linux foundation and draws upon a lot of the Linux kernel's best 
practices and includes built in testing and CI. Bringing Nim lets us program 
modern MCU's / dev boards from all those vendors.

For a TLDR: Nephyr is still relatively young, but surprisingly stable when 
running. Still be patient as it'll require direct flashing boards and 
understanding Zephyr board setup. However, there's also a QEMU emulator. 
Feedback would be great and feel free to file issues. The recommended start for 
now is to clone/copy 
[nephyr_example_app](https://github.com/EmbeddedNim/nephyr_example_app) and 
check the readme. I'll try to get the QEMU version setup and running this next 
week/weekend.

Nephyr is already functional and in testing at my company as a key part of our 
embedded stack. My goal there is to show that Nim is a stable, powerful, and 
efficient way to program microcontrollers. Especially for professional embedded 
development (but hobbiests as well!). It's hard to truly explain to people 
exactly how much tedious work is required in "professional" embedded 
development work. Those in the field are largely numb to it, and the mantra of 
"but C works!" is strong for a lot of reasons. People are used to writing 
hundreds of lines of often tedious and error-prone C code to accomplish simple 
tasks like serializing JSON. While it works, it's not fast either in programmer 
effort or often even in runtime speed.

I believe Zephyr is a great choice for this purpose (as opposed to a pure Nim 
option, alas) since it includes support for dozens of MCU boards and platforms. 
Though, it does this by building on Linux's 
[Devicetree](https://docs.zephyrproject.org/latest/guides/dts/index.html). This 
adds a layer of indirection that can be frustrating to experienced embedded 
devs and confusing to newcomers, but is well worth learning. It essentially 
_[maps](https://forum.nim-lang.org/postActivity.xml#maps) out how the hardware 
is wired and makes it a snap to configure how a board is wired. In contrast to 
FreeRTOS, Zephyr provides a full suite of first-class subsystems for 
communicating over bluetooth, canbus, wifi, etc. That includes all the drivers 
required for them to work. While Zephyr is still relatively young as an OSS 
project, it has enabled me to run the exact same Nim code on 4-5 different 
MCU's from different vendors including 2 different Ethernet options.

One of Nephyr's primary goals is to provide an easier to use wrapper around 
Zephyr with sane defaults (for the device trees, etc) while still allowing full 
access to the RTOS for professional work. For example, Nephyr supports MCUBoot 
with a basic JSON-RPC method for uploading firmwares over-the-air. Figuring out 
these steps from the docs can be a daunting task! I have been using the 
[Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062) for 
a lot development work as it's fairly fast and includes a decent bit of ram. 
But NXP's LPC boards work, as do a lot of STM boards. Unfortunately, there's no 
RP2040 support in Zephyr (yet).

It'd be awesome to see if we could get some community projects like displays or 
neopixels working! I've not had much time to do "fun" projects with it yet. But 
I'd love to support people who are interested. You can find me here or contact 
me via the email on my GitHub though sometimes I take a while to respond back. 

Reply via email to