The print statements from the Jlink binary offer little additional
benefit while debugging and only clutter the output. Furthermore they
interfere with the TUI layout of GDB when one of the context layouts is
used.
If multiple debuggers are present when testing for JLinkExe version
a GUI will open to select the debugger to attach, so add -nogui
when testing for version as well.
Since J-Link V6.74, a GUI is shown when flashing from the command line.
This steals the focus of the terminal. Adding `-nogui 1` solves the
issue, but raises the minimum supported version to V6.74 (released
around June 2020).
Note that JLinkGDBServer has a slightly different `-nogui` option.
According to the documentation [1], the options are case-insensitive.
Unify all options to use a single style (lower case was the easiest).
[1] https://wiki.segger.com/J-Link_Commander
On error Jlink exits with a no error code by default.
From the JLink User Guide:
'-ExitOnError' has the same meaning as the 'exitonerror' command
'exitonerror' command
This command toggles whether J-Link Commander exits on error or not.
1: J-Link Commander will now exit on Error.
0: J-Link Commander will no longer exit on Error.
Executing 'flash/reset' without a board connected now correctly returns an
error. For 'term' it does not show an error due to the way it is handled
internally.
It also returns an error when the board fails to do an operation when it
is in a state where it cannot be flashed for example.
Get BINFILE and ELFFILE from command line instead of environment variable.
Rename 'HEXFILE' to 'BINFILE' in the script as the binary file is used.
The documentation was already talking about 'BINFILE' but 'BINFILE'
was never exported by the build system and it was using 'HEXFILE' in the
implementation.
When executing `make test` on devices using JLink, testrunner
launches `make term` which calls `jlink.sh term_rtt`. When finished
the father process is killed but `setsid` has launched JLinkExe
as another subprocess, which is not killed by `os.killpg` from
testrunner since it doesn't belong to the same group.
While running `make term` JLinkExe is expecting commands and thus
can be disturbed by other JLink commands, e.g. `make reset`.
This enable `make test` (which runs those two commands at the same
time) on target using JLinkExe as a programmer/debugger.