Nesper is the beginning stages of porting over some wrappers for the ESP-IDF version of FreeRTOS from an internal project. You can see it here: https://github.com/elcritch/nesper
PR's or recommendations welcome! Much of the FreeRTOS API wrappers feel a bit hacky, but they appear to work with a little work.
I'm also working on including an up-to-date tcp socket server using LwIP's version of select. The example can be found here (though it's currently not compiling due to refactoring, I'm working on that): https://github.com/elcritch/esp32_nim_net_example/blob/master/socketwifi/src/server.nim (note that this is also a good updated example of using selectors and nativesockets, which is a bit hard to find for generic usage)
I'll be using this issue here to note progress on examples: https://github.com/elcritch/esp32_nim_net_example/issues/3
There is code I have for a uart <-> socket echo but it's tied in with some JSON-RPC server code, but if anyone is interested I could add it to the examples.
Nice! I'm currently playing with an ESP8266, would be awesome to see some Nim support for that too :)
Btw I created a new Discord channel called #embedded, it's relayed to #nim-embedded on Freenode as well if you or anyone else wants to join.
That’s great! I have two SparkFun ESP32 Things, and I like the platform quite a bit.
ESP-IDF has a pretty big surface area, so it seems there’d need to be quite a lot of API wrapping to make a full fledged Nim port. Besides IP sockets there’s Bluetooth, flash I/O (SPI and internal), USB, GPIO, filesystems (for SD cards), etc... But this is an exciting start.
Slightly off-topic, but I recently got a Wio Terminal, which is a new system from Seeed that has an ARM CPU, color display, d-pad and 3 buttons, accelerometer, mic and piezo speaker in a nice white case. US$30. It supports Arduino and CircuitPython, but it’d be sweet to run Nim on it.
ESP-IDF has a pretty big surface area, so it seems there’d need to be quite a lot of API wrapping to make a full fledged Nim port. Besides IP sockets there’s Bluetooth, flash I/O (SPI and internal), USB, GPIO, filesystems (for SD cards), etc... But this is an exciting start.
Yah it has a surprisingly broad set of features. That said I think of Lwip/sockets as a core requirement to really use the ESP32 since they're on of the few that require changes in the Nim stdlib.
Luckily c2nim converts most of the rest pretty quickly. Sometimes you've got to tweak the C Headers a bit (looking at you inline struct initialization). I've already got a fair bit of uart, nvs flash, and the core FreeRTOS covered. Those only took a couple of hours each, or less. Nim libs provide the rest for json, http, etc. They're not very pretty Nim interfaces but useable!
That Wio Terminal looks like a great board. Arduino libraries are pretty easy to use with Nim + ARC/ORC, though the arduino-cli is the best. You can use the "esp32" freertos/lwip with it maybe: https://wiki.seeedstudio.com/Software-FreeRTOS/ (that'd let you do tasks too)
A good place to start would be to implement CMSIS bindings.
Is that for ARM or the ESP32?
CMSIS is a vendor independant Hardware Asbtraction Layer made by ARM but usable on other architecture. It's basically a standard API for RTOS & common driver.
It's widely used in the embedded industry and you often have a C-implementation of CMSIS with commercial boards. You always have one provided with STM32 boards. Even when it's whant your board uses, it can provide the basis for how to implement a driver and have similar API on different boards.
See :
The Zephyr project, is also something to look at as it's a RTOS with defned API for networking, storage, bluetooth, crypto, file system etc. There is a port of Zephyr of the ESP32 if I'm not mistaken.
@shirleyquirk That would be interesting! It's almost there it sounds like.
@clonk Ok I've seen those before for a SAMD51 mcu I was using previously. It's outside the scope of this project as Nesper is focused on FreeRTOS/LwIP. However, there are a fair number of other boards which support FreeRTOS/LwIP (maybe SMT32*'s?), so Nesper should be useful for decent swatch of embedded boards. LwIP can also be used on Arduino boards as well, though with more effort.
It'd be great to have CMSIS wrappers, perhaps interested people can collaborate on the discord #embedded channel. The more embedded Nim can do the better IMHO!
@dom96 those boards will be great! I don't have much time to spend on those channels, but feel free to ping me here.
It's been a while, but I've been slowly expanding out Nesper and testing it. I've reached a nice milestone: it's now possible to build the entire project using Nim!
You can see the updated wifi example docs: https://github.com/elcritch/nesper/blob/master/esp-idf-examples/simplewifi/README.md
Here's the Nim file: https://github.com/elcritch/nesper/blob/master/esp-idf-examples/simplewifi/main/wifi_example_main.nim
It'd fun to compare the difference of a Nim api vs the native C api. The documentation is still lacking for the api, but most of the "Nim-ified" api's live under nesper/*.nim while esp native api's are under nesper/esp/*.nim. There's also a few tests now too.