Nice! NuttX seems like a handy RTOS. Note that you can should be able to enable LwIP without FreeRTOS. Most of the differences are in std/net.
mbedTLS would be great on ESP32's and other embedded platforms as well.
Hi,
Fortunately, NuttX has a POSIX-standard BSD Socket layer (apparently uIP-based), so I have access to the HTTP server. Once the SSL issue is cleared up and async/await etc. are working, I will submit a pull request.
The branch can be found here: https://github.com/centurysys/Nim
I got your asynchttpserver sample working, but I am having trouble with it because it is leaking memory for some reason.
https://github.com/elcritch/esp32_nim_net_example/blob/master/socketeth/nim/example_server.nim
The branch can be found here: https://github.com/centurysys/Nim
Nice! Taking a quick look. You might consider using the posix_other.nim rather than a full copy of the posix like lib/posix/posix_nuttx_consts.nim unless there's a lot of differences. It's a bit of preference.
I tried to run it with ioselectors_epoll with mm:orc, memory is released when memory consumption increases to some extent. EPOLL may be a good choice for NuttX.
So when using Orc it can take a while before it'll kick in. It's often enough to run out of memory before orc cycle collector is normally called. There's -d:nimStressOrc which runs orc with 10 cycles (roots?).
For embedded cases it may make sense to add a way to tweak the Orc cycle size. Alternatively you can run GC_runOrc manually at a convenient point.
You can read about them here https://github.com/nim-lang/Nim/blob/devel/doc/nimc.md#nim-for-embedded-systems
Thank you for your reply.
You might consider using the posix_other.nim rather than a full copy of the posix like > lib/posix/posix_nuttx_consts.nim unless there's a lot of differences. It's a bit of preference.
I took a diff and found the following differences in the example.
# <fcntl.h>
var F_DUPFD* {.importc: "F_DUPFD", header: "<fcntl.h>".}: cint
-var F_DUPFD_CLOEXEC* {.importc: "F_DUPFD", header: "<fcntl.h>".}: cint
+var F_DUPFD_CLOEXEC* {.importc: "F_DUPFD_CLOEXEC", header: "<fcntl.h>".}: cint
var F_GETFD* {.importc: "F_GETFD", header: "<fcntl.h>".}: cint
var F_SETFD* {.importc: "F_SETFD", header: "<fcntl.h>".}: cint
var F_GETFL* {.importc: "F_GETFL", header: "<fcntl.h>".}: cint
@@ -127,6 +127,10 @@
var O_RDWR* {.importc: "O_RDWR", header: "<fcntl.h>".}: cint
var O_WRONLY* {.importc: "O_WRONLY", header: "<fcntl.h>".}: cint
var O_CLOEXEC* {.importc: "O_CLOEXEC", header: "<fcntl.h>".}: cint
+var O_DIRECT* {.importc: "O_DIRECT", header: "<fcntl.h>".}: cint
+var O_PATH* {.importc: "O_PATH", header: "<fcntl.h>".}: cint
+var O_NOATIME* {.importc: "O_NOATIME", header: "<fcntl.h>".}: cint
+var O_TMPFILE* {.importc: "O_TMPFILE", header: "<fcntl.h>".}: cint
Like Zepher, would the following change be advisable?
when defined(nuttx):
var FOO*
I will read the documentation you provided. Thank you very much.
I took your advice, applied the changes and submitted a pull request.
https://github.com/nim-lang/Nim/pull/21372
CI seems to have passed. Could you please take a look at the contents?