Native code on ChipworkX using RLP
The main language for .NET Micro Framework is managed C# code (altrough with some thinkering people got other .NET languages like VB.NET to work). Which is a powerfull yet easy to use language. In combination with Visual Studio this is what makes .NET Micro Framework unique.
The only drawback of this solution is that the managed code is interpreted while running. This takes some time. Therefore it isn’t as fast as running native code. The people at GHI found a solution for this called RLP.

- Screenshot of Wolfenstein on ChipworkX
RLP stands for Runtime Loadable Procedures. How it works? You write your native code in the compiler you want (for example the free ARM toolchain YAGARTO) and create a ELF file. This ELF file is loaded into SDRAM by C#. To access the native functions there is an Invoke command that calls the native functions with a specific set of parameters and returns an integer.
The documentation for RLP can be found in the GHI Library documentation under ChipworkX.System.RLP:
http://www.ghielectronics.com/downloads/ChipworkX/LibraryDocumentation/Index.html
Inspired to try it out I took the Raycasting tutorial from “Lode’s Computer Graphics Manual” and made a version using C# and RLP.
The native code is compiled using the YAGARTO ARM toolchain.
How the program works:
- The raycasting engine is initialized by the InitEngine routine. This routine has several parameters where the screenbuffer is the most important. The screenbuffer is a byte[] array used to copy the screen bitmap from native to managed code. byte[] arrays are passed along as reference so when the array is updated on native side the managed array is updated also
- After init the first call to RenderView is made. It may look like this function doesn’t return anything but it does by updating the screenbuffer that was passed along with the InitEngine routine. After RenderView is called the updated bitmap is flushed to the screen on the managed side.
- There are 4 InterruptPorts created for moving around. When the key is pressed the Move function is called and this function updates the internal parameters on the native side. After the Move command is invoked the RenderView is called again to update the screen.
Download:
I’ve included the Visual Studio 2008 solution below. Within this archive you will find the archive containing the native code. I’ve compiled it using the YAGARTO toolchain but it should compile without modifications on other GCC based toolchains (e.g. WinARM).
Recent Comments