G400 + RLP + Keil. How?

I want to use Keil IDE to create RLP procedures for my G400. What should I put to “R/O base” and “R/W base” textboxes under Linker tab in Keil’s project options? G400 page only state “Address Range: 0xA0000000 ~ 0xA17FFFF8”, but I’m not educated enough to translate that for Keil. Could anyone help me?

I have a feeling a made it work a few months ago, but now I just cannot remember the correct configuration :frowning:

Still an exception on


:(

Just did that. Thanks in advance.

@ Simon from Vilnius - 0xA17FFFF8 is the end of the memory reserved for RLP. By setting the R/W base to this address, you are asking the compiler to place all R/W data starting at the end of the RLP memory which has the risk of overwriting memory that the system is using for other purposes.

Since the RLP memory is used for all your memory both constant (R/O) and variable (R/W) I would keep it simple initially and set both bases to the same address. Or you can set the R/W to somewhere halfway into the RLP region then check the map file to tweak the values bases on the actual amount of R/O memory you need. But personally I would keep it simple.

While I have done a lot of RLP on Spider, Cerb and Hydra I have not done any RLP work on the G400.

Thanks guys for your help, but I still get an exception on RLP.InitializeBSSRegion():

An unhandled exception of type 'System.Exception' occurred in GHI.Premium.Native.dll
    #### Exception System.Exception - 0xffffffff (1) ####
    #### Message: 
    #### GHI.Premium.Native.RLP::FindSymbol [IP: 0000] ####
    #### GHI.Premium.Native.RLP::InitializeBSSRegion [IP: 0006] ####
    #### GHI.Premium.Native.RLP::InitializeBSSRegion [IP: 000a] ####

I guess I need some help from GHI gurus…

can you post the linker’s output .map file?

also the snippet of C# source code from where you call LoadELF to where you call InitializeBSSRegion

Native function:

#include "RLP.h"

int TrivialFunction(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
 return 123;
}

Code that calls it:

    public class Program {
        public static void Main() {
            var gogo = Resources.GetBytes(Resources.BinaryResources.G400RlpTest);
            RLP.LoadELF(gogo);
            RLP.InitializeBSSRegion(gogo); //<--- dies here

            var trivialFunction = RLP.GetProcedure(gogo, "TrivialFunction");
            Debug.Print("This is trivial: " + trivialFunction.InvokeEx(new byte[0]));
        }

    }

Map file:



==============================================================================

Section Cross References



==============================================================================

Image Symbol Table

    Local Symbols

    Symbol Name                              Value     Ov Type        Size  Object(Section)

    TrivialFunction.c                        0x00000000   Number         0  trivialfunction.o ABSOLUTE
    .text                                    0xa0000000   Section        0  trivialfunction.o(.text)

    Global Symbols

    Symbol Name                              Value     Ov Type        Size  Object(Section)

    BuildAttributes$$THM_ISAv2$ARM_ISAv5$E$P$J$S$PE$A:L22$X:L11$S22$IEEE1$IW$USESV6$~STKCKD$USESV7$~SHL$OSPACE$EBA8$STANDARDLIB$REQ8$PRES8$EABIv2 0x00000000   Number         0  anon$$obj.o ABSOLUTE
    TrivialFunction                          0xa0000000   ARM Code      12  trivialfunction.o(.text)



==============================================================================

Memory Map of the image

  Image Entry point : 0xa0000000

  Load Region LR_1 (Base: 0xa0000000, Size: 0x0000000c, Max: 0xffffffff, ABSOLUTE)

    Execution Region ER_RO (Base: 0xa0000000, Size: 0x0000000c, Max: 0xffffffff, ABSOLUTE)

    Base Addr    Size         Type   Attr      Idx    E Section Name        Object

    0xa0000000   0x0000000c   Code   RO            1  * .text               trivialfunction.o


    Execution Region ER_RW (Base: 0xa1000000, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)

    **** No section assigned to this execution region ****


    Execution Region ER_ZI (Base: 0xa1000000, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)

    **** No section assigned to this execution region ****


==============================================================================

Image component sizes


      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name

        12          0          0          0          0       2002   trivialfunction.o

    ----------------------------------------------------------------------
        12          0          0          0          0       2002   Object Totals
         0          0          0          0          0          0   (incl. Generated)
         0          0          0          0          0          0   (incl. Padding)

    ----------------------------------------------------------------------
         0          0          0          0          0          0   Library Totals
         0          0          0          0          0          0   (incl. Padding)

    ----------------------------------------------------------------------

==============================================================================


      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   

        12          0          0          0          0       2002   Grand Totals
        12          0          0          0          0       2002   ELF Image Totals
        12          0          0          0          0          0   ROM Totals

==============================================================================

    Total RO  Size (Code + RO Data)                   12 (   0.01kB)
    Total RW  Size (RW Data + ZI Data)                 0 (   0.00kB)
    Total ROM Size (Code + RO Data + RW Data)         12 (   0.01kB)

==============================================================================


Keil config: MCU=SAM9x35. R/O base=0xA0000000, R/W base=0xA1000000

need to see linker script, your map file is missing two vary important symbols:

[ol]bss_start
bss_end[/ol]

I believe to get your example to run, remove the InitializeBSSRegion. In your example the size of that region is zero, so the call (if it worked) would do nothing.

For larger native functions you have two choices:

[ol]instead of InitializeBSSRegion, examine your linker map find the line: [quote]Execution Region ER_ZI (Base: 0xa1000000, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)[/quote] Then instead of InitializeBSS… put[quote] InitializeZeroRegion({Base address}, {size})[/quote]
Take a look at the linker script provided in https://www.ghielectronics.com/downloads/src/RLP_User.zip in it you will find the way the two missing symbols are created. You will need to add a similar construct to your linker script.
[/ol]
For an explanation, go to https://www.ghielectronics.com/downloads/man/Library_Documentation_v4.2/Premium/Index.html then navigate: [em]GHI.Premium.Native Namespace>RLP Class>RLP_Methods>IntializeBSSRegion Method [/em]

EDIT: enumerated methods, fixed Message throwing away non-html

1 Like

Thanks Jeff. Now I pretty much get it. This is Keil, it does not have a linker script, or it is hidden somewhere, so I cannot control those bss_start and bss_end tags. But I can look in the map file and use InitializeZeroRegion. Sweet. It works now!

Glad you got it working. I learned a lot trying to help you on this (thanks) :slight_smile:

Hello, I’m in the same situation
How did you use InitializeZeroRegion({Base address}, {size}) ?
Thanks

 elf_file = Resources.GetBytes(Resources.BinaryResources.testrlp);

            Debug.Print("Loading");
            RLP.LoadELF(elf_file);

            Debug.Print("Initializing");
            RLP.InitializeZeroRegion(0xa1000000, 0x10000);
            RLP.InitializeBSSRegion(elf_file);
            initISR = RLP.GetProcedure(elf_file, "Init");

Execution Region ER_RW (Base: 0xa1000000, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)

**** No section assigned to this execution region ****


Execution Region ER_ZI (Base: 0xa1000000, Size: 0x00000128, Max: 0xffffffff, ABSOLUTE)

Base Addr    Size         Type   Attr      Idx    E Section Name        Object

0xa1000000   0x00000060   Zero   RW           60    .bss                c_5.l(libspace.o)
0xa1000060   0x00000000   Zero   RW            2    HEAP                sam9x35.o
0xa1000060   0x000000c8   Zero   RW            1    STACK               sam9x35.o

==============================================================================

Image component sizes

  Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name

    20          0          0          0          0       2167   rlplaser.o
    32         12          0          0        200        216   sam9x35.o

----------------------------------------------------------------------
    52         12         16          0        200       2383   Object Totals
     0          0         16          0          0          0   (incl. Generated)
     0          0          0          0          0          0   (incl. Padding)

That’s your magic numbers:

Also, do not use InitializeBSSRegion() then.

Thank you for your help.
With the option “Debug information” friends it works it does not work if this option is unchecked.
The problem is that the file is too big with a few lines of code.

with code:

int Init(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
	
 
	return 123;
}
 

Work Ok :

   **** No section assigned to this execution region ****


    Execution Region ER_ZI (Base: 0xa1000000, Size: 0x00000128, Max: 0xffffffff, ABSOLUTE)

    Base Addr    Size         Type   Attr      Idx    E Section Name        Object

    0xa1000000   0x00000060   Zero   RW          242    .bss                c_5.l(libspace.o)
    0xa1000060   0x00000000   Zero   RW            2    HEAP                sam9x35.o
    0xa1000060   0x000000c8   Zero   RW            1    STACK               sam9x35.o


==============================================================================

Image component sizes


      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name

        20          0          0          0          0       2148   rlplaser.o
        32         12          0          0        200        216   sam9x35.o

    ----------------------------------------------------------------------
        52         12         16          0        200       2364   Object Totals
         0          0         16          0          0          0   (incl. Generated)
         0          0          0          0          0          0   (incl. Padding)

    ----------------------------------------------------------------------

Not Work:

    **** No section assigned to this execution region ****


    Execution Region ER_ZI (Base: 0xa1000000, Size: 0x00000128, Max: 0xffffffff, ABSOLUTE)

    Base Addr    Size         Type   Attr      Idx    E Section Name        Object

    0xa1000000   0x00000060   Zero   RW           64    .bss                c_5.l(libspace.o)
    0xa1000060   0x00000000   Zero   RW            2    HEAP                sam9x35.o
    0xa1000060   0x000000c8   Zero   RW            1    STACK               sam9x35.o


==============================================================================

Image component sizes


      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name

        20          0          0          0          0          0   rlplaser.o
        32         12          0          0        200          0   sam9x35.o

    ----------------------------------------------------------------------
        52         12         16          0        200          0   Object Totals
         0          0         16          0          0          0   (incl. Generated)
         0          0          0          0          0          0   (incl. Padding)

    ----------------------------------------------------------------------

axf file too large

static Twid twid;

/** Page buffer.*/
static uint8_t pData[PAGE_SIZE];
/**
 * \brief TWI interrupt handler. Forwards the interrupt to the TWI driver handler.
 */
static void TWI1_IrqHandler( void )
{
    TWID_Handler( &twid ) ;
}

int Init(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
	
   /* Configure TWI pins. */
    PIO_Configure(pins, PIO_LISTSIZE(pins));

    /* Enable TWI peripheral clock */
    PMC_EnablePeripheral(ID_TWI0);

    /* Configure TWI */
    TWI_ConfigureMaster(BOARD_BASE_TWI_EEPROM, TWCK, BOARD_MCK);
    TWID_Initialize(&twid, BOARD_BASE_TWI_EEPROM);

    /* Configure TWI interrupts */
    IRQ_ConfigureIT(BOARD_ID_TWI_EEPROM, 0, TWI1_IrqHandler);
    IRQ_EnableIT(BOARD_ID_TWI_EEPROM);
    /* Erase page #0 and #1 */
    //memset(pData, 0, PAGE_SIZE);
    //printf("-I- Filling page #0 with zeroes ...\n\r");
    TWID_Write(&twid, AT24C_ADDRESS, 0x0000, 2, pData, PAGE_SIZE, 0);
	return 123;
}

Map File :

Execution Region ER_ZI (Base: 0xa1000008, Size: 0x000001a8, Max: 0xffffffff, ABSOLUTE)

    Base Addr    Size         Type   Attr      Idx    E Section Name        Object

    0xa1000008   0x00000080   Zero   RW           12    .bss                rlplaser.o
    0xa1000088   0x00000060   Zero   RW          246    .bss                c_5.l(libspace.o)
    0xa10000e8   0x00000000   Zero   RW            2    HEAP                sam9x35.o
    0xa10000e8   0x000000c8   Zero   RW            1    STACK               sam9x35.o


==============================================================================

Image component sizes


      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name

        88          0          0          0          0     322669   aic.o
         0          0          0          0          0        364   async.o
      1064         12          0          0          0       4996   pio.o
       316         20          0          0          0       1136   pmc.o
       196         28         24          8        128     332220  rlplaser.o
        32         12          0          0        200        216   sam9x35.o
      1472        228          0          0          0       3988   twi.o
      1488        144          0          0          0       3452   twid.o

I’m discouraged, I looked forward to the Raptor but I’ll Give Up the map, or nothing works

  • Analog output does not work
  • I2C does not work (touchscreen CP7)
  • RLP does not work.
    I’ll take the Cobra but lacks speed.
    Sorry for my english