Skip to content

Conversation

centurysys
Copy link
Contributor

@centurysys centurysys commented Feb 25, 2023

Summary

Added sample application in Nim language

Impact

It allows you to create applications in the Nim language, which can be easily integrated with the C language so that you can use NuttX features in Nim right away.

  1. No need to create HAL, binding modules.
  2. Can use Nim standard libraries, external libraries.

Testing

Tested on sim, arm Cortex-A5, Cortex-M4.

  1. install choosenim, latest Nim language.

https://nim-lang.org/install_unix.html
$ choosenim devel --latest

  1. configure NuttX.

This example uses async/await, which requires the following items to be enabled

CONFIG_SCHED_CHILD_STATUS=y
CONFIG_NET=y
CONFIG_NET_SOCKOPTS=y

important:
I am sending out a pull request to clear Nim's asyncdispatch module global dispatcher at the end of the task.

nim-lang/Nim#21432

Until this accepted, the second and subsequent runs will fail.

@xiaoxiang781216
Copy link
Contributor

Please fix the nxstyle error reported here:
https://github.com/apache/nuttx-apps/actions/runs/4272067879/jobs/7438598461

@centurysys
Copy link
Contributor Author

@xiaoxiang781216
Regarding the second error, the function "NimMain()"(Fixed Name) must be called before calling the Nim process.
The name "NimMain" can be influenced via the --nimMainPrefix:prefix switch.
How should I correct this?

@xiaoxiang781216
Copy link
Contributor

Fxing "Mixed case identifier found" is optional since the mixed case can't avoid completely in some context. Anyway, you can add NimMain to the white list here: https://github.com/apache/nuttx/blob/master/tools/nxstyle.c#L500

@centurysys
Copy link
Contributor Author

Thank you very much.
I see that we need to make a change to add it to the whitelist of the repository on the nuttx OS side. Would you be willing to merge this one after I deal with that one?

@xiaoxiang781216
Copy link
Contributor

Sure.

@centurysys centurysys force-pushed the feature/support-nim-app branch from 736755d to 0a3c1c5 Compare February 26, 2023 11:16
@centurysys
Copy link
Contributor Author

Thank you for merging the changes on the OS side.
I have modified the style, is this correct?

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Feb 26, 2023

Let's see the style check report.
BTW, you can run the check offline with:
../nuttx/tools/checkpatch.sh -g HEAD~...HEAD

@jerpelea jerpelea merged commit c785e32 into apache:master Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants