[SOLVED] Command line options. How to use readrange, save and saveas

  • Hi all,

    I'm using the command line option readrange to get some data stored in my MCU. It works well and shows the data read as you can see in "readrange.png":

    Code
    cd C:\Program Files (x86)\SEGGER\JLink
    JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083
    IF ERRORLEVEL 1 GOTO ERROR
    
    
    :ERROR
    echo %ERRORLEVEL%
    ECHO J-Flash ARM: Error!
    pause


    Now, I want to save that data, but it's not working.
    - Save command:

    Code
    JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083 -save

    This code doesn't return error, but it doesn't save the data on my hard drive. How can I tell the code where to store it?

    - Saveas command:

    Code
    JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083 -saveas%~dp0\Data.bin

    This code returns ERRORLEVEL = 1

    What am I doing wrong?

  • Hi,
    Thank you for your inquiry.
    Such an issue is not known to us and we were not able to reproduce it.

    Are you using the latest J-Link Software and Documentation Pack version?
    You can download it here:
    https://www.segger.com/downloads/jlin…cumentationPack

    Did you make sure that you do have write permissions for the location you want to place the data file at?
    Does it work when running J-Flash as administrator?

    Best regards,
    Fabian

    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hello Fabian.

    I solved the problem with "-saveas":

    JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083 -saveas%~dp0\Data.bin

    For some reason I don't know, JFlash didn't recognize "%~dp0", which returns the current path of the .bat file. The solution was simple:

    Code
    set path_MAIN=%~dp0
    JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083 -saveas%path_MAIN%Data.bin

    It now works well.


    Regarding "-save" command I think I misunderstood the way it works . I thought it would record a different ".srec" file, but it actually overwrote the same ".srec" file that had been opened before with "-open" command:

    Code
    set path_MAIN=%~dp0
    JFlash.exe -openprj%path_MAIN%SerialNumberDataFlash.jflash -open%path_MAIN%SerialNumberDataFlash.srec -save
    REM This overwrites "SerialNumberDataFlash.srec" after opening it

    No that I know this, I rewrite muy question: Does "-save" command work if I had not previously opened a ".srec" file with "-open" command? That's to say, If I have only used "-readrange" command to get some data from the microcontroller, as you can see below:

    JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083 -save

  • Hi,
    Good to hear, that you are up and running again.
    The "-save" command line option saves the current, altered state of the data file, if there already is one.
    Example:
    -You open a project and you open a file (e.g "data.hex")
    -You merge some content to your "data.hex" file
    -You use -save to save the changed data file.

    As you can see from the example, save has a very special use case.
    Therefore -saveas is the go-to in 99.9% of the cases.

    "-saveas" creates/overwrites a file with the current data window (or the specified range) as content.

    Does this answer your question?

    Best regards,Fabian

    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hello Fabian

    As you can see from the example, save has a very special use case.
    Therefore -saveas is the go-to in 99.9% of the cases.

    It's just what I thought after doing several tests.

    Does this answer your question?

    Yes, this answers my question.Thanks.
    I suggest including the explanation you gave me in the next version of the manual.

    I have only one more question. Is it possible to store the data read with "-readrange" in a variable to use it in the .bat program? I mean, without saving a new file (with "-saveas") and then reading it manually.

    Regards.

  • Hi,

    I suggest including the explanation you gave me in the next version of the manual.

    Thank you for the feedback. We will discuss this internally.

    Is it possible to store the data read with "-readrange" in a variable to use it in the .bat program? I

    Unfortunately, this is not possible.
    You will have to use the route over a data file, I am afraid.

    What you could do alternatively is to buy our J-Link SDK:
    https://www.segger.com/products/debug…ogy/j-link-sdk/
    It comes with a source project (in C code) of the J-Link Commander (and more) so you could alter it to fit your needs.

    Does this answer your questions?

    Best regards,
    Fabian

    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • What you could do alternatively is to buy our J-Link SDK:
    segger.com/products/debug-prob…nk/technology/j-link-sdk/
    It comes with a source project (in C code) of the J-Link Commander (and more) so you could alter it to fit your needs.

    I'll take a look at it.

    Does this answer your questions?

    Yes, it's answered so this thread can be closed.

    Thanks again for your help.
    Regards.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!