RLP Issue

Hello all.

The following issue code(as sample code) couldn’t call the native method of RLP.
This program abort at where calling initialize method in StartTask function.
Please teach method that to deal with it.

※ Development board: Fez Raptor
※ Version information >>> BootLoader=4.3.6 Firmware=4.3.5
※ I have thought that Rlp is impalpable.
※ I am not good at English.

Best regards!

-------------------- issue code (C Language)--------------------
RLP_Task task;

void TaskCallback(void* arg)
{
    unsigned int* count = (unsigned int*)arg;
    RLP->PostManagedEvent(*count);

    if (*count > 0)
    {
        *count -= 1;
        RLP->Task.ScheduleTimeOffset(&task, 1000000);
    }
    else
    {
        RLP->Task.Abort(&task);
    }
}

int StartTask(void** args)
{
    RLP->Task.Initialize(&task, TaskCallback, args[0], RLP_FALSE);
    RLP->Task.Schedule(&task);

    return 1;
}

-------------------- issue code (C# Language)--------------------
public static void Main()
{
    byte[] elfBuffer = Resources.GetBytes(Resources.BinaryResources.G400RLP); //Make sure to add an ELF file as a resource
    RuntimeLoadableProcedures.NativeEvent += RuntimeLoadableProcedures_NativeEvent;

    var elfImage = new RuntimeLoadableProcedures.ElfImage(elfBuffer);

    var yourFunction = elfImage.FindFunction(“YourFunc”);

    var byteArray = new byte[] { 25, 5, 0 };
    int anInteger = 5;

    var yourFuncResult = yourFunction.Invoke(anInteger, byteArray, byteArray.Length, true);

     Debug.Print("YourFunc returned " + yourFuncResult.ToString()); //Should be 5
     Debug.Print("The third element of the byte array is " + byteArray[2].ToString()); //Should be 30

    var startTask = elfImage.FindFunction(“StartTask”);
    startTask.Invoke(5);

    Thread.Sleep(-1);
}

private static void RuntimeLoadableProcedures_NativeEvent(object sender, RuntimeLoadableProcedures.NativeEventEventArgs e)
{
     Debug.Print(“We’ve received " + e.Data.ToString() + " from the native side.”); //Should be 5 to 0
}

@ shibata - Hey welcome to the forum. You should use code tags to format your code when posting


RLP_Task task;

void TaskCallback(void* arg)
{
    unsigned int* count = (unsigned int*)arg;
    RLP->PostManagedEvent(*count);

    if (*count > 0)
    {
        *count -= 1;
        RLP->Task.ScheduleTimeOffset(&task, 1000000);
    }
    else
    {
        RLP->Task.Abort(&task);
    }
}

int StartTask(void** args)
{
    RLP->Task.Initialize(&task, TaskCallback, args[0], RLP_FALSE);
    RLP->Task.Schedule(&task);

    return 1;
}


public static void Main()
{
    byte[] elfBuffer = Resources.GetBytes(Resources.BinaryResources.G400RLP); //Make sure to add an ELF file as a resource
    RuntimeLoadableProcedures.NativeEvent += RuntimeLoadableProcedures_NativeEvent;

    var elfImage = new RuntimeLoadableProcedures.ElfImage(elfBuffer);

    var yourFunction = elfImage.FindFunction("YourFunc");

    var byteArray = new byte[] { 25, 5, 0 };
    int anInteger = 5;

    var yourFuncResult = yourFunction.Invoke(anInteger, byteArray, byteArray.Length, true);

     Debug.Print("YourFunc returned " + yourFuncResult.ToString()); //Should be 5
     Debug.Print("The third element of the byte array is " + byteArray[2].ToString()); //Should be 30

    var startTask = elfImage.FindFunction("StartTask");
    startTask.Invoke(5);

    Thread.Sleep(-1);
}

private static void RuntimeLoadableProcedures_NativeEvent(object sender, RuntimeLoadableProcedures.NativeEventEventArgs e)
{
     Debug.Print("We've received " + e.Data.ToString() + " from the native side."); //Should be 5 to 0
} 

@ shibata - It looks like you are using an older firmware version. The RLP files online are for the most recent firmware version. The G400 RLP size has changed since your firmware, so if you are using the newer files, RLP extensions will fail. Try updating your firmware to the latest.

@ Mr. John Smith - Thank you. I`ll be careful.

@ John - Thank you !
However, My Fez raptor can’t update firmware.
Do you know a other way?
For example, I change RLP size(※) in LinkerScript file and suchlike. So, RLP run?
※ Please teach RLP size.

@ shibata - RLP shrank from 24MB to 23MB between your firmware and the latest, so if you reverse that change in the files we provide you should be fine.

@ John - Thank you very much!
This problem was repaired after changing RLP size(0x16FFFFC -> 0x17FFFFC).
I was helped by your support.
Thank you!