Improve J-Link driver and introduce libjaylink.

This patch uses libjaylink which is a library to access J-Link
devices. As other tools which are not in the scope of OpenOCD also
need to access J-Link devices a library is used. A firmware upgrade
tool and an advanced configuration tool for J-Link devices are under
development.

Further versions of libjaylink will support additional features
OpenOCD could benefit from. This includes TCP/IP as additional
possibility to connect to J-Link devices as well as power tracing and
device internal communication. The latter is used to access
peripherals on some development boards (e.g EFM32 STK and DVK).

Integration of libjaylink is realized with a git submodule like
jimtcl. As libjaylink depends on libusb-1.0 only, no additional
dependency is introduced for OpenOCD.

All low-level JTAG and SWD implementations of the current driver are
left untouched and therefore no incompabilities are to be expected.

Improvements of this patch:

 * Support for more USB Product IDs, including those with the new
   scheme (0x10xx). The corresponding udev rules are also updated.
 * Device selection with serial number and USB address.
 * Adaptive clocking is now correctly implemented and only usable for
   devices with the corresponding capability.
 * The target power supply can now be switched without the need for
   changing configuration and power cycling the device.
 * Device configuration is more restrictive and only allowed if the
   required capabilities are available.
 * Device configuration now shows the changes between the current
   configuration of the device and the values that will be applied.
 * Device configuration is verified after it is written to the device
   exactly as the vendor software does.
 * Connection registration is now handled properly and checks if the
   maximum number of connections on a device is reached. This is also
   necessary for devices which are attached via USB to OpenOCD as
   some device models also support connections on TCP/IP.
 * Serial Wire Output (SWO) can now be captured. This feature is not
   documented by SEGGER however it is completely supported by
   libjaylink.

This patch and libjaylink were tested on Ubuntu 14.04 (i386),
Debian 7 (amd64), FreeBSD 10.0 (amd64) and Windows XP SP3 (32-bit)
with the following device and target configurations:

 * JTAG: J-Link v8.0, v9.0 and v9.3 with AT91SAM7S256
 * SWD: SiLabs EFM32 STK 3700 (EFM32GG990F1024)
 * SWD: J-Link v8.0, v9.0 and v9.3 with EFM32GG990F1024
 * SWD: XMC 2Go (XMC1100)
 * SWD: XMC1100 Boot Kit (XMC1100)
 * SWD: IAR Systems / Olimex Eval Board (LPC1343F)
 * SWD: Nordic Semiconductor nRF51 Dongle (nRF51422)
 * SWD: SiLabs EZR32 WSTK 6220A (EZR32WG330FG60G)

Except for Windows XP all builds are tested with Clang in addition to
GCC. This patch and libjaylink are not tested on OSX yet.

Change-Id: I8476c57d37c6091c4b892b183da682c548ca1786
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/2598
Tested-by: jenkins
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
This commit is contained in:
Marc Schink 2014-10-20 13:18:38 -04:00 committed by Freddie Chopin
parent 9a6d6b51b7
commit 442f1540d5
7 changed files with 1242 additions and 1271 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "jimtcl"]
path = jimtcl
url = http://repo.or.cz/r/jimtcl.git
[submodule "src/jtag/drivers/libjaylink"]
path = src/jtag/drivers/libjaylink
url = git://repo.or.cz/libjaylink.git

View File

@ -201,6 +201,7 @@ m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
m4_define([USB1_ADAPTERS],
[[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
[[jlink], [Segger J-Link JTAG Programmer], [JLINK]],
[[stlink], [ST-Link JTAG Programmer], [HLADAPTER_STLINK]],
[[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
[[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
@ -208,8 +209,7 @@ m4_define([USB1_ADAPTERS],
[[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]]])
m4_define([USB_ADAPTERS],
[[[jlink], [Segger J-Link JTAG Programmer], [JLINK]],
[[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
[[[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
[[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
[[aice], [Andes JTAG Programmer], [AICE]]])
@ -506,6 +506,11 @@ AC_ARG_ENABLE([internal-jimtcl],
AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
[use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
AC_ARG_ENABLE([internal-libjaylink],
AS_HELP_STRING([--disable-internal-libjaylink],
[Disable building internal libjaylink]),
[use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
build_minidriver=no
AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
if test $build_zy1000 = yes; then
@ -787,6 +792,19 @@ if test $use_internal_jimtcl = yes; then
fi
fi
if test $use_internal_libjaylink = yes; then
if test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"; then
( cd $srcdir/src/jtag/drivers/libjaylink/ && ./autogen.sh )
AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
[--enable-subproject-build])
else
AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
fi
else
PKG_CHECK_MODULES([libjaylink], [libjaylink >= 0.1],
[CFLAGS="$CFLAGS $libjaylink_CFLAGS"; LIBS="$LIBS $libjaylink_LIBS"; HAVE_LIBJAYLINK=yes], [HAVE_LIBJAYLINK=no])
fi
if test $build_remote_bitbang = yes; then
build_bitbang=yes
AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
@ -1170,6 +1188,14 @@ else
fi
AM_CONDITIONAL([HLADAPTER], [test $enable_stlink != no -o $enable_ti_icdi != no])
# Disable J-Link driver if internal libjaylink is disabled and libjaylink was
# not found by pkg-config.
if test $enable_jlink != no; then
if test $use_internal_libjaylink$HAVE_LIBJAYLINK = nono; then
enable_jlink=no
fi
fi
AM_CONDITIONAL([RELEASE], [test $build_release = yes])
AM_CONDITIONAL([PARPORT], [test $build_parport = yes])
AM_CONDITIONAL([DUMMY], [test $build_dummy = yes])
@ -1209,6 +1235,7 @@ AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
AM_CONDITIONAL([INTERNAL_JIMTCL], [test $use_internal_jimtcl = yes])
AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test $use_internal_libjaylink = yes])
# Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])

View File

@ -74,15 +74,23 @@ ATTRS{idVendor}=="0640", ATTRS{idProduct}=="002d", MODE="664", GROUP="plugdev"
# Amontec JTAGkey-HiSpeed
ATTRS{idVendor}=="0fbb", ATTRS{idProduct}=="1000", MODE="664", GROUP="plugdev"
# IAR J-Link USB
# SEGGER J-Link
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0101", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0102", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0103", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0104", MODE="664", GROUP="plugdev"
# J-Link-OB (onboard)
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0105", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0107", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0108", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1010", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1011", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1012", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1013", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1014", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1016", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1017", MODE="664", GROUP="plugdev"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1018", MODE="664", GROUP="plugdev"
# Raisonance RLink
ATTRS{idVendor}=="138e", ATTRS{idProduct}=="9000", MODE="664", GROUP="plugdev"

View File

@ -449,18 +449,17 @@ product. The driver can be configured to search for any VID/PID pair
@* Link: @url{http://www.altera.com/literature/ug/ug_usb_blstr.pdf}
@end itemize
@section USB JLINK based
There are several OEM versions of the Segger @b{JLINK} adapter. It is
@section USB J-Link based
There are several OEM versions of the SEGGER @b{J-Link} adapter. It is
an example of a microcontroller based JTAG adapter, it uses an
AT91SAM764 internally.
@itemize @bullet
@item @b{ATMEL SAMICE} Only works with ATMEL chips!
@* Link: @url{http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3892}
@item @b{SEGGER JLINK}
@item @b{SEGGER J-Link}
@* Link: @url{http://www.segger.com/jlink.html}
@item @b{Atmel SAM-ICE} (Only works with Atmel chips!)
@* Link: @url{http://www.atmel.com/tools/atmelsam-ice.aspx}
@item @b{IAR J-Link}
@* Link: @url{http://www.iar.com/en/products/hardware-debug-probes/iar-j-link/}
@end itemize
@section USB RLINK based
@ -1960,7 +1959,7 @@ Examples:
@cindex translation
If you have a configuration file for another hardware debugger
or toolset (Abatron, BDI2000, BDI3000, CCS,
Lauterbach, Segger, Macraigor, etc.), translating
Lauterbach, SEGGER, Macraigor, etc.), translating
it into OpenOCD syntax is often quite straightforward. The most tricky
part of creating a configuration script is oftentimes the reset init
sequence where e.g. PLLs, DRAM and the like is set up.
@ -2717,63 +2716,69 @@ This is a write-once setting.
@end deffn
@deffn {Interface Driver} {jlink}
Segger J-Link family of USB adapters. It currently supports JTAG and SWD transports.
SEGGER J-Link family of USB adapters. It currently supports JTAG and SWD
transports.
@quotation Compatibility Note
Segger released many firmware versions for the many harware versions they
SEGGER released many firmware versions for the many harware versions they
produced. OpenOCD was extensively tested and intended to run on all of them,
but some combinations were reported as incompatible. As a general
recommendation, it is advisable to use the latest firmware version
available for each hardware version. However the current V8 is a moving
target, and Segger firmware versions released after the OpenOCD was
target, and SEGGER firmware versions released after the OpenOCD was
released may not be compatible. In such cases it is recommended to
revert to the last known functional version. For 0.5.0, this is from
"Feb 8 2012 14:30:39", packed with 4.42c. For 0.6.0, the last known
version is from "May 3 2012 18:36:22", packed with 4.46f.
@end quotation
@deffn {Command} {jlink caps}
Display the device firmware capabilities.
@deffn {Command} {jlink hwstatus}
Display various hardware related information, for example target voltage and pin
states.
@end deffn
@deffn {Command} {jlink info}
Display various device information, like hardware version, firmware version, current bus status.
@deffn {Command} {jlink freemem}
Display free device internal memory.
@end deffn
@deffn {Command} {jlink hw_jtag} [@option{2}|@option{3}]
Set the JTAG protocol version to be used. Without argument, show the actual JTAG protocol version.
@deffn {Command} {jlink jtag} [@option{2}|@option{3}]
Set the JTAG command version to be used. Without argument, show the actual JTAG
command version.
@end deffn
@deffn {Command} {jlink config}
Display the J-Link configuration.
Display the device configuration.
@end deffn
@deffn {Command} {jlink config kickstart} [val]
Set the Kickstart power on JTAG-pin 19. Without argument, show the Kickstart configuration.
@deffn {Command} {jlink config targetpower} [@option{on}|@option{off}]
Set the target power state on JTAG-pin 19. Without argument, show the target
power state.
@end deffn
@deffn {Command} {jlink config mac_address} [@option{ff:ff:ff:ff:ff:ff}]
Set the MAC address of the J-Link Pro. Without argument, show the MAC address.
@deffn {Command} {jlink config mac} [@option{ff:ff:ff:ff:ff:ff}]
Set the MAC address of the device. Without argument, show the MAC address.
@end deffn
@deffn {Command} {jlink config ip} [@option{A.B.C.D}(@option{/E}|@option{F.G.H.I})]
Set the IP configuration of the J-Link Pro, where A.B.C.D is the IP address,
E the bit of the subnet mask and
F.G.H.I the subnet mask. Without arguments, show the IP configuration.
Set the IP configuration of the device, where A.B.C.D is the IP address, E the
bit of the subnet mask and F.G.H.I the subnet mask. Without arguments, show the
IP configuration.
@end deffn
@deffn {Command} {jlink config usb_address} [@option{0x00} to @option{0x03} or @option{0xff}]
Set the USB address; this will also change the product id. Without argument, show the USB address.
@deffn {Command} {jlink config usb} [@option{0} to @option{3}]
Set the USB address of the device. This will also change the USB Product ID
(PID) of the device. Without argument, show the USB address.
@end deffn
@deffn {Command} {jlink config reset}
Reset the current configuration.
@end deffn
@deffn {Command} {jlink config save}
Save the current configuration to the internal persistent storage.
@deffn {Command} {jlink config write}
Write the current configuration to the internal persistent storage.
@end deffn
@deffn {Config} {jlink pid} val
Set the USB PID of the interface. As a configuration command, it can be used only before 'init'.
@end deffn
@deffn {Config} {jlink serial} serial-number
Set the @var{serial-number} of the interface, in case more than one adapter is connected to the host.
If not specified, serial numbers are not considered.
@deffn {Config} {jlink usb} <@option{0} to @option{3}>
Set the USB address of the interface, in case more than one adapter is connected
to the host. If not specified, USB addresses are not considered. Device
selection via USB address is deprecated and the serial number should be used
instead.
Note that there may be leading zeros in the @var{serial-number} string
that will not show in the Segger software, but must be specified here.
Debug level 3 output contains serial numbers if there is a mismatch.
As a configuration command, it can be used only before 'init'.
@end deffn
@deffn {Config} {jlink serial} <serial number>
Set the serial number of the interface, in case more than one adapter is
connected to the host. If not specified, serial numbers are not considered.
As a configuration command, it can be used only before 'init'.
@end deffn

View File

@ -20,6 +20,22 @@ EXTRA_DIST = $(ULINK_FIRMWARE) \
DRIVERFILES =
SUBDIRS=
if JLINK
if INTERNAL_LIBJAYLINK
SUBDIRS += libjaylink
libjaylink_internal_la_SOURCES = jlink.c
libjaylink_internal_la_LIBADD = libjaylink/libjaylink/libjaylink.la
libjaylink_internal_la_CPPFLAGS = -I$(builddir)/libjaylink/libjaylink \
-I$(srcdir)/libjaylink $(AM_CPPFLAGS)
noinst_LTLIBRARIES += libjaylink_internal.la
libocdjtagdrivers_la_LIBADD += libjaylink_internal.la
else
DRIVERFILES += jlink.c
endif
endif
# Standard Driver: common files
DRIVERFILES += driver.c
@ -77,9 +93,6 @@ endif
if USBPROG
DRIVERFILES += usbprog.c
endif
if JLINK
DRIVERFILES += jlink.c
endif
if RLINK
DRIVERFILES += rlink.c rlink_speed_table.c
endif
@ -151,4 +164,10 @@ noinst_HEADERS = \
versaloon/versaloon_include.h \
versaloon/versaloon_internal.h
DIST_SUBDIRS = usb_blaster
if INTERNAL_LIBJAYLINK
DIST_SUBDIRS += libjaylink
endif
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
Subproject commit 83f6e7c4d86035c848195817251320b4b81671b0