NuttX on a Netduino Plus 2

I am going to try to port NuttX onto a Netduino Plus 2, and this is a journal of that experience.

Why am I going to do this?  Well, why not?  Haha, but seriously, this project is largely motivated from the desire to have RTOS and native-code capabilities on this board/platform.

The Netduino Plus 2 ships with dotNet Micro Framework (“NETMF”).  While this is lovely and fun in its own right — and I was a skeptic coming into it — it is as slow as you might expect from an interpreted framework.  Many if not most embedded developers are accustomed to C/asm and are taken aback by the inability to manipulate the hardware directly, or run at one machine cycle per instruction.  Or have real-time capabilities whereby they can services interrupts or read or feed datastreams with minimal latency and maximal speed.  Scripting and p-code execution environments certainly have a place in speeding development, but so does having the power to access your machine’s native capability, and so many environments provide some facility for integrating these approaches.  For example, Java has the the Java Native Interface (“JNI”).  In NETMF, there is a similar facility called ‘interop assemblies’.

I did an interop assembly on a lark (separate project, q.v.), but there are at least two problems:

  1. This requires a firmware build change.  The firmware contains the native component.  the application contains the managed component.  There is not an official way for the application to provide all that, and deploy it onto unmodified firmware.
  2. This works for creating objects in the NETMF type system, but can be awkward to integrate more deeply, and the interface between native and managed is weaker than JNI.

So, initially I thought about making an interop to proxy dynamically loaded native code (like providing a ‘dll’ capability), but then I thought about instead doing a port of NETMF onto an RTOS, and letting the RTOS handle those parts.  I did some research and found that this was not a new idea, but no one to wit had actually done it.  The NETMF apparently can run on another OS (the emulator apparently works this way), and there was a project to put it on top of Linux.  So, I thought this might be a useful approach — and maybe much richer than the ‘dll emulation’ approach.

My first though was FreeRTOS, which is well-respected, has existing ports for this processor (STM32F405), and is, well, free.  It’s also friendly on the memory footprint, and I’ve used it before.  However, I ultimately decided to give NuttX a try.  NuttX’s philosophy is to present a Linuxian system model that should be more accessible to programmers.  It’s less friendly on the memory footprint, but still within a couple 10s of K for something replete with file systems and networking.  Also, there is an existing port for the STM32F4Discovery, which I could cannibalize, and an existing driver for the ENC28J60 Ethernet controller that I will be needed.  Also, why not?

So I decided to do this project in two phases:

  1. Port NuttX to Netduino Plus 2
    As a goal, just the OS and its execution environment.  This will result in something of value in its own right, and you could happily develop applications within this framework.
  2. Port NETMF onto NuttX
    Make a ‘solution’ that runs on NuttX.  My thinking is the Linuxian programming environment might make this more natural.  I could be wrong but that is my present thinking.

So, today, I am off to downloading codebases and setting up build environments….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s