G400 RLP Delay function does not work

Hi All,

I am trying out the RLP support in the G400. I have used several of the functions for accessing the GPIOs and running tasks and they work fine. However when I call the Delay function my board crashes. Has anyone else had this problem?

1 Like

@ Daiz - Define crashes. Does it restart or does hang?

@ Mr. John Smith - It reboots after displaying the following on the debug serial port:

ERROR: Undef Instr
cpsr=0x6000005f
pc =0xa00009b8
lr =0xa00009bb
r0=0x00000000
r1=0x51eb851f
r2=0x00111700
r3=0x2017b130
r4=0xa000099d
r5=0x266c1b00
r6=0x266c749c
r7=0x00307640
r8=0x20612338
r9=0x20611a00
r10=0x00000000
r11=0x00000000
r12=0x00000010
sp =0x00307640
ERROR: Undef Instr
cpsr=0x6000005f
pc =0xa00009b8
lr =0xa00009bb
r0=0x00000000
r1=0x51eb851f
r2=0x00111700
r3=0x2017b130
r4=0xa000099d
r5=0x266c1b00
r6=0x266c749c
r7=0x00307640
r8=0x20612338
r9=0x20611a00
r10=0x00000000
r11=0x00000000
r12=0x00000010
sp =0x00307640
[0x00307640] : 31 00 10 00 00 1b 6c 26 07 00 01 00 64 00 00 00 1…l&…d…
[0x00307650] : 02 00 00 00 78 b6 15 20 00 00 00 a0 00 00 70 01 …x▒. …▒…p.
[0x00307660] : 00 00 00 00 00 00 00 00 f8 6f 6c 26 2c 5d 1e 20 …▒ol&,].
[0x00307670] : 00 00 00 00 f8 6f 6c 26 00 00 00 05 60 e1 18 20 …▒ol&…`▒.
[0x00307680] : 9c 74 6c 26 00 00 00 00 00 1a 61 20 00 00 00 00 ▒tl&…a …
[0x00307690] : b0 ff 6f 26 02 00 00 00 b0 ff 6f 26 04 f4 18 20 ▒▒o&…▒▒o&.▒.
[0x003076a0] : 9c 74 6c 26 00 1a 61 20 31 00 00 00 01 00 00 00 ▒tl&…a 1…
[0x003076b0] : 00 1a 61 20 d4 48 1b 20 00 00 00 03 00 00 00 03 …a ▒H. …
[0x003076c0] : 00 1a 61 20 00 1a 61 20 32 00 00 00 40 21 61 20 …a …a 2…@ !a
[0x003076d0] : 00 00 00 00 50 6d 1b 20 ff ff ff ff 00 00 00 00 …Pm. ▒▒▒▒…
[0x003076e0] : 00 00 00 00 f0 76 30 00 00 00 00 00 06 00 00 00 …▒v0…
[0x003076f0] : 10 00 01 00 58 01 70 22 08 00 00 00 9c 74 6c 26 …X.p"…▒tl&
[0x00307700] : 00 00 00 00 00 00 00 00 74 ac 6f 26 7c 00 00 00 …t▒o&|…
[0x00307710] : 84 ff ff ff 32 00 00 01 24 02 50 20 e0 9a 13 20 ▒▒▒▒2…$.P ▒.
[0x00307720] : 00 40 29 00 44 00 02 00 00 8f 16 00 00 21 00 00 .@ ).D…▒…!..
[0x00307730] : 50 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 P…

@ Daiz - Can you provide a code sample that illustrates the problem? The c# and c if you please.

Okay I created a project with the code reduced to the minimum but I do not know how to post it here so I will just paste the C and C# code.

The RLP code is just:

#include “RLP.h”

int Delay(void** args)
{
int delay = *(int *)args[0];

RLP->Delay(delay);

return 1;

}

The NetMF code is:

using System;
using System.Threading;
using GHI.Processor;
using Microsoft.SPOT;

namespace Delay
{
public class Program
{
public static void Main()
{
//It is a good idea to put some pause if working with RLP. If something goes wrong (it often does),
//you’ll have those seconds to erase the application before everything crashes.
Thread.Sleep(5000);

        //=========================================================================
        //====== Configuring RLP subsystem ========================================
        //=========================================================================
        var compiledData = Resources.GetBytes(Resources.BinaryResources.Delay);
        var elfImage = new RuntimeLoadableProcedures.ElfImage(compiledData);
        elfImage.InitializeBssRegion();

        //=========================================================================
        //====== Calling RLP function Delay =======================================
        //=========================================================================
        var Delay = elfImage.FindFunction("Delay");
        var result = Delay.Invoke();
        Debug.Print("Delay should return 1, returns " + result);

        Thread.Sleep(-1);
    }
}

}

@ Daiz - It looks like your RLP function expects a single parameter that it uses to pass to the delay function, but your C# invocation of it is not providing that parameter. Try changing the C# line “var result = Delay.Invoke();” to “var result = Delay.Invoke(50);”

@ John - When I created the small sample code I forgot the parameter. Problem still exists when you pass the parameter.

@ Daiz - How do you compile the RLP image?

@ John - I use the EmBitz 1.00 IDE. My code is based on the “RLP in Depth sample” EmBlocks code but I had to correct the RLP.h to use 0x16FFFFC instead of 0x17FFFFC.

@ Daiz - 0x16FFFFC is the correct value for the 2016 R1 and 2015 R1 SDKs, not 0x17FFFFC. 0x17FFFFC is only for before 2015 R1.

I added a Codeshare containing the complete project if anyone wants to try it out.

[url]https://www.ghielectronics.com/community/codeshare/entry/1105[/url]

@ John - Is anyone at GHI going to try the code and confirm the problem?

@ Daiz - Assuming you tested with the correct address of 0x16FFFFC, for us to be able to test it, you’ll have to get a sample working with the toolchain and process mentioned on https://www.ghielectronics.com/docs/50/rlp. If using the steps on that page works but your IDE doesn’t, something isn’t working quite right in the IDE you use. If you have a sample that fails using the system on that page, we can take a look at it.

1 Like

@ John - I tried out the Yagarto compiler and the RLP Examples form the link you provided and the RLP->Delay function worked. So I looked at the makefile from that and compared it to what the Embitz IDE was doing and noticed that the Embitz was compiling the code with thumb instructions. I changed the options in Embitz to not use thumb and the RLP->Delay function worked. What I find strange about all this is that other functions such as RLP->GPIO.EnableOutputMode, RLP->GPIO.Writepin and RLP->GPIO.Readpin worked fine when compiled with thumb but not the RLP->Delay function. My RLP binary is now twice the size but at least it works properly so I am happy.