RLPLite Questions

This question was originally asked on another thread but I think it got overlooked. So, I’m posting it in it’s own thread with hopes that some RLP experts will notice.
http://www.tinyclr.com/forum/topic?id=7751&page=3#msg76371

On the RLP Lite wiki page there are a couple things that are a little confusing in the example.

First…

//////////////////////////////////////
// Important note: Global variables are not initialized
// For example, this variable below does not have 123 in it. It contains a random number.
int notinit = 123;
/////////////////////////////////////

There’s no guidance here on how to properly initialize globals. Can this be done in main() or should these be passed into a function? Or should globals not be used at all?

Second…

#define DATA_SIZE 50 
int main()
{
	int i;
	unsigned char data[DATA_SIZE];
	int value[1]={0x55};
	unsigned char length[1]= {DATA_SIZE};
 
	i = RLP_MemSet(data, value, length);
	i = RLP_MemSetStdLib(data, value, length);
 
 
	while(1);
}

Is a main() loop required? Does this run all the time or at all after loaded into managed code? Is this only executed if you run it in Keil?

Also, I think the current example only works with the Hydra. Is there any guidance for compiling RLPLite for Cerberus?

If I have a RLP function that has a parameter list like this…

int ProcessImage(unsigned char *generalArray, void **args, unsigned int argsCount, unsigned int *argSize)

How would I convert that to RLPLite since it only allows void, int, & unsigned char params? Does this mean I can’t have unsigned int and should modify the function to use int instead or is there another way?

Thanks!

RLP is the same as writing C code, but without main(). Your C code or C++ should just contain functions, with vars ands def “globals” placed before the functions in the time honoured way. I have not used RLPLite yet, it seems to be limmited.
You can init vars inside the functions.

Perhaps somebody can answer this. With respect to the main() program above and the while loop, how does the C# managed code work?

This is taken from the wiki.

[quote]Native Procedures Important Notes

Native function calls suspend all other C# threads and return only when the native procedure finishes.[/quote]

EDIT:

@ Ianlee74

Check this link it appears that floats and uints can be used?

http://www.ghielectronics.com/downloads/NETMF/OSHW%20Library%20Documentation/html/b8f9960c-ad02-e26f-0cad-02f5554f6708.htm

I don’t think main() will ever be called, but I’m no expert.

@ godefroi,

If the make file was changed so that main() was the entry point it would, but i dont know what that might clobber.

Main is just a function like any other function but main is called by the runtime which doesn’t exist in RLP. So you can call main if you want which is a terrible idea.

If I understand RLP (and I don’t) there’s no normal C startup stuff happening. No main() being called, no globals being initialized, nothing like that. It’s just code loaded into memory.

Correct, runtime load able procedures :slight_smile:

But rlplite cannot do dynamic argument allocation so using args like you do in RLP won’t work? Or is the only difference is that you have to load the binary differently and specify address pointers to load functions according to the map file?

@ GUS,

I have used RLP a number of times, and use it just like C, and that means declaring variables, but only initialise them inside the functions. My comments about main() above were due to the fact that main() had been declared in the RLPLite WIKI/Tutorial which I belived to be incorrect, and was pointing out that it could not work. I agree to use main() in RLP would be a terrible idea.

Sorry, I’ve been out of town and unable to reply to anything. I’ll ask all my follow up questions at once…

In the doc you linked to, it appears that the first set of parameters can be a single array of floats, [u]ints, or [s]bytes. I’m still not sure how I would convert the example that I gave to this format. I’ll admit my C skills are a bit rusty…

This is what I always thought. The example on the wiki is very misleading by showing global vars and a main(). It makes one think that they could almost created classes within RLP and basically have a C program running within your managed code. I think this example would be a lot more useful if all the extra “stuff” was stripped out and it only showed things that are possible and useful.

And what about RLPLite on Cerberus? Is it supported? Do the instructions change? I imagine a different compiler & options are required. Are these documented anywhere yet?

@ ianlee74 - Checkout this link I think its more accurate. Then post what you need to pass to an RLP function.

http://www.ghielectronics.com/downloads/NETMF/OSHW%20Library%20Documentation/html/24f042fd-8c80-aa73-2109-794e599c43e3.htm

Looking at the docs for regular RLP it’s not obvious that you can pass a lot of arguments to the function call either. It’s listed as InvokeEx(byte[], object[]) for instance.
I would just try it the way it’s written and see if it works.

Alright, I spent the evening testing out some RLP Lite code. The wiki is a little out of whack, and some extra steps are needed.

First, download the Keil uvision software.
Pick STM32F405RG as CPU for the Cerb.

Follow the other steps (except pick different R/O R/W base as per wiki for cerb). Add a source file and what not.
Add system_stm32f4xx.c (from the C:\Keil\ARM\Startup\ST\STM32F4xx folder) to the Source Group.

Yes you DO need main. But just make it do nothing, unless you want it to do something :slight_smile:

int main() {
return 0;
}

Or else it will not compile. The stm startup stuff requires a main. There might be some tuning options needed here; we could fix the .o / .c file for this CPU not to call main.

Create your bin, and follow the rest of the wiki steps.

Test run for changing all bytes in a byte array (20,000 bytes);
managed code: 651ms
native: 1.1ms

Yep. Kick ass.

2 Likes

Awesome! I assume that was on your Cerberus? Send me your RLPLite code and I’ll test it on a Hydra just for comparison’s sake :slight_smile:

BTW, anyone can edit the wiki. So, anytime you find a problem or see anything that needs to be added. Go ahead and do it. This thread will be lost in weeks…

1 Like

Like the link in the RLP-Wiki, the link mentioned below doesn´t work anymore

Does anybody know, which link coud be used now instead?

With regards, Michael

Here is the right one:

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation%20v4.2/OSHW/html/9a85ed5d-39f8-0111-6814-d292a55e0197.htm