Execution of native c-code in the .NET Micro Framework

Recently I bought a Netduino N3 to create applications in C# for prototyping, but now im faced with executing native c-code in the .NET Micro Framework.
I assumed that the framework should be able to load CLI-DLL’s (where the native c-code is wrapped), but I was wrong.

Is there any chance to execute native c-code in the .NET Micro Framework?

Best regards,

Christian

We’re working on a 4.4 release that will include the (real) ability to compile firmware from source and link arbitrary c files. This will add the feature that you want, though, at least initially, you’ll likely need a Keil Compiler license to ensure a compact package size. Stay tuned.

Thank you for replying to my post.

I also did some additional investigation on this topic and I came up with the following link (Tutorial to extend the interpreter with any c files - written by Frank Zhao).

Right now im confused, does the tutorial differs to your described possibility to compile and link any c files?
It does not sound like that.

In addition to your reply, do you have an idea if this mechanism is already implemented? Is it possible to obtain a kind of tutorial or documentation how to use it?

Christian

There are two elements to Franks solution:

  • C/C++ code that is time critical
  • C# wrapper class

If you look in Franks GitHub Repository you will find two directories:

  • Files for Porting Kit
  • Files for Visual Studio

The Porting Kit files contains a few generated C files and one written by Frank. This is where the native driver sits. This is linked into the firmware.

The C# files allow your application to call into the native C/C++ code.

Hope this helps,
Mark

Thank you Mark, it helps in the manner that I’m on the right way. My intension is also to accerlate the switching timing of GPIO’s of a N3.

Unfourtnately I struggle at the intial point to compile the firmware of the device. I just follow the instructions (see link) but it still fails.

Whenever I start the build process it looks good at the beginning, in the meantime (after appr. 2-3 minutes) first build errors occurs. Afterwards the entire build finish with 104 errors.
The first error occurs while building the project “…\Netduino3\TinyCLR\TinyCLR.proj”.

Do you have any idea what might be wrong?

I’m aware that I’m mixing up the inital question with creating firmware of a Netduino device, but it would be great if you could support me at this point.

Christian

If you are not in a hurry and just want to get to grips with the build process then I would have a look at this thread on building NETMF 4.4. The build process discussed in that thread uses GCC so while the objects produced are a little larger than Keil it has the benefit that it is free.

As Bryan mentioned, there is work on going to try and simplify the process.

Regards,
Mark

I already read this article but for me it seems that my device is not supported yet “STM32F427”?
I was also wondering about the stage of completion of the NETMF 4.4 as well, is it possible to build a firmware with a user defined extension of the interpreter?

If the answer is yes in both times, then I would give him a try.

Best regards,
Christian

Work is ongoing with NETMF 4.4 and that will include the STM32F427 as this is the chip on the N3 series of boards.

I’m not sure what you mean when you say user defined extension of the interpreter. Could you provide more information / example / use case?

Regards,
Mark

That’s a pity, but thank you for your quick respond.

I guess the description

user defined extension of the interpreter

was kept to general. I essentially meant just be able to execute native code on the device. The extension of the interpreter is the way how I understand this process.

It seems so, that I have to use the 4.3 framework to compile a firmware for the N3. Unfortunately I don’t have that much time to wait for the 4.4 support of my device, maybe your are able to help me out for my previous problem?

Whenever I start the build process it looks good at the beginning, in the meantime (after appr. 2-3 minutes) first build errors occurs. Afterwards the entire build finish with 104 errors.
The first error occurs while building the project “…\Netduino3\TinyCLR\TinyCLR.proj”.

Do you have any idea what might be wrong?

Best regards,
Christian

User defined Extension

As far as I’m aware the only real way to do this at the moment is by following Frank’s example and building the extension into the firmware.

Build Error

I’ve never had much luck building the 4.3 firmware so I’m sorry but I can’t be much help here.

Work is ongoing for the 4.4 firmware so I’d watch this space.

Regards,
Mark

Hi Mark,
thank you very much for support!

I will wait for the up coming 4.4 firmware release (hopefully pretty soon :slight_smile:). In the meantime I have to find another way to get everything to work.

Best regards,
Christian

You can try the ghi firmware. They have a way to execute interops without building it into the firmware.
http://docs.ghielectronics.com/tinyclr/porting/native_interops.html
I have not tried it myself. They have no support for network on Netduino yet.

Hey guys I have been looking and it seems that v4.4 is still quite - did this ever get released? Or did I miss something?
I put this aside cause of the bug in Maple throwing an exception and not responding to web requests.

Brad

It’s still in flight at the moment.

Regards,
Mark