[ANSWERED] JLink script files - memory access

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [ANSWERED] JLink script files - memory access

    Hi there,

    I want to build some kind of script that tests the RAM and perhaps writes some values into registers to enable different peripherals.

    Initially I thought I could do that through C script file API functions, perhaps in SetupTarget(). But the documentation is pretty slim, I couldn't find a way how to access the memory. In documentation says that inside this routine "May use MEM_ API functions". But, where are these MEM_* routines?

    So, is it possible to write/read memory from C scripts, in a loop, and check its validity? If not, how can I do that?

    The CPU is Cortex-A9, MB86R11 from Fujistsu.

    Thanks,
    Cristian.
  • Hi Christian,


    thanks for pointing that out.
    We will update the manual accordingly.

    The following MEM_APi functions are available:
    int JLINK_MEM_WriteU32(Addr, val)
    int JLINK_MEM_WriteU16(Addr, val)
    int JLINK_MEM_WriteU8(Addr, val)

    unsigned int JLINK_MEM_ReadU32(Addr)
    unsigned int JLINK_MEM_ReadU16(Addr)
    unsigned int JLINK_MEM_ReadU8(Addr)

    The write functions return -1 on error, >=0 is O.K.
    The read function return value read at the specified address.

    Best regards,
    Niklas
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Niklas,


    Thanks for the information. However, I've encounter another problem. I'm parsing the RAM with the write and read routines, but after a while I'm getting Segmentation fault. Here is my code:
    (sorry for the indentation, but the /code or /c is horribly displayed).


    void SetupTarget(void)
    {
    unsigned int value;
    value = 0;

    unsigned int count;
    unsigned int addr;
    unsigned int to_write;

    addr = 0x80000000;
    to_write = 0x55555555;
    count = 1 * 1024 * 1024;

    Report("Started RAM check...");

    while(count > 0)
    {
    JLINK_MEM_WriteU32(addr, to_write);
    if(to_write != JLINK_MEM_ReadU32(addr))
    {
    Report1("problem at addr ", addr);
    count = 1;
    }

    Report1("addr2 ", addr);

    addr = addr + 4;
    count = count - 1;
    }

    Report1("Stopped at addr ", addr);
    }


    For start addr=0x80000000, the console output is:
    [...]
    addr 0x80004550
    addr 0x80004554
    addr 0x80004558
    addr 0x8000455C
    Segmentation fault


    For start addr=0x80004000, the console output is
    [...]
    addr 0x80008550
    addr 0x80008554
    addr 0x80008558
    addr 0x8000855C
    Segmentation fault


    For start addr=0x80010000, the console output is
    [...]
    addr 0x80014550
    addr 0x80014554
    addr 0x80014558
    addr 0x8001455C
    Segmentation fault


    Tried on windows, but the result is the same. I'm running on:
    SEGGER J-Link Commander V6.10n (Compiled Nov 18 2016 17:39:47)
    DLL version V6.10n, compiled Nov 18 2016 17:39:39

    Connecting to J-Link via USB...O.K.
    Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
    Hardware version: V8.00