cmsis-dap: add initial cmsis-dap support
This is based on work from: https://github.com/TheShed/OpenOCD-CMSIS-DAP/tree/cmsis-dap Main changes include moving over to using HIDAPI rather than libusb-1.0 and cleaning up to merge into master. Support for reset using srst has also been added. It has been tested on all the mbed boards as well as the Freedom board from Freescale. These boards only implement SWD mode, however JTAG mode has been tested with a Keil ULINK2 and a stm32 target - but requires a lot more work. Change-Id: I96d5ee1993bc9c0526219ab754c5aad3b55d812d Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com> Reviewed-on: http://openocd.zylin.com/1542 Tested-by: jenkins__archive__
parent
4bff54ccf4
commit
4dc8cd201c
20
configure.ac
20
configure.ac
|
@ -209,6 +209,9 @@ m4_define([USB0_ADAPTERS],
|
||||||
[[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
|
[[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
|
||||||
[[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]]])
|
[[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]]])
|
||||||
|
|
||||||
|
m4_define([HIDAPI_ADAPTERS],
|
||||||
|
[[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP]]])
|
||||||
|
|
||||||
#========================================
|
#========================================
|
||||||
# FTD2XXX support comes in 4 forms.
|
# FTD2XXX support comes in 4 forms.
|
||||||
# (1) win32 - via a zip file
|
# (1) win32 - via a zip file
|
||||||
|
@ -367,7 +370,7 @@ m4_define([AC_ARG_ADAPTERS], [
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_ARG_ADAPTERS([USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS], [auto])
|
AC_ARG_ADAPTERS([USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS, HIDAPI_ADAPTERS], [auto])
|
||||||
|
|
||||||
AC_ARG_ENABLE([parport],
|
AC_ARG_ENABLE([parport],
|
||||||
AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
|
AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
|
||||||
|
@ -751,7 +754,7 @@ else
|
||||||
AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
|
AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$use_internal_jimtcl" = yes; then
|
if test $use_internal_jimtcl = yes; then
|
||||||
if test -f "$srcdir/jimtcl/configure.ac"; then
|
if test -f "$srcdir/jimtcl/configure.ac"; then
|
||||||
AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
|
AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
|
||||||
else
|
else
|
||||||
|
@ -1103,6 +1106,15 @@ PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
|
||||||
|
|
||||||
PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
|
PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
|
||||||
|
|
||||||
|
for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
|
||||||
|
PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
|
||||||
|
use_hidapi=yes
|
||||||
|
break
|
||||||
|
],[
|
||||||
|
use_hidapi=no
|
||||||
|
])
|
||||||
|
done
|
||||||
|
|
||||||
m4_define([PROCESS_ADAPTERS], [
|
m4_define([PROCESS_ADAPTERS], [
|
||||||
m4_foreach([adapter], [$1], [
|
m4_foreach([adapter], [$1], [
|
||||||
if test $2; then
|
if test $2; then
|
||||||
|
@ -1124,6 +1136,7 @@ m4_define([PROCESS_ADAPTERS], [
|
||||||
PROCESS_ADAPTERS([USB1_ADAPTERS], [$use_libusb1 = yes], [libusb-1.x])
|
PROCESS_ADAPTERS([USB1_ADAPTERS], [$use_libusb1 = yes], [libusb-1.x])
|
||||||
PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o $use_libusb0 = yes], [libusb-1.x or libusb-0.1])
|
PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o $use_libusb0 = yes], [libusb-1.x or libusb-0.1])
|
||||||
PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], [libusb-0.1])
|
PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], [libusb-0.1])
|
||||||
|
PROCESS_ADAPTERS([HIDAPI_ADAPTERS], [$use_hidapi = yes], [hidapi])
|
||||||
|
|
||||||
if test $enable_stlink != no -o $enable_ti_icdi != no; then
|
if test $enable_stlink != no -o $enable_ti_icdi != no; then
|
||||||
AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
|
AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
|
||||||
|
@ -1165,6 +1178,7 @@ AM_CONDITIONAL([IS_MINGW], [test $is_mingw = yes])
|
||||||
AM_CONDITIONAL([IS_WIN32], [test $is_win32 = yes])
|
AM_CONDITIONAL([IS_WIN32], [test $is_win32 = yes])
|
||||||
AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = yes])
|
AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = yes])
|
||||||
AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
|
AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
|
||||||
|
AM_CONDITIONAL([CMSIS_DAP], [test $use_hidapi = yes])
|
||||||
|
|
||||||
AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
|
AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
|
||||||
AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
|
AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
|
||||||
|
@ -1290,7 +1304,7 @@ echo
|
||||||
echo
|
echo
|
||||||
echo OpenOCD configuration summary
|
echo OpenOCD configuration summary
|
||||||
echo --------------------------------------------------
|
echo --------------------------------------------------
|
||||||
m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS],
|
m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS, HIDAPI_ADAPTERS],
|
||||||
[echo -n m4_format(["%-40s"], ADAPTER_DESC([adapter]))
|
[echo -n m4_format(["%-40s"], ADAPTER_DESC([adapter]))
|
||||||
case $ADAPTER_VAR([adapter]) in
|
case $ADAPTER_VAR([adapter]) in
|
||||||
auto)
|
auto)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# export LIBUSB1_SRC=/path/to/libusb-1.0
|
# export LIBUSB1_SRC=/path/to/libusb-1.0
|
||||||
|
# export HIDAPI_SRC=/path/to/hidapi
|
||||||
# export OPENOCD_CONFIG="--enable-..."
|
# export OPENOCD_CONFIG="--enable-..."
|
||||||
# cd /work/dir
|
# cd /work/dir
|
||||||
# /path/to/openocd/contrib/cross-build.sh <host-triplet>
|
# /path/to/openocd/contrib/cross-build.sh <host-triplet>
|
||||||
|
@ -36,13 +37,16 @@ WORK_DIR=$PWD
|
||||||
## Source code paths, customize as necessary
|
## Source code paths, customize as necessary
|
||||||
: ${OPENOCD_SRC:="`dirname "$0"`/.."}
|
: ${OPENOCD_SRC:="`dirname "$0"`/.."}
|
||||||
: ${LIBUSB1_SRC:=/path/to/libusb}
|
: ${LIBUSB1_SRC:=/path/to/libusb}
|
||||||
|
: ${HIDAPI_SRC:=/path/to/hidapi}
|
||||||
|
|
||||||
OPENOCD_SRC=`readlink -m $OPENOCD_SRC`
|
OPENOCD_SRC=`readlink -m $OPENOCD_SRC`
|
||||||
LIBUSB1_SRC=`readlink -m $LIBUSB1_SRC`
|
LIBUSB1_SRC=`readlink -m $LIBUSB1_SRC`
|
||||||
|
HIDAPI_SRC=`readlink -m $HIDAPI_SRC`
|
||||||
|
|
||||||
HOST_TRIPLET=$1
|
HOST_TRIPLET=$1
|
||||||
BUILD_DIR=$WORK_DIR/$HOST_TRIPLET-build
|
BUILD_DIR=$WORK_DIR/$HOST_TRIPLET-build
|
||||||
LIBUSB1_BUILD_DIR=$BUILD_DIR/libusb1
|
LIBUSB1_BUILD_DIR=$BUILD_DIR/libusb1
|
||||||
|
HIDAPI_BUILD_DIR=$BUILD_DIR/hidapi
|
||||||
OPENOCD_BUILD_DIR=$BUILD_DIR/openocd
|
OPENOCD_BUILD_DIR=$BUILD_DIR/openocd
|
||||||
|
|
||||||
## Root of host file tree
|
## Root of host file tree
|
||||||
|
@ -90,6 +94,17 @@ $LIBUSB1_CONFIG
|
||||||
make
|
make
|
||||||
make install DESTDIR=$SYSROOT
|
make install DESTDIR=$SYSROOT
|
||||||
|
|
||||||
|
# hidapi build & install into sysroot
|
||||||
|
if [ -d $HIDAPI_SRC ] ; then
|
||||||
|
mkdir -p $HIDAPI_BUILD_DIR
|
||||||
|
cd $HIDAPI_BUILD_DIR
|
||||||
|
$HIDAPI_SRC/configure --build=`$HIDAPI_SRC/config.guess` --host=$HOST_TRIPLET \
|
||||||
|
--with-sysroot=$SYSROOT --prefix=$PREFIX \
|
||||||
|
$HIDAPI_CONFIG
|
||||||
|
make
|
||||||
|
make install DESTDIR=$SYSROOT
|
||||||
|
fi
|
||||||
|
|
||||||
# OpenOCD build & install into sysroot
|
# OpenOCD build & install into sysroot
|
||||||
mkdir -p $OPENOCD_BUILD_DIR
|
mkdir -p $OPENOCD_BUILD_DIR
|
||||||
cd $OPENOCD_BUILD_DIR
|
cd $OPENOCD_BUILD_DIR
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ACTION!="add|change", GOTO="openocd_rules_end"
|
ACTION!="add|change", GOTO="openocd_rules_end"
|
||||||
SUBSYSTEM!="usb|tty", GOTO="openocd_rules_end"
|
SUBSYSTEM!="usb|tty|hidraw", GOTO="openocd_rules_end"
|
||||||
|
|
||||||
# Olimex ARM-USB-OCD
|
# Olimex ARM-USB-OCD
|
||||||
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="0003", MODE="664", GROUP="plugdev"
|
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="0003", MODE="664", GROUP="plugdev"
|
||||||
|
@ -89,4 +89,16 @@ ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="664", GROUP="plugdev"
|
||||||
# opendous and estick
|
# opendous and estick
|
||||||
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="204f", MODE="664", GROUP="plugdev"
|
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="204f", MODE="664", GROUP="plugdev"
|
||||||
|
|
||||||
|
# mbed CMSIS-DAP
|
||||||
|
ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="664", GROUP="plugdev"
|
||||||
|
KERNEL=="hidraw*", ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="664", GROUP="plugdev"
|
||||||
|
|
||||||
|
# Freescale Freedom Board CMSIS-DAP
|
||||||
|
ATTRS{idVendor}=="c251", ATTRS{idProduct}=="f002", MODE="664", GROUP="plugdev"
|
||||||
|
KERNEL=="hidraw*", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="f002", MODE="664", GROUP="plugdev"
|
||||||
|
|
||||||
|
# Keil ULINK2 CMSIS-DAP
|
||||||
|
ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2722", MODE="664", GROUP="plugdev"
|
||||||
|
KERNEL=="hidraw*", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2722", MODE="664", GROUP="plugdev"
|
||||||
|
|
||||||
LABEL="openocd_rules_end"
|
LABEL="openocd_rules_end"
|
||||||
|
|
|
@ -490,6 +490,10 @@ Texas Instruments has an adapter called @b{ICDI}.
|
||||||
It is not to be confused with the FTDI based adapters that were originally fitted to their
|
It is not to be confused with the FTDI based adapters that were originally fitted to their
|
||||||
evaluation boards. This is the adapter fitted to the Stellaris LaunchPad.
|
evaluation boards. This is the adapter fitted to the Stellaris LaunchPad.
|
||||||
|
|
||||||
|
@section USB CMSIS-DAP based
|
||||||
|
ARM has released a interface standard called CMSIS-DAP that simplifies connecting
|
||||||
|
debuggers to ARM Cortex based targets @url{http://www.keil.com/support/man/docs/dapdebug/dapdebug_introduction.htm}.
|
||||||
|
|
||||||
@section USB Other
|
@section USB Other
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item @b{USBprog}
|
@item @b{USBprog}
|
||||||
|
@ -2541,6 +2545,23 @@ and a specific set of GPIOs is used.
|
||||||
@c chooses among list of bit configs ... only one option
|
@c chooses among list of bit configs ... only one option
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@deffn {Interface Driver} {cmsis-dap}
|
||||||
|
CMSIS-DAP compliant based adapter.
|
||||||
|
|
||||||
|
@deffn {Config Command} {cmsis_dap_vid_pid} [vid pid]+
|
||||||
|
The vendor ID and product ID of the CMSIS-DAP device. If not specified
|
||||||
|
known default values are used.
|
||||||
|
Currently, up to eight [@var{vid}, @var{pid}] pairs may be given, e.g.
|
||||||
|
@example
|
||||||
|
cmsis_dap_vid_pid 0xc251 0xf001 0x0d28 0x0204
|
||||||
|
@end example
|
||||||
|
@end deffn
|
||||||
|
|
||||||
|
@deffn {Command} {cmsis-dap info}
|
||||||
|
Display various device information, like hardware version, firmware version, current bus status.
|
||||||
|
@end deffn
|
||||||
|
@end deffn
|
||||||
|
|
||||||
@deffn {Interface Driver} {dummy}
|
@deffn {Interface Driver} {dummy}
|
||||||
A dummy software-only driver for debugging.
|
A dummy software-only driver for debugging.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
@ -3135,6 +3156,11 @@ Wire Control Register (WCR).
|
||||||
No parameters: displays current settings.
|
No parameters: displays current settings.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@subsection CMSIS-DAP Transport
|
||||||
|
@cindex CMSIS-DAP
|
||||||
|
CMSIS-DAP is an ARM-specific transport that is used to connect to
|
||||||
|
compilant debuggers.
|
||||||
|
|
||||||
@subsection SPI Transport
|
@subsection SPI Transport
|
||||||
@cindex SPI
|
@cindex SPI
|
||||||
@cindex Serial Peripheral Interface
|
@cindex Serial Peripheral Interface
|
||||||
|
|
|
@ -75,7 +75,7 @@ libopenocd_la_LIBADD = \
|
||||||
$(top_builddir)/src/rtos/librtos.la \
|
$(top_builddir)/src/rtos/librtos.la \
|
||||||
$(top_builddir)/src/helper/libhelper.la \
|
$(top_builddir)/src/helper/libhelper.la \
|
||||||
$(LIBFTDI_LIBS) $(MINGWLDADD) \
|
$(LIBFTDI_LIBS) $(MINGWLDADD) \
|
||||||
$(LIBUSB1_LIBS) $(LIBUSB0_LIBS)
|
$(HIDAPI_LIBS) $(LIBUSB1_LIBS) $(LIBUSB0_LIBS)
|
||||||
|
|
||||||
STARTUP_TCL_SRCS = \
|
STARTUP_TCL_SRCS = \
|
||||||
$(srcdir)/helper/startup.tcl \
|
$(srcdir)/helper/startup.tcl \
|
||||||
|
|
|
@ -134,8 +134,6 @@ static int jtag_speed;
|
||||||
|
|
||||||
static struct jtag_interface *jtag;
|
static struct jtag_interface *jtag;
|
||||||
|
|
||||||
const struct swd_driver *swd;
|
|
||||||
|
|
||||||
/* configuration */
|
/* configuration */
|
||||||
struct jtag_interface *jtag_interface;
|
struct jtag_interface *jtag_interface;
|
||||||
|
|
||||||
|
@ -1824,6 +1822,8 @@ void adapter_assert_reset(void)
|
||||||
jtag_add_reset(0, 1);
|
jtag_add_reset(0, 1);
|
||||||
} else if (transport_is_swd())
|
} else if (transport_is_swd())
|
||||||
swd_add_reset(1);
|
swd_add_reset(1);
|
||||||
|
else if (transport_is_cmsis_dap())
|
||||||
|
swd_add_reset(1); /* FIXME */
|
||||||
else if (get_current_transport() != NULL)
|
else if (get_current_transport() != NULL)
|
||||||
LOG_ERROR("reset is not supported on %s",
|
LOG_ERROR("reset is not supported on %s",
|
||||||
get_current_transport()->name);
|
get_current_transport()->name);
|
||||||
|
@ -1837,6 +1837,8 @@ void adapter_deassert_reset(void)
|
||||||
jtag_add_reset(0, 0);
|
jtag_add_reset(0, 0);
|
||||||
else if (transport_is_swd())
|
else if (transport_is_swd())
|
||||||
swd_add_reset(0);
|
swd_add_reset(0);
|
||||||
|
else if (transport_is_cmsis_dap())
|
||||||
|
swd_add_reset(0); /* FIXME */
|
||||||
else if (get_current_transport() != NULL)
|
else if (get_current_transport() != NULL)
|
||||||
LOG_ERROR("reset is not supported on %s",
|
LOG_ERROR("reset is not supported on %s",
|
||||||
get_current_transport()->name);
|
get_current_transport()->name);
|
||||||
|
|
|
@ -6,7 +6,8 @@ libocdjtagdrivers_la_LIBADD =
|
||||||
libocdjtagdrivers_la_SOURCES = \
|
libocdjtagdrivers_la_SOURCES = \
|
||||||
$(DRIVERFILES)
|
$(DRIVERFILES)
|
||||||
|
|
||||||
libocdjtagdrivers_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBUSB1_CFLAGS) $(LIBUSB0_CFLAGS)
|
libocdjtagdrivers_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBUSB1_CFLAGS) \
|
||||||
|
$(LIBUSB0_CFLAGS) $(HIDAPI_CFLAGS)
|
||||||
|
|
||||||
ULINK_FIRMWARE = $(srcdir)/OpenULINK
|
ULINK_FIRMWARE = $(srcdir)/OpenULINK
|
||||||
|
|
||||||
|
@ -122,6 +123,10 @@ if OPENJTAG
|
||||||
DRIVERFILES += openjtag.c
|
DRIVERFILES += openjtag.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if CMSIS_DAP
|
||||||
|
DRIVERFILES += cmsis_dap_usb.c
|
||||||
|
endif
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
bitbang.h \
|
bitbang.h \
|
||||||
bitq.h \
|
bitq.h \
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -302,8 +302,6 @@ struct jtag_interface {
|
||||||
|
|
||||||
extern const char *jtag_only[];
|
extern const char *jtag_only[];
|
||||||
|
|
||||||
extern const struct swd_driver *swd;
|
|
||||||
|
|
||||||
void adapter_assert_reset(void);
|
void adapter_assert_reset(void);
|
||||||
void adapter_deassert_reset(void);
|
void adapter_deassert_reset(void);
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,9 @@ extern struct jtag_interface aice_interface;
|
||||||
#if BUILD_BCM2835GPIO == 1
|
#if BUILD_BCM2835GPIO == 1
|
||||||
extern struct jtag_interface bcm2835gpio_interface;
|
extern struct jtag_interface bcm2835gpio_interface;
|
||||||
#endif
|
#endif
|
||||||
|
#if BUILD_CMSIS_DAP == 1
|
||||||
|
extern struct jtag_interface cmsis_dap_interface;
|
||||||
|
#endif
|
||||||
#endif /* standard drivers */
|
#endif /* standard drivers */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,6 +227,9 @@ struct jtag_interface *jtag_interfaces[] = {
|
||||||
#if BUILD_BCM2835GPIO == 1
|
#if BUILD_BCM2835GPIO == 1
|
||||||
&bcm2835gpio_interface,
|
&bcm2835gpio_interface,
|
||||||
#endif
|
#endif
|
||||||
|
#if BUILD_CMSIS_DAP == 1
|
||||||
|
&cmsis_dap_interface,
|
||||||
|
#endif
|
||||||
#endif /* standard drivers */
|
#endif /* standard drivers */
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,11 +110,17 @@ struct swd_driver {
|
||||||
*/
|
*/
|
||||||
int (*write_reg)(uint8_t cmd, uint32_t value);
|
int (*write_reg)(uint8_t cmd, uint32_t value);
|
||||||
|
|
||||||
/* XXX START WITH enough to:
|
/**
|
||||||
* init (synch mode, WCR)
|
* Synchronous block read of an AP or DP register.
|
||||||
* for async, TRN > 1
|
*
|
||||||
* read IDCODE from DP
|
* @param cmd with APnDP/RnW/addr/parity bits
|
||||||
*/
|
* @param number of reads from register to be executed
|
||||||
|
* @param buffer to store data read from register
|
||||||
|
*
|
||||||
|
* @return SWD_ACK_* code for the transaction
|
||||||
|
* or (negative) fault code
|
||||||
|
*/
|
||||||
|
int (*read_block)(uint8_t cmd, uint32_t blocksize, uint8_t *buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures data collection from the Single-wire
|
* Configures data collection from the Single-wire
|
||||||
|
@ -135,5 +141,6 @@ int swd_init_reset(struct command_context *cmd_ctx);
|
||||||
void swd_add_reset(int req_srst);
|
void swd_add_reset(int req_srst);
|
||||||
|
|
||||||
bool transport_is_swd(void);
|
bool transport_is_swd(void);
|
||||||
|
bool transport_is_cmsis_dap(void);
|
||||||
|
|
||||||
#endif /* SWD_H */
|
#endif /* SWD_H */
|
||||||
|
|
|
@ -59,8 +59,6 @@ static const Jim_Nvp nvp_jtag_tap_event[] = {
|
||||||
{ .name = NULL, .value = -1 }
|
{ .name = NULL, .value = -1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct jtag_interface *jtag_interface;
|
|
||||||
|
|
||||||
struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
|
struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
|
||||||
{
|
{
|
||||||
const char *cp = Jim_GetString(o, NULL);
|
const char *cp = Jim_GetString(o, NULL);
|
||||||
|
|
|
@ -91,6 +91,7 @@ ARM_DEBUG_SRC = \
|
||||||
arm_adi_v5.c \
|
arm_adi_v5.c \
|
||||||
adi_v5_jtag.c \
|
adi_v5_jtag.c \
|
||||||
adi_v5_swd.c \
|
adi_v5_swd.c \
|
||||||
|
adi_v5_cmsis_dap.c \
|
||||||
embeddedice.c \
|
embeddedice.c \
|
||||||
trace.c \
|
trace.c \
|
||||||
etb.c \
|
etb.c \
|
||||||
|
|
|
@ -0,0 +1,344 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2013 by mike brown *
|
||||||
|
* mike@theshedworks.org.uk *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2013 by Spencer Oliver *
|
||||||
|
* spen@spen-soft.co.uk *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Utilities to support ARM "CMSIS-DAP", The CoreSight Debug Access Port.
|
||||||
|
* This is coupled to recent versions of ARM's "CoreSight" debug framework.
|
||||||
|
* This specific code is a transport level interface, with
|
||||||
|
* "target/arm_adi_v5.[hc]" code understanding operation semantics,
|
||||||
|
* shared with the SWD & JTAG transports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "arm.h"
|
||||||
|
#include "arm_adi_v5.h"
|
||||||
|
#include <helper/time_support.h>
|
||||||
|
|
||||||
|
#include <transport/transport.h>
|
||||||
|
#include <jtag/interface.h>
|
||||||
|
|
||||||
|
#include <jtag/swd.h>
|
||||||
|
|
||||||
|
#define CMSIS_CMD_DP (0 << 0) /* set only for AP access */
|
||||||
|
#define CMSIS_CMD_AP (1 << 0) /* set only for AP access */
|
||||||
|
#define CMSIS_CMD_READ (1 << 1) /* set only for read access */
|
||||||
|
#define CMSIS_CMD_WRITE (0 << 1) /* set only for read access */
|
||||||
|
#define CMSIS_CMD_A32(n) ((n)&0x0C) /* bits A[3:2] of register addr */
|
||||||
|
#define CMSIS_CMD_VAL_MATCH (1 << 4) /* Value Match */
|
||||||
|
#define CMSIS_CMD_MATCH_MSK (1 << 5) /* Match Mask */
|
||||||
|
|
||||||
|
/* YUK! - but this is currently a global.... */
|
||||||
|
extern struct jtag_interface *jtag_interface;
|
||||||
|
|
||||||
|
static int (cmsis_dap_queue_ap_abort)(struct adiv5_dap *dap, uint8_t *ack)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_ap_abort");
|
||||||
|
|
||||||
|
/* FIXME: implement this properly cmsis-dap has DAP_WriteABORT()
|
||||||
|
* for now just hack @ everything */
|
||||||
|
return jtag_interface->swd->write_reg(
|
||||||
|
(CMSIS_CMD_DP | CMSIS_CMD_WRITE | CMSIS_CMD_A32(DP_ABORT)), 0x1e);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmsis_dap_queue_dp_read(struct adiv5_dap *dap, unsigned reg, uint32_t *data)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_dp_read %d", reg);
|
||||||
|
|
||||||
|
int retval = jtag_interface->swd->read_reg(
|
||||||
|
(CMSIS_CMD_DP | CMSIS_CMD_READ | CMSIS_CMD_A32(reg)), data);
|
||||||
|
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
/* fault response */
|
||||||
|
uint8_t ack = retval & 0xff;
|
||||||
|
cmsis_dap_queue_ap_abort(dap, &ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmsis_dap_queue_idcode_read(struct adiv5_dap *dap, uint8_t *ack, uint32_t *data)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_idcode_read");
|
||||||
|
|
||||||
|
int retval = cmsis_dap_queue_dp_read(dap, DP_IDCODE, data);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
*ack = retval;
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int (cmsis_dap_queue_dp_write)(struct adiv5_dap *dap, unsigned reg, uint32_t data)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_dp_write %d 0x%08" PRIx32, reg, data);
|
||||||
|
|
||||||
|
/* setting the ORUNDETECT bit causes issues for some targets,
|
||||||
|
* disable until we find out why */
|
||||||
|
if (reg == DP_CTRL_STAT) {
|
||||||
|
LOG_DEBUG("disabling overrun detection");
|
||||||
|
data &= ~CORUNDETECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int retval = jtag_interface->swd->write_reg(
|
||||||
|
(CMSIS_CMD_DP | CMSIS_CMD_WRITE | CMSIS_CMD_A32(reg)), data);
|
||||||
|
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
/* fault response */
|
||||||
|
uint8_t ack = retval & 0xff;
|
||||||
|
cmsis_dap_queue_ap_abort(dap, &ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Select the AP register bank matching bits 7:4 of reg. */
|
||||||
|
static int cmsis_dap_ap_q_bankselect(struct adiv5_dap *dap, unsigned reg)
|
||||||
|
{
|
||||||
|
uint32_t select_ap_bank = reg & 0x000000F0;
|
||||||
|
|
||||||
|
if (select_ap_bank == dap->ap_bank_value)
|
||||||
|
return ERROR_OK;
|
||||||
|
|
||||||
|
dap->ap_bank_value = select_ap_bank;
|
||||||
|
select_ap_bank |= dap->ap_current;
|
||||||
|
|
||||||
|
return cmsis_dap_queue_dp_write(dap, DP_SELECT, select_ap_bank);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int (cmsis_dap_queue_ap_read)(struct adiv5_dap *dap, unsigned reg, uint32_t *data)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_ap_read %d", reg);
|
||||||
|
|
||||||
|
int retval = cmsis_dap_ap_q_bankselect(dap, reg);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
retval = jtag_interface->swd->read_reg(
|
||||||
|
(CMSIS_CMD_AP | CMSIS_CMD_READ | CMSIS_CMD_A32(reg)), data);
|
||||||
|
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
/* fault response */
|
||||||
|
uint8_t ack = retval & 0xff;
|
||||||
|
cmsis_dap_queue_ap_abort(dap, &ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int (cmsis_dap_queue_ap_write)(struct adiv5_dap *dap, unsigned reg, uint32_t data)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_ap_write %d 0x%08" PRIx32, reg, data);
|
||||||
|
|
||||||
|
/* TODO: CSW_DBGSWENABLE (bit31) causes issues for some targets
|
||||||
|
* disable until we find out why */
|
||||||
|
if (reg == AP_REG_CSW)
|
||||||
|
data &= ~CSW_DBGSWENABLE;
|
||||||
|
|
||||||
|
int retval = cmsis_dap_ap_q_bankselect(dap, reg);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
retval = jtag_interface->swd->write_reg(
|
||||||
|
(CMSIS_CMD_AP | CMSIS_CMD_WRITE | CMSIS_CMD_A32(reg)), data);
|
||||||
|
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
/* fault response */
|
||||||
|
uint8_t ack = retval & 0xff;
|
||||||
|
cmsis_dap_queue_ap_abort(dap, &ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int (cmsis_dap_queue_ap_read_block)(struct adiv5_dap *dap, unsigned reg,
|
||||||
|
uint32_t blocksize, uint8_t *buffer)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_queue_ap_read_block 0x%08" PRIx32, blocksize);
|
||||||
|
|
||||||
|
int retval = jtag_interface->swd->read_block(
|
||||||
|
(CMSIS_CMD_AP | CMSIS_CMD_READ | CMSIS_CMD_A32(AP_REG_DRW)),
|
||||||
|
blocksize, buffer);
|
||||||
|
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
/* fault response */
|
||||||
|
uint8_t ack = retval & 0xff;
|
||||||
|
cmsis_dap_queue_ap_abort(dap, &ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Executes all queued DAP operations. */
|
||||||
|
static int cmsis_dap_run(struct adiv5_dap *dap)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_run");
|
||||||
|
/* FIXME: for now the CMSIS-DAP interface hard-wires a zero-size queue. */
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct dap_ops cmsis_dap_ops = {
|
||||||
|
.is_swd = true,
|
||||||
|
.queue_idcode_read = cmsis_dap_queue_idcode_read,
|
||||||
|
.queue_dp_read = cmsis_dap_queue_dp_read,
|
||||||
|
.queue_dp_write = cmsis_dap_queue_dp_write,
|
||||||
|
.queue_ap_read = cmsis_dap_queue_ap_read,
|
||||||
|
.queue_ap_write = cmsis_dap_queue_ap_write,
|
||||||
|
.queue_ap_read_block = cmsis_dap_queue_ap_read_block,
|
||||||
|
.queue_ap_abort = cmsis_dap_queue_ap_abort,
|
||||||
|
.run = cmsis_dap_run,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct command_registration cmsis_dap_commands[] = {
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Set up SWD and JTAG targets identically, unless/until
|
||||||
|
* infrastructure improves ... meanwhile, ignore all
|
||||||
|
* JTAG-specific stuff like IR length for SWD.
|
||||||
|
*
|
||||||
|
* REVISIT can we verify "just one SWD DAP" here/early?
|
||||||
|
*/
|
||||||
|
.name = "newdap",
|
||||||
|
.jim_handler = jim_jtag_newtap,
|
||||||
|
.mode = COMMAND_CONFIG,
|
||||||
|
.help = "declare a new CMSIS-DAP"
|
||||||
|
},
|
||||||
|
COMMAND_REGISTRATION_DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct command_registration cmsis_dap_handlers[] = {
|
||||||
|
{
|
||||||
|
.name = "cmsis-dap",
|
||||||
|
.mode = COMMAND_ANY,
|
||||||
|
.help = "cmsis_dap command group",
|
||||||
|
.chain = cmsis_dap_commands,
|
||||||
|
},
|
||||||
|
COMMAND_REGISTRATION_DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
static int cmsis_dap_select(struct command_context *ctx)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_select");
|
||||||
|
|
||||||
|
int retval = register_commands(ctx, NULL, cmsis_dap_handlers);
|
||||||
|
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
/* FIXME: This needs a real overhaul!! FIXME
|
||||||
|
* be sure driver is in SWD mode; start
|
||||||
|
* with hardware default TRN (1), it can be changed later
|
||||||
|
* we use a bogus 'swd' driver to implement cmsis-dap as it is quite similar */
|
||||||
|
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
if (!swd || !swd->read_reg || !swd->write_reg || !swd->init) {
|
||||||
|
LOG_ERROR("no SWD driver?");
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = swd->init(1);
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
LOG_ERROR("unable to init CMSIS-DAP driver");
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmsis_dap_init(struct command_context *ctx)
|
||||||
|
{
|
||||||
|
struct target *target = get_current_target(ctx);
|
||||||
|
struct arm *arm = target_to_arm(target);
|
||||||
|
struct adiv5_dap *dap = arm->dap;
|
||||||
|
uint32_t idcode;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
LOG_DEBUG("CMSIS-ADI: cmsis_dap_init");
|
||||||
|
|
||||||
|
/* Force the DAP's ops vector for CMSIS-DAP mode.
|
||||||
|
* messy - is there a better way? */
|
||||||
|
arm->dap->ops = &cmsis_dap_ops;
|
||||||
|
|
||||||
|
/* FIXME validate transport config ... is the
|
||||||
|
* configured DAP present (check IDCODE)?
|
||||||
|
* Is *only* one DAP configured?
|
||||||
|
*
|
||||||
|
* MUST READ IDCODE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Note, debugport_init() does setup too */
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
if (!swd || !swd->read_reg || !swd->write_reg || !swd->init) {
|
||||||
|
LOG_ERROR("no SWD driver?");
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int retval = swd->init(1);
|
||||||
|
if (retval != ERROR_OK) {
|
||||||
|
LOG_ERROR("unable to init CMSIS-DAP driver");
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t ack;
|
||||||
|
|
||||||
|
status = cmsis_dap_queue_idcode_read(dap, &ack, &idcode);
|
||||||
|
|
||||||
|
if (status == ERROR_OK)
|
||||||
|
LOG_INFO("IDCODE 0x%08" PRIx32, idcode);
|
||||||
|
|
||||||
|
/* force clear all sticky faults */
|
||||||
|
cmsis_dap_queue_ap_abort(dap, &ack);
|
||||||
|
|
||||||
|
/* this is a workaround to get polling working */
|
||||||
|
jtag_add_reset(0, 0);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct transport cmsis_dap_transport = {
|
||||||
|
.name = "cmsis-dap",
|
||||||
|
.select = cmsis_dap_select,
|
||||||
|
.init = cmsis_dap_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void cmsis_dap_constructor(void) __attribute__((constructor));
|
||||||
|
static void cmsis_dap_constructor(void)
|
||||||
|
{
|
||||||
|
transport_register(&cmsis_dap_transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if the current debug session
|
||||||
|
* is using CMSIS-DAP as its transport.
|
||||||
|
*/
|
||||||
|
bool transport_is_cmsis_dap(void)
|
||||||
|
{
|
||||||
|
return get_current_transport() == &cmsis_dap_transport;
|
||||||
|
}
|
|
@ -55,10 +55,16 @@
|
||||||
|
|
||||||
#include <jtag/swd.h>
|
#include <jtag/swd.h>
|
||||||
|
|
||||||
|
/* YUK! - but this is currently a global.... */
|
||||||
|
extern struct jtag_interface *jtag_interface;
|
||||||
|
|
||||||
static int swd_queue_dp_read(struct adiv5_dap *dap, unsigned reg,
|
static int swd_queue_dp_read(struct adiv5_dap *dap, unsigned reg,
|
||||||
uint32_t *data)
|
uint32_t *data)
|
||||||
{
|
{
|
||||||
/* REVISIT status return vs ack ... */
|
/* REVISIT status return vs ack ... */
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
assert(swd);
|
||||||
|
|
||||||
return swd->read_reg(swd_cmd(true, false, reg), data);
|
return swd->read_reg(swd_cmd(true, false, reg), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +83,9 @@ static int (swd_queue_dp_write)(struct adiv5_dap *dap, unsigned reg,
|
||||||
uint32_t data)
|
uint32_t data)
|
||||||
{
|
{
|
||||||
/* REVISIT status return vs ack ... */
|
/* REVISIT status return vs ack ... */
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
assert(swd);
|
||||||
|
|
||||||
return swd->write_reg(swd_cmd(false, false, reg), data);
|
return swd->write_reg(swd_cmd(false, false, reg), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +95,9 @@ static int (swd_queue_ap_read)(struct adiv5_dap *dap, unsigned reg,
|
||||||
{
|
{
|
||||||
/* REVISIT APSEL ... */
|
/* REVISIT APSEL ... */
|
||||||
/* REVISIT status return ... */
|
/* REVISIT status return ... */
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
assert(swd);
|
||||||
|
|
||||||
return swd->read_reg(swd_cmd(true, true, reg), data);
|
return swd->read_reg(swd_cmd(true, true, reg), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +106,9 @@ static int (swd_queue_ap_write)(struct adiv5_dap *dap, unsigned reg,
|
||||||
{
|
{
|
||||||
/* REVISIT APSEL ... */
|
/* REVISIT APSEL ... */
|
||||||
/* REVISIT status return ... */
|
/* REVISIT status return ... */
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
assert(swd);
|
||||||
|
|
||||||
return swd->write_reg(swd_cmd(false, true, reg), data);
|
return swd->write_reg(swd_cmd(false, true, reg), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +200,6 @@ int dap_to_swd(struct target *target)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
COMMAND_HANDLER(handle_swd_wcr)
|
COMMAND_HANDLER(handle_swd_wcr)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -280,7 +293,6 @@ static const struct command_registration swd_handlers[] = {
|
||||||
|
|
||||||
static int swd_select(struct command_context *ctx)
|
static int swd_select(struct command_context *ctx)
|
||||||
{
|
{
|
||||||
struct target *target = get_current_target(ctx);
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = register_commands(ctx, NULL, swd_handlers);
|
retval = register_commands(ctx, NULL, swd_handlers);
|
||||||
|
@ -288,6 +300,8 @@ static int swd_select(struct command_context *ctx)
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
const struct swd_driver *swd = jtag_interface->swd;
|
||||||
|
|
||||||
/* be sure driver is in SWD mode; start
|
/* be sure driver is in SWD mode; start
|
||||||
* with hardware default TRN (1), it can be changed later
|
* with hardware default TRN (1), it can be changed later
|
||||||
*/
|
*/
|
||||||
|
@ -296,14 +310,20 @@ static int swd_select(struct command_context *ctx)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = swd->init(1);
|
retval = swd->init(1);
|
||||||
if (retval != ERROR_OK) {
|
if (retval != ERROR_OK) {
|
||||||
LOG_DEBUG("can't init SWD driver");
|
LOG_DEBUG("can't init SWD driver");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force DAP into SWD mode (not JTAG) */
|
/* force DAP into SWD mode (not JTAG) */
|
||||||
retval = dap_to_swd(target);
|
/*retval = dap_to_swd(target);*/
|
||||||
|
|
||||||
|
if (ctx->current_target) {
|
||||||
|
/* force DAP into SWD mode (not JTAG) */
|
||||||
|
struct target *target = get_current_target(ctx);
|
||||||
|
retval = dap_to_swd(target);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -316,6 +336,10 @@ static int swd_init(struct command_context *ctx)
|
||||||
uint32_t idcode;
|
uint32_t idcode;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
/* Force the DAP's ops vector for SWD mode.
|
||||||
|
* messy - is there a better way? */
|
||||||
|
arm->dap->ops = &swd_dap_ops;
|
||||||
|
|
||||||
/* FIXME validate transport config ... is the
|
/* FIXME validate transport config ... is the
|
||||||
* configured DAP present (check IDCODE)?
|
* configured DAP present (check IDCODE)?
|
||||||
* Is *only* one DAP configured?
|
* Is *only* one DAP configured?
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# This is an Freescale Freedom eval board with a single MKL25Z128VLK4 chip.
|
||||||
|
# http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KL25Z
|
||||||
|
#
|
||||||
|
|
||||||
|
source [find interface/cmsis-dap.cfg]
|
||||||
|
|
||||||
|
# increase working area to 16KB
|
||||||
|
set WORKAREASIZE 0x4000
|
||||||
|
|
||||||
|
# chip name
|
||||||
|
set CHIPNAME MKL25Z128VLK4
|
||||||
|
|
||||||
|
source [find target/kl25.cfg]
|
|
@ -0,0 +1,13 @@
|
||||||
|
# This is an mbed eval board with a single NXP LPC11U24 chip.
|
||||||
|
# http://mbed.org/handbook/mbed-NXP-LPC11U24
|
||||||
|
#
|
||||||
|
|
||||||
|
source [find interface/cmsis-dap.cfg]
|
||||||
|
|
||||||
|
# increase working area to 8KB
|
||||||
|
set WORKAREASIZE 0x2000
|
||||||
|
|
||||||
|
# chip name
|
||||||
|
set CHIPNAME lpc11u24
|
||||||
|
|
||||||
|
source [find target/lpc11uxx.cfg]
|
|
@ -0,0 +1,7 @@
|
||||||
|
# This is an mbed eval board with a single NXP LPC1768 chip.
|
||||||
|
# http://mbed.org/handbook/mbed-NXP-LPC1768
|
||||||
|
#
|
||||||
|
|
||||||
|
source [find interface/cmsis-dap.cfg]
|
||||||
|
|
||||||
|
source [find target/lpc1768.cfg]
|
|
@ -0,0 +1,7 @@
|
||||||
|
#
|
||||||
|
# ARM CMSIS-DAP compliant adapter
|
||||||
|
#
|
||||||
|
# http://www.keil.com/support/man/docs/dapdebug/
|
||||||
|
#
|
||||||
|
|
||||||
|
interface cmsis-dap
|
|
@ -0,0 +1,48 @@
|
||||||
|
#
|
||||||
|
# Freescale Kinetis KL25 devices
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# KL25 devices support both JTAG and SWD transports.
|
||||||
|
#
|
||||||
|
source [find target/swj-dp.tcl]
|
||||||
|
|
||||||
|
if { [info exists CHIPNAME] } {
|
||||||
|
set _CHIPNAME $CHIPNAME
|
||||||
|
} else {
|
||||||
|
set _CHIPNAME kl25
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [info exists ENDIAN] } {
|
||||||
|
set _ENDIAN $ENDIAN
|
||||||
|
} else {
|
||||||
|
set _ENDIAN little
|
||||||
|
}
|
||||||
|
|
||||||
|
# Work-area is a space in RAM used for flash programming
|
||||||
|
# By default use 4kB
|
||||||
|
if { [info exists WORKAREASIZE] } {
|
||||||
|
set _WORKAREASIZE $WORKAREASIZE
|
||||||
|
} else {
|
||||||
|
set _WORKAREASIZE 0x1000
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [info exists CPUTAPID] } {
|
||||||
|
set _CPUTAPID $CPUTAPID
|
||||||
|
} else {
|
||||||
|
set _CPUTAPID 0x0bc11477
|
||||||
|
}
|
||||||
|
|
||||||
|
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||||
|
|
||||||
|
set _TARGETNAME $_CHIPNAME.cpu
|
||||||
|
target create $_TARGETNAME cortex_m -endian $_ENDIAN -chain-position $_CHIPNAME.cpu
|
||||||
|
|
||||||
|
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
||||||
|
|
||||||
|
set _FLASHNAME $_CHIPNAME.flash
|
||||||
|
flash bank $_FLASHNAME kinetis 0 0 0 0 $_TARGETNAME
|
||||||
|
|
||||||
|
# if srst is not fitted use SYSRESETREQ to
|
||||||
|
# perform a soft reset
|
||||||
|
cortex_m reset_config sysresetreq
|
|
@ -0,0 +1,48 @@
|
||||||
|
#
|
||||||
|
# NXP lpc11uxx family
|
||||||
|
|
||||||
|
source [find target/swj-dp.tcl]
|
||||||
|
|
||||||
|
if { [info exists CHIPNAME] } {
|
||||||
|
set _CHIPNAME $CHIPNAME
|
||||||
|
} else {
|
||||||
|
set _CHIPNAME lpc11uxx
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [info exists ENDIAN] } {
|
||||||
|
set _ENDIAN $ENDIAN
|
||||||
|
} else {
|
||||||
|
set _ENDIAN little
|
||||||
|
}
|
||||||
|
|
||||||
|
# Work-area is a space in RAM used for flash programming
|
||||||
|
# By default use 6kB
|
||||||
|
if { [info exists WORKAREASIZE] } {
|
||||||
|
set _WORKAREASIZE $WORKAREASIZE
|
||||||
|
} else {
|
||||||
|
set _WORKAREASIZE 0x1800
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [info exists CPUTAPID] } {
|
||||||
|
set _CPUTAPID $CPUTAPID
|
||||||
|
} else {
|
||||||
|
set _CPUTAPID 0x00000000
|
||||||
|
}
|
||||||
|
|
||||||
|
# delays on reset lines
|
||||||
|
adapter_nsrst_delay 100
|
||||||
|
#jtag_ntrst_delay 100
|
||||||
|
|
||||||
|
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||||
|
|
||||||
|
set _TARGETNAME $_CHIPNAME.cpu
|
||||||
|
target create $_TARGETNAME cortex_m -endian $_ENDIAN -chain-position $_TARGETNAME
|
||||||
|
|
||||||
|
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
||||||
|
|
||||||
|
#set _FLASHNAME $_CHIPNAME.flash
|
||||||
|
#flash bank $_FLASHNAME lpc2000 0 0 0 0 $_TARGETNAME
|
||||||
|
|
||||||
|
# if srst is not fitted use SYSRESETREQ to
|
||||||
|
# perform a soft reset
|
||||||
|
cortex_m reset_config sysresetreq
|
|
@ -49,10 +49,6 @@ if { [info exists CPUROMSIZE] } {
|
||||||
error "_CPUROMSIZE not set. Please do not include lpc17xx.cfg directly, but the specific chip configuration file (lpc1751.cfg, lpc1764.cfg, etc)."
|
error "_CPUROMSIZE not set. Please do not include lpc17xx.cfg directly, but the specific chip configuration file (lpc1751.cfg, lpc1764.cfg, etc)."
|
||||||
}
|
}
|
||||||
|
|
||||||
#delays on reset lines
|
|
||||||
adapter_nsrst_delay 200
|
|
||||||
jtag_ntrst_delay 200
|
|
||||||
|
|
||||||
#jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
#jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||||
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||||
|
|
||||||
|
@ -74,6 +70,12 @@ flash bank $_FLASHNAME lpc2000 0x0 $_CPUROMSIZE 0 0 $_TARGETNAME \
|
||||||
# we have no idea what clock the target is running at.
|
# we have no idea what clock the target is running at.
|
||||||
adapter_khz 10
|
adapter_khz 10
|
||||||
|
|
||||||
|
# delays on reset lines
|
||||||
|
adapter_nsrst_delay 200
|
||||||
|
if {$using_jtag} {
|
||||||
|
jtag_ntrst_delay 200
|
||||||
|
}
|
||||||
|
|
||||||
$_TARGETNAME configure -event reset-init {
|
$_TARGETNAME configure -event reset-init {
|
||||||
# Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
|
# Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
|
||||||
# "User Flash Mode" where interrupt vectors are _not_ remapped,
|
# "User Flash Mode" where interrupt vectors are _not_ remapped,
|
||||||
|
|
|
@ -18,8 +18,13 @@
|
||||||
# split out "chip" and "tag" so we can someday handle
|
# split out "chip" and "tag" so we can someday handle
|
||||||
# them more uniformly irlen too...)
|
# them more uniformly irlen too...)
|
||||||
|
|
||||||
|
global using_jtag
|
||||||
|
set using_jtag 1
|
||||||
|
|
||||||
proc swj_newdap {chip tag args} {
|
proc swj_newdap {chip tag args} {
|
||||||
set tran [transport select]
|
global using_jtag
|
||||||
if [string equal $tran "jtag"] { eval jtag newtap $chip $tag $args}
|
set tran [transport select]
|
||||||
if [string equal $tran "swd"] { eval swd newdap $chip $tag $args }
|
if [string equal $tran "jtag"] { eval jtag newtap $chip $tag $args; set using_jtag 1 }
|
||||||
|
if [string equal $tran "swd"] { eval swd newdap $chip $tag $args; set using_jtag 0 }
|
||||||
|
if [string equal $tran "cmsis-dap"] { eval cmsis-dap newdap $chip $tag $args; set using_jtag 0 }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue