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

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

  • [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":

    Source Code

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

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

    Source Code

    1. 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:

    Source Code

    1. JFlash.exe -openprj%~dp0\SerialNumberDataFlash.jflash -readrange0x40100070,0x40100083 -saveas%~dp0\Data.bin
    This code returns ERRORLEVEL = 1

    What am I doing wrong?
    Images
    • readrange.png

      8.71 kB, 457×204, viewed 638 times
    • ERRORLEVEL 1.png

      5.92 kB, 481×142, viewed 411 times
  • 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:
    segger.com/downloads/jlink/#J-…twareAndDocumentationPack

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

    Or you can contact us via e-mail.
  • Hello Fabian.

    I solved the problem with "-saveas":

    Hardwariano wrote:

    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:

    Source Code

    1. set path_MAIN=%~dp0
    2. 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:

    Source Code

    1. set path_MAIN=%~dp0
    2. JFlash.exe -openprj%path_MAIN%SerialNumberDataFlash.jflash -open%path_MAIN%SerialNumberDataFlash.srec -save
    3. 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:

    Hardwariano wrote:

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

    Or you can contact us via e-mail.
  • Hello Fabian

    SEGGER - Fabian wrote:

    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.

    SEGGER - Fabian wrote:

    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,

    Hardwariano wrote:

    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.

    Hardwariano wrote:

    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:
    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.

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

    Or you can contact us via e-mail.
  • SEGGER - Fabian wrote:

    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.

    SEGGER - Fabian wrote:

    Does this answer your questions?
    Yes, it's answered so this thread can be closed.

    Thanks again for your help.
    Regards.