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

  • Seems like it is connecting now but it still hangs (waits or a n input) unfortunately. The only difference is that it hangs on the last console log line: "Cortex-M0 identified." instead of "Type "connect" to establish a target connection, '?' for help"

  • works for me - also working for me is using 'q' at the end instead of 'exit', or 'qc` which explicitly disconnects or putting the commands into a file and placing that filename on the end of the line instead of emitting them from the makefile. Still annoying they changed it however.

  • Well I don't know what your makefile looks like but after some more testing I pretty much can't make this hang whether I pipe the commands into JLinkExe, or put them in a file and put that on the end, or use Autoconnect or don't use Autoconnect (although Autoconnect is cleaner). This makefile for instance works with make test or make test2. Doesn't hang, exits with a clean 0 exit.

    test: 
    	echo "r\nh\nloadbin test.bin 0x00\nexit\n" |\
    	JLinkExe -if swd -device nrf51 -speed 4000
    
    xx: makefile
    	echo r\\nh\\nloadbin test.bin 0x00\\nexit\\n >> xx
    
    test2: xx
    	JLinkExe -if swd -device nrf51 -speed 4000 xx
    
    clean:
    	rm -f xx
    
Related