Skip to content

Commit ce7f542

Browse files
authored
Merge pull request #7 from syntacore/en-sc/from_upstream
Merge up to 6f84e90 from RISC-V OpenOCD
2 parents c0a2b6b + 35cd78c commit ce7f542

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3123
-1125
lines changed

.github/workflows/linux-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Linux Build
55
jobs:
66
# 32-bit, clang
77
build32:
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-latest
99
env:
1010
CFLAGS: -m32
1111
CC: clang

.github/workflows/snapshot.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
# Copyright (C) 2020 by Tarek BOUCHKATI <[email protected]>
44

5-
on: push
5+
on:
6+
push:
7+
branches:
8+
- riscv
69

710
name: OpenOCD Snapshot
811

configure.ac

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,19 @@ m4_define([USB1_ADAPTERS],
137137
[[ft232r], [Bitbang mode of FT232R based devices], [FT232R]],
138138
[[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]],
139139
[[xds110], [TI XDS110 Debug Probe], [XDS110]],
140-
[[cmsis_dap_v2], [CMSIS-DAP v2 Compliant Debugger], [CMSIS_DAP_USB]],
141140
[[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
142141
[[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
143142
[[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]],
144143
[[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
145144
[[usbprog], [USBProg JTAG Programmer], [USBPROG]],
146-
[[esp_usb_jtag], [Espressif JTAG Programmer], [ESP_USB_JTAG]]])
145+
[[esp_usb_jtag], [Espressif JTAG Programmer], [ESP_USB_JTAG]],
146+
[[cmsis_dap_v2], [CMSIS-DAP v2 compliant dongle (USB bulk)], [CMSIS_DAP_USB]]])
147+
148+
# Please keep cmsis_dap_v2 the last in USB1_ADAPTERS
149+
# and cmsis_dap the first in HIDAPI_ADAPTERS
147150

148151
m4_define([HIDAPI_ADAPTERS],
149-
[[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP_HID]],
152+
[[[cmsis_dap], [CMSIS-DAP v1 compliant dongle (HID)], [CMSIS_DAP_HID]],
150153
[[nulink], [Nu-Link Programmer], [HLADAPTER_NULINK]]])
151154

152155
m4_define([HIDAPI_USB1_ADAPTERS],
@@ -162,6 +165,9 @@ m4_define([LIBFTDI_USB1_ADAPTERS],
162165
m4_define([LIBGPIOD_ADAPTERS],
163166
[[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]])
164167

168+
m4_define([REMOTE_BITBANG_ADAPTER],
169+
[[[remote_bitbang], [Remote Bitbang driver], [REMOTE_BITBANG]]])
170+
165171
m4_define([LIBJAYLINK_ADAPTERS],
166172
[[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
167173

@@ -176,6 +182,15 @@ m4_define([LINUXSPIDEV_ADAPTER],
176182
m4_define([VDEBUG_ADAPTER],
177183
[[[vdebug], [Cadence Virtual Debug Interface], [VDEBUG]]])
178184

185+
m4_define([JTAG_DPI_ADAPTER],
186+
[[[jtag_dpi], [JTAG DPI Adapter], [JTAG_DPI]]])
187+
188+
m4_define([JTAG_VPI_ADAPTER],
189+
[[[jtag_vpi], [JTAG VPI Adapter], [JTAG_VPI]]])
190+
191+
m4_define([RSHIM_ADAPTER],
192+
[[[rshim], [BlueField SoC via rshim], [RSHIM]]])
193+
179194
# The word 'Adapter' in "Dummy Adapter" below must begin with a capital letter
180195
# because there is an M4 macro called 'adapter'.
181196
m4_define([DUMMY_ADAPTER],
@@ -274,10 +289,6 @@ AS_IF([test "x$debug_malloc" = "xyes" -a "x$have_glibc" = "xyes"], [
274289
AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
275290
])
276291

277-
AC_ARG_ENABLE([rshim],
278-
AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
279-
[build_rshim=$enableval], [build_rshim=no])
280-
281292
AC_ARG_ENABLE([dmem],
282293
AS_HELP_STRING([--enable-dmem], [Enable building the dmem driver]),
283294
[build_dmem=$enableval], [build_dmem=no])
@@ -302,10 +313,14 @@ AC_ARG_ADAPTERS([
302313
LIBFTDI_ADAPTERS,
303314
LIBFTDI_USB1_ADAPTERS,
304315
LIBGPIOD_ADAPTERS,
316+
REMOTE_BITBANG_ADAPTER,
305317
LINUXSPIDEV_ADAPTER,
306318
SERIAL_PORT_ADAPTERS,
307319
DUMMY_ADAPTER,
308320
VDEBUG_ADAPTER,
321+
JTAG_DPI_ADAPTER,
322+
JTAG_VPI_ADAPTER,
323+
RSHIM_ADAPTER,
309324
PCIE_ADAPTERS,
310325
LIBJAYLINK_ADAPTERS
311326
],[auto])
@@ -324,14 +339,6 @@ AC_ARG_ENABLE([parport_giveio],
324339
[Enable use of giveio for parport (for CygWin only)]),
325340
[parport_use_giveio=$enableval], [parport_use_giveio=])
326341

327-
AC_ARG_ENABLE([jtag_vpi],
328-
AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
329-
[build_jtag_vpi=$enableval], [build_jtag_vpi=no])
330-
331-
AC_ARG_ENABLE([jtag_dpi],
332-
AS_HELP_STRING([--enable-jtag_dpi], [Enable building support for JTAG DPI]),
333-
[build_jtag_dpi=$enableval], [build_jtag_dpi=no])
334-
335342
AC_ARG_ENABLE([amtjtagaccel],
336343
AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
337344
[build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
@@ -377,19 +384,24 @@ AC_ARG_ENABLE([sysfsgpio],
377384
AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
378385
[build_sysfsgpio=$enableval], [build_sysfsgpio=no])
379386

387+
can_build_rshim=no
388+
380389
AS_CASE([$host_os],
381390
[linux*], [
382391
is_linux=yes
392+
can_build_rshim=yes
383393
],
384394
[
385395
AS_IF([test "x$build_sysfsgpio" = "xyes"], [
386396
AC_MSG_ERROR([sysfsgpio is only available on linux])
387397
])
388398
389-
AS_CASE([$host_os], [freebsd*], [],
399+
AS_CASE([$host_os], [freebsd*], [
400+
can_build_rshim=yes
401+
],
390402
[
391-
AS_IF([test "x$build_rshim" = "xyes"], [
392-
AC_MSG_ERROR([build_rshim is only available on linux or freebsd])
403+
AS_IF([test "x$enable_rshim" = "xyes"], [
404+
AC_MSG_ERROR([rshim is only available on linux or freebsd])
393405
])
394406
])
395407
@@ -398,10 +410,6 @@ AS_CASE([$host_os],
398410
])
399411
])
400412

401-
AC_ARG_ENABLE([remote-bitbang],
402-
AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang driver]),
403-
[build_remote_bitbang=$enableval], [build_remote_bitbang=yes])
404-
405413
AS_CASE(["${host_cpu}"],
406414
[i?86|x86*], [],
407415
[
@@ -499,12 +507,6 @@ AS_IF([test "x$build_parport" = "xyes"], [
499507
AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
500508
])
501509

502-
AS_IF([test "x$build_rshim" = "xyes"], [
503-
AC_DEFINE([BUILD_RSHIM], [1], [1 if you want to debug BlueField SoC via rshim.])
504-
], [
505-
AC_DEFINE([BUILD_RSHIM], [0], [0 if you don't want to debug BlueField SoC via rshim.])
506-
])
507-
508510
AS_IF([test "x$build_dmem" = "xyes"], [
509511
AC_DEFINE([BUILD_DMEM], [1], [1 if you want to debug via Direct Mem.])
510512
], [
@@ -562,19 +564,6 @@ AS_IF([test "x$parport_use_giveio" = "xyes"], [
562564
AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
563565
])
564566

565-
AS_IF([test "x$build_jtag_vpi" = "xyes"], [
566-
AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
567-
], [
568-
AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
569-
])
570-
571-
AS_IF([test "x$build_jtag_dpi" = "xyes"], [
572-
AC_DEFINE([BUILD_JTAG_DPI], [1], [1 if you want JTAG DPI.])
573-
], [
574-
AC_DEFINE([BUILD_JTAG_DPI], [0], [0 if you don't want JTAG DPI.])
575-
])
576-
577-
578567
AS_IF([test "x$build_amtjtagaccel" = "xyes"], [
579568
AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
580569
], [
@@ -596,13 +585,6 @@ PKG_CHECK_MODULES([JIMTCL], [jimtcl >= 0.79], [
596585
])
597586
])
598587

599-
AS_IF([test "x$build_remote_bitbang" = "xyes"], [
600-
build_bitbang=yes
601-
AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang driver.])
602-
], [
603-
AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang driver.])
604-
])
605-
606588
AS_IF([test "x$build_sysfsgpio" = "xyes"], [
607589
build_bitbang=yes
608590
AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
@@ -701,18 +683,27 @@ PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libu
701683
PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
702684
PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
703685
PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [Linux libgpiod])
686+
PROCESS_ADAPTERS([REMOTE_BITBANG_ADAPTER], [true], [unused])
704687
PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_libjaylink" = "xyes"], [libjaylink-0.2])
705688
PROCESS_ADAPTERS([PCIE_ADAPTERS], ["x$is_linux" = "xyes"], [Linux build])
706689
PROCESS_ADAPTERS([SERIAL_PORT_ADAPTERS], ["x$can_build_buspirate" = "xyes"],
707690
[internal error: validation should happen beforehand])
708691
PROCESS_ADAPTERS([LINUXSPIDEV_ADAPTER], ["x$is_linux" = "xyes"], [Linux spidev])
709692
PROCESS_ADAPTERS([VDEBUG_ADAPTER], [true], [unused])
693+
PROCESS_ADAPTERS([JTAG_DPI_ADAPTER], [true], [unused])
694+
PROCESS_ADAPTERS([JTAG_VPI_ADAPTER], [true], [unused])
695+
PROCESS_ADAPTERS([RSHIM_ADAPTER], ["x$can_build_rshim" = "xyes"],
696+
[internal error: validation should happen beforehand])
710697
PROCESS_ADAPTERS([DUMMY_ADAPTER], [true], [unused])
711698

712699
AS_IF([test "x$enable_linuxgpiod" != "xno"], [
713700
build_bitbang=yes
714701
])
715702

703+
AS_IF([test "x$enable_remote_bitbang" != "xno"], [
704+
build_bitbang=yes
705+
])
706+
716707
AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enable_nulink" != "xno"], [
717708
AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
718709
AM_CONDITIONAL([HLADAPTER], [true])
@@ -743,12 +734,9 @@ AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
743734
AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
744735
AM_CONDITIONAL([AM335XGPIO], [test "x$build_am335xgpio" = "xyes"])
745736
AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
746-
AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes"])
747-
AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes"])
748737
AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
749738
AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
750739
AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
751-
AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
752740
AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
753741
AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
754742
AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
@@ -760,7 +748,6 @@ AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
760748
AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"])
761749
AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"])
762750
AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
763-
AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
764751
AM_CONDITIONAL([DMEM], [test "x$build_dmem" = "xyes"])
765752
AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
766753

@@ -839,18 +826,22 @@ AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
839826
echo
840827
echo
841828
echo OpenOCD configuration summary
842-
echo --------------------------------------------------
829+
echo ---------------------------------------------------
843830
m4_foreach([adapter], [USB1_ADAPTERS,
844831
HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS,
845832
LIBFTDI_USB1_ADAPTERS,
846833
LIBGPIOD_ADAPTERS,
834+
REMOTE_BITBANG_ADAPTER,
847835
LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
848836
LINUXSPIDEV_ADAPTER,
849837
VDEBUG_ADAPTER,
838+
JTAG_DPI_ADAPTER,
839+
JTAG_VPI_ADAPTER,
840+
RSHIM_ADAPTER,
850841
DUMMY_ADAPTER,
851842
OPTIONAL_LIBRARIES,
852843
COVERAGE],
853-
[s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
844+
[s=m4_format(["%-41s"], ADAPTER_DESC([adapter]))
854845
AS_CASE([$ADAPTER_VAR([adapter])],
855846
[auto], [
856847
echo "$s"yes '(auto)'

doc/openocd.texi

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,12 +2415,6 @@ target.
24152415
List the debug adapter drivers that have been built into
24162416
the running copy of OpenOCD.
24172417
@end deffn
2418-
@deffn {Config Command} {adapter transports} transport_name+
2419-
Specifies the transports supported by this debug adapter.
2420-
The adapter driver builds-in similar knowledge; use this only
2421-
when external configuration (such as jumpering) changes what
2422-
the hardware can support.
2423-
@end deffn
24242418

24252419
@anchor{adapter gpio}
24262420
@deffn {Config Command} {adapter gpio [ @
@@ -3845,13 +3839,6 @@ Not all adapters and adapter drivers support SWD multi-drop. Only the following
38453839
adapter drivers are SWD multi-drop capable:
38463840
cmsis_dap (use an adapter with CMSIS-DAP version 2.0), ftdi, all bitbang based.
38473841

3848-
@subsection SPI Transport
3849-
@cindex SPI
3850-
@cindex Serial Peripheral Interface
3851-
The Serial Peripheral Interface (SPI) is a general purpose transport
3852-
which uses four wire signaling. Some processors use it as part of a
3853-
solution for flash programming.
3854-
38553842
@anchor{swimtransport}
38563843
@subsection SWIM Transport
38573844
@cindex SWIM
@@ -7431,6 +7418,76 @@ msp432 bsl lock
74317418
@end deffn
74327419
@end deffn
74337420

7421+
@deffn {Flash Driver} {mspm0}
7422+
7423+
All Arm Cortex-M0+ MSPM0 microcontroller versions from Texas Instruments
7424+
include internal flash. The mspm0 flash driver automatically recognizes the
7425+
specific version's flash parameters and autoconfigures itself. The main
7426+
program flash starts at address 0x0. Non-main flash starts at 0x41c00000.
7427+
If present on the device, the optional region called "Data" starts at
7428+
0x41d00000.
7429+
7430+
@b{Warning}:
7431+
7432+
@itemize @bullet
7433+
@item @b{Reset while MCU operation:} When erasing all of MAIN memory, if the
7434+
MCU is still executing from MAIN memory do not reset the device as it could
7435+
cause a double hard-fault due to the missing interrupt vector table at the
7436+
start of memory. To recover from such scenario reset or power-cycle the MCU.
7437+
7438+
@item @b{No explicit protection support:} MSPM0 flash controller auto-protect
7439+
themselves after every flash operation. As a result of this, OpenOCD does not
7440+
explicitly provide any protection function and automatically un-protects
7441+
required sections as flash operations are requested.
7442+
@end itemize
7443+
7444+
@b{Examples}:
7445+
7446+
@itemize @bullet
7447+
7448+
@item @b{Flash bank description:}
7449+
@example
7450+
flash bank $_FLASHNAME mspm0 0 0 0 0 $_TARGETNAME
7451+
@end example
7452+
7453+
@item @b{To erase and program the MAIN region:}
7454+
@example
7455+
halt
7456+
flash erase_sector 0 0 last
7457+
flash write_image MAIN.bin 0x0
7458+
mspm0_board_reset
7459+
@end example
7460+
7461+
@item @b{To erase and program the NONMAIN region:}
7462+
@example
7463+
halt
7464+
flash erase_sector 1 0 last
7465+
flash write_image NONMAIN.bin 0x41C00000
7466+
mspm0_board_reset
7467+
@end example
7468+
7469+
@end itemize
7470+
7471+
@deffn {TCL proc} {mspm0_board_reset}
7472+
Performs an nRST toggle on the device.
7473+
@end deffn
7474+
7475+
@deffn {TCL proc} {mspm0_mass_erase}
7476+
Sends the mass erase command to the SEC-AP mailbox and then performs
7477+
an nRST toggle. Once the command has been fully processed by the ROM,
7478+
all MAIN memory will be erased. NOTE: This command is not supported
7479+
on MSPM0C* family of devices.
7480+
@end deffn
7481+
7482+
@deffn {TCL proc} {mspm0_factory_reset}
7483+
Sends the factory reset command to the SEC-AP mailbox and then performs
7484+
an nRST toggle. Once the command has been fully processed by the ROM,
7485+
all MAIN memory will be erased and NONMAIN will be reset to its default
7486+
values.
7487+
@end deffn
7488+
7489+
@end deffn
7490+
74347491
@deffn {Flash Driver} {niietcm4}
74357492
This drivers handles the integrated NOR flash on NIIET Cortex-M4
74367493
based controllers. Flash size and sector layout are auto-configured by the driver.

src/flash/nor/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ NOR_DRIVERS = \
4545
%D%/max32xxx.c \
4646
%D%/mdr.c \
4747
%D%/msp432.c \
48+
%D%/mspm0.c \
4849
%D%/mrvlqspi.c \
4950
%D%/niietcm4.c \
5051
%D%/non_cfi.c \

src/flash/nor/driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ extern const struct flash_driver max32xxx_flash;
274274
extern const struct flash_driver mdr_flash;
275275
extern const struct flash_driver mrvlqspi_flash;
276276
extern const struct flash_driver msp432_flash;
277+
extern const struct flash_driver mspm0_flash;
277278
extern const struct flash_driver niietcm4_flash;
278279
extern const struct flash_driver npcx_flash;
279280
extern const struct flash_driver nrf51_flash;

src/flash/nor/drivers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static const struct flash_driver * const flash_drivers[] = {
5151
&mdr_flash,
5252
&mrvlqspi_flash,
5353
&msp432_flash,
54+
&mspm0_flash,
5455
&niietcm4_flash,
5556
&npcx_flash,
5657
&nrf5_flash,

0 commit comments

Comments
 (0)