[SOLVED] Running JLink through batch file does not work through LabVIEW

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

  • [SOLVED] Running JLink through batch file does not work through LabVIEW

    Hello,

    I have a batch file that calls JLink.exe to set it up and run a command file.

    .bat file contents

    Source Code

    1. "C:\Program Files\SEGGER\JLink_V792o\JLink.exe" -device AT91SAM4SA16C -if swd -speed 4000 -CommandFile "C:\Users\Tester\Desktop\New Board Programming\Data\J-Tag Fusion\test_jtag_full_load_new.jlink"
    2. pause


    command file contents

    Source Code

    1. connect
    2. si 1
    3. speed 4000
    4. reset
    5. halt
    6. erase 0x400000,0xFFFFFF
    7. loadbin ExampleFile.bin,0x400000
    8. exit

    When I right click the .bat file located in a folder on my desktop and run it, I have no issue with it running. When I call the .bat file in LabVIEW, I get the following error:

    J-Link>loadbin Example.bin,0x400000
    'loadbin': Performing implicit reset & halt of MCU.
    Downloading file [Sam4sRecoveryFullImage.bin]...
    Failed to open file.
    J-Link>exit

    My question is, if it is failing to open the file, is there any other way I could call that file for it to be able to work though LabVIEW?
  • Sounds like it has to do with the “working directory” (en.m.wikipedia.org/wiki/Working_directory)

    When you click the bat file, the working directory of the bat file code is the location of thw bat file.
    That working directory is inherited by JLink.exe, so when opening the relative(!) file path <Example.bin> the file is searched in the working directory (same location where the bat file is)

    When you call the bat file from within LabVIEW, the working directory is most probably the location of your LabVIEW project.
    So that working directory is inherited by the bat file and finally by JLink.exe
    Now <Example.bin> is searched where your LabVIEW project is located and not where the bat file is located.

    See here:
    forums.ni.com/t5/Example-Code/…y-in-LabVIEW/ta-p/3507703
    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.