[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

    Code
    "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"
    pause

    command file contents

    Code
    connect
    si 1
    speed 4000
    reset
    halt
    erase 0x400000,0xFFFFFF
    loadbin ExampleFile.bin,0x400000
    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” (https://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:
    https://forums.ni.com/t5/Example-Cod…EW/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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

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