[SOLVED] jlink script: Commands to variable

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

  • Hello,

    Thank you for your inquiry.
    You can call J-Link read and write calls directly from JLinkScript file so no command strings are needed.
    e.g.
    JLINK_MEM_ReadU32() or JLINK_MEM_WriteU32().
    How to use the wreg exec command in a JLinkScript is explained here:

    wiki.segger.com/Using_J-Link_Command_Strings


    Best regards,

    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    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 contact us per e-mail.
    Alternatively our support system can be used as well: segger.com/ticket/
  • Thanks Nino for your fast answer.
    What i did have in mind was to use a .jlink file, I didn't know about .jlinkScript.
    I don't know if the .jlinkScript is a good approach as it seems to be used to customize existing functions.

    What I want to achieve is to load and run a binary located into RAM. I am able to do it manually with Jlink commander but I'd like to automate it a bit :

    Here is what I'd like to do in pseudo code:
    U32 SPvalue ;U32 PCvalue ;
    //Halt cpu
    h
    //Load binary
    loadbin C:\tmp\bin\MyBinary.bin, 0x20010000
    //Read Stack pointer addr
    SPvalue= JLINK_MEM_ReadU32(0x04000000);
    //Read ResetHandler addr
    PCvalue= JLINK_MEM_ReadU32(0x04000004);
    //Place stack pointer according to previous read
    wreg "R13 (SP)", SPvalue
    //Reset MSPLIM
    wreg MSPLIM, 0
    //Set program counter on ResetHandler Addr.
    setPC PCvalue
    // Launch program
    go

    What is the best way to do it ?

    Thank you.
  • Hello,

    Thank you for clarifying your setup. In that case the commandfile (.jlink) is the right approach. However the scripting language here has no return values so no variables can be used.
    You would have to know them beforehand.
    Is a binary file the only output you got or do you also have the elf file output?
    In any way you could also use our universal debugger Ozone for your setup:
    segger.com/products/development-tools/ozone-j-link-debugger/
    It can be used for free with a J-Link Plus or higher and all debugger GUI actions are completely scriptable with several hook points that can be used.

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    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 contact us per e-mail.
    Alternatively our support system can be used as well: segger.com/ticket/