This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

JLinkExe hangs in Makefile but not in terminal on Mac OS

Here are the commands I use to upload a program to the device:

JLinkExe  -device nrf51422_xxac -if swd -speed 4000 
loadbin filename.bin 0x18000 
r 
exit

It works like a charm when entered from terminal, but when added to the Makefile, it hangs after printing out last log message:

Loading: _build/nrf51422_xxac_s110.bin
JLinkExe  -device nrf51422_xxac -if swd -speed 4000
SEGGER J-Link Commander V5.10g (Compiled Jan  6 2016 13:58:14)
DLL version V5.10g, compiled Jan  6 2016 13:57:56
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Aug 28 2015 19:26:24
Hardware version: V1.00
S/N: 681121013
Emulator has Trace capability
VTref = 3.300V
Type "connect" to establish a target connection, '?' for help

So it looks like it hangs after the first JLinkExe command is executed. What is the cause of this? BTW, I am using Xcode with External Build System target to do that. Program is compiled properly.

image description

Parents
  • I managed to work around this by appliyin Apple script. I created upload.sh script file (had to have executable permissions, use chmod +x if needed). Then Makefile invokes this script instead of JLinkExe commands directly. Content of upload.sh:

    #!/bin/sh 
    osascript <<END 
    tell application "Terminal"
        do script "JLinkExe  -device nrf51422_xxac -if swd -speed 4000\nloadbin filepath.bin 0x18000\nr\nexit\n$1"
    end tell
    END
    

    Replace filepath.bin with full path where bin file is expected to be after compilation (_build subdirectory) or use environmental variables to set it for you (did not have time for this yet and will update my answer when I perfect it).

  • Yes that works - just change the run line to

    JLinkExe -if swd -device nrf51 -speed 4000 -Autoconnect 1
    

    and it will work just as it did before - no need to muck around with Applescript.

Reply Children
No Data
Related