openocd.git
3 years agocortex_m: use the new enum ARMV7M_REGSEL_name 73/5873/2
Antonio Borneo [Wed, 21 Oct 2020 14:12:27 +0000 (16:12 +0200)]
cortex_m: use the new enum ARMV7M_REGSEL_name

Register xPSR is indexed directly with its value 16 or with the
incorrect enum ARMV7M_xPSR.

Replace them with the new enum ARMV7M_REGSEL_xPSR.

Change-Id: I86600e7f78e39002ce45f66d4792d5067c1f541b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5873
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agostlink: handle read/write FPU registers in HLA API 83/5883/2
Antonio Borneo [Sun, 25 Oct 2020 16:35:45 +0000 (17:35 +0100)]
stlink: handle read/write FPU registers in HLA API

Old stlink firmware in stlink V1 and stlink V2 pre-J15 do not
handle FPU registers in the read_reg() and write_reg() API.

Add code to be compatible with the new API of OpenOCD.

Change-Id: Ib0439c5294b6911ea75efe8c7fa085b014317a4b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5883
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agohla: API: specify that read_reg/write_reg use regsel as parameter 82/5882/3
Antonio Borneo [Sun, 25 Oct 2020 13:59:13 +0000 (14:59 +0100)]
hla: API: specify that read_reg/write_reg use regsel as parameter

The API of hla have been defined from ST-Link basic operations.
By chance, all the current implementation of hla (st-link, ti-icdi
and nulink) share the same way to handle the parameter 'num' of
the API read_reg() and write_reg(), that is simply using it to
initialize the field REGSEL (bits [6:0]) of armv7m Debug Core
Register Selector Register (DCRSR).

Add a comment in the API definition to highlight this, in case it
get used by a further hla implementation, then rename as 'regsel'
the 'num' parameter.

Change-Id: I4b6a2c7d78b4fc4de2b9b2bdba065414b15c6ba3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5882
Reviewed-by: Edward Fewell <edwardfewell@hotmail.com>
Tested-by: jenkins
Reviewed-by: Zale Yu
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agotarget/cortex_m,hla_target: rework Cortex-M register handling part 4 64/5864/6
Tomas Vanek [Wed, 14 Oct 2020 19:03:02 +0000 (21:03 +0200)]
target/cortex_m,hla_target: rework Cortex-M register handling part 4

Consolidate low level register read/write.

Floating point registers were handled by target_read/write_u32
unlike other registers handled by cortexm_dap_read/write_coreregister_u32
There is no reason to do so in cortex_m.
Remove cortexm_dap_read/write_coreregister_u32
and use cortex_m_load/store_core_reg_u32 directly.

Similarly HLA adapters register read/write interface supports all registers
so use it for any floating point and other registers.

Change-Id: Ida679e5f4fec02d94ffb0bd3f265ed7ed2221cdc
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5864
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/armv7m: rework Cortex-M register handling part 3 63/5863/7
Tomas Vanek [Wed, 14 Oct 2020 18:23:50 +0000 (20:23 +0200)]
target/armv7m: rework Cortex-M register handling part 3

Move primask/basepri/faultmask/control packing/unpacking from
cortex_m.c and hla_target.c to armv7m.c armv7m_read_core_reg()
and armv7m_write_core_reg() where also the FP 32/64-bit registers
conversion takes place.

Introduce a new hidden register ARMV7M_PMSK_BPRI_FLTMSK_CTRL
for packing/unpacking of special registers in the register cache.

The new packing/unpacking is endianess safe.

While on it improve returned error codes and LOG_ messages.

Just minimal changes in cortex_m.c and hla_target.c, will be
consolidated in the next patch.

Change-Id: Id51e764e243e54b5fdaadf2a202eee7c4bc729fe
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5863
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/armv7m: rework Cortex-M register handling part 2 62/5862/4
Tomas Vanek [Wed, 14 Oct 2020 14:52:09 +0000 (16:52 +0200)]
target/armv7m: rework Cortex-M register handling part 2

Make arm register id coherent with reg_list index.
Without this reg_list[ARMV7M_R12] was possible but
reg_list[ARMV7M_FPSCR] was out of bounds.

Remove unused items from reg_list index.

Change-Id: I84d3b5c496fc1839d07a5b74cb1fd1c3d4ff8989
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5862
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
3 years agotarget/armv7m: rework Cortex-M register handling part 1 27/5327/5
Tomas Vanek [Sun, 20 Oct 2019 08:12:32 +0000 (10:12 +0200)]
target/armv7m: rework Cortex-M register handling part 1

Define a new enum with DCRSR.REGSEL selectors.
Introduce armv7m_map_id_to_regsel() to unify mapping in one place.
Use DCRSR.REGSEL selectors for low level register read/write.

Change-Id: Ida0ccdfa9cdb1257a1900b8bfbf172b076374d39
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5327
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
3 years agotarget, register: allow a register hidden from gdb and 'reg' cmd 25/5325/4
Tomas Vanek [Sun, 20 Oct 2019 07:40:34 +0000 (09:40 +0200)]
target, register: allow a register hidden from gdb and 'reg' cmd

Introduce a 'hidden' flag in struct reg to support a register cache
containing different views of same data: e.g. Cortex-M has
primask, basepri, faultmask and control registers accessed
as one word. With the hidden flag we can add an reg_list item
corresponding to hw access without exposing the register to user level.

All the struct reg are allocated with calloc() but one in xscale.c
allocated by malloc(). Change this one to use calloc() as well
to guarantee initial value hidden=false

Change-Id: I8da9f5a5a60777ae7ef943a841307487bd80fc6f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5325
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash/stmqspi: minor fixes on coding style 32/5932/2
Antonio Borneo [Mon, 9 Nov 2020 14:50:55 +0000 (15:50 +0100)]
flash/stmqspi: minor fixes on coding style

Add space around operators;
use BIT() macro in place of left shifting constant 1;
remove space between cast operator and value;
do not check a pointer before free() it;
add parenthesis around parameters in macros;
fix indentation using only TABs;
remove line continuation '\' at code lines out of macros.

Change-Id: I809e8ee72d7bfe49d0edf10afb36efe2458de77c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: e44539d66c89 ("Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface")
Reviewed-on: http://openocd.zylin.com/5932
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
3 years agotcl/board: rename board file ST b-l475e-iot01a 31/5931/3
Antonio Borneo [Mon, 9 Nov 2020 11:53:30 +0000 (12:53 +0100)]
tcl/board: rename board file ST b-l475e-iot01a

Use the board file name as <company>_<name>.cfg

Add the SPDX tag to workaround an error in checkpatch that fails
to recognize as valid a patch that only changes a file name.

Change-Id: I929cd9e5f9fe2e7386950643487534c9a5a05bc6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: e44539d66c89 ("Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface")
Reviewed-on: http://openocd.zylin.com/5931
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
3 years agotarget/cortex_m: Change sleep to running state 21/5921/3
Kevin Yang [Wed, 4 Nov 2020 18:39:29 +0000 (10:39 -0800)]
target/cortex_m: Change sleep to running state

When the core is in sleep mode, the core is no longer retiring
instructions. Cortext M remains in "unknown" state. This patch converts
sleep mode to "running" state.

Change-Id: I1e9b6c9be51fd0f1f6ce81af9b1f5f9f1f43c661
Signed-off-by: Kevin Yang <kangyang@google.com>
Reviewed-on: http://openocd.zylin.com/5921
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 years agoFlash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface 21/4321/15
Andreas Bolsch [Wed, 21 Dec 2016 09:35:58 +0000 (10:35 +0100)]
Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface

- write speed up to 150 kByte/s on STM32F469I-disco (due to
  SWD clock and USB connection), up to 1 MByte/s on Nucleo-F767ZI
  with external STLink-V3 or Nucleo-G474RE with two W25Q256FV in
  dual 4-line mode or STM32H73BI-Disco in octal mode
- tested with STM32L476G-disco (64MBit flash, 3-byte addr),
  STM32F412G-Disco, STM32F469I-Disco, STM32F746G-Disco, and
  STM32L476G-Disco (all 128Mbit flash, 3-byte addr),
  STM32F723E-Disco, STM32F769I-Disco (512Mbit flash, 4-byte addr)
  STM32L4R9I-Disco, STM32L4P5G-Disco (512MBit octo-flash, DTR, 4-byte addr)
  STM32H745I-Disco, STM32H747I-Disco (two 512MBit flash, 4-byte addr)
  STM32H73BI-Disco, STM32H735G-Disco (512MBit octo-flash, DTR, 4-byte addr)
- suitable cfg for Discovery boards included
- limited parsing of SFDP data if flash device not hardcoded
  (tested only in single/quad mode as most devices either don't
  support SFDP at all or have empty(!) SFDP memory)
- 'set' command for auto detection override (e. g. for EEPROMs)
- 'cmd' command for arbitrary SPI commands (reconfiguration, testing etc.)
- makefile for creation of binary loader files
- tcl/board/stm32f469discovery.cfg superseded by stm32f469i-disco.cfg
- tcl/board/stm32f7discovery.cfg removed as name is ambiguous
  (superseded by stm32f746g-disco.cfg vs. stm32f769i-disco.cfg)
- dual 4-line mode tested on Nucleo-F767ZI, Nucleo-H743ZI and Nucleo-H7A3ZI-Q
  with two W25Q256FV, and on Nucleo-L496ZP-P and Nucleo-L4R5ZI
  with two W25Q128FV, sample cfg files included and on STM32H745I-Disco,
  STM32H747I-Disco, STM32H750B-Disco
- read/verify/erase_check uses indirect read mode to work around silicon bug in
  H7, L4+ and MP1 memory mapped mode (last bytes not readable, accessing last
  bytes causes debug interface to hang)
- octospi supported only in single/dual 1-line, 2-line, 4-line
  and single 8-line modes, (not in hyper flash mode)

Requirements:
GPIOs must be initialized appropriately, and SPI flash chip be configured
appropriately (1-line ..., QPI, 4-byte addresses ...). This is board/chip
specific, cf. included cfg files. The driver infers most parameters from
current setting in CR, CCR, ... registers.

Change-Id: I54858fbbe8758c3a5fe58812e93f5f39514704f8
Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: http://openocd.zylin.com/4321
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Christopher Head <chead@zaber.com>
3 years agostlink: fix computation of trace prescaler 09/5909/2
Antonio Borneo [Sat, 31 Oct 2020 13:55:10 +0000 (14:55 +0100)]
stlink: fix computation of trace prescaler

Use integer rounding for the computation of prescaler.
Improve the test of prescaler range, knowing its value would be
decremented before being written in TPIU ACPR.

Change-Id: I041dde1dca41323904e36a6b6975028a6de902b3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5909
Tested-by: jenkins
3 years agostlink: fix max SWV baudrate on stlink v3 08/5908/2
Antonio Borneo [Fri, 30 Oct 2020 14:03:37 +0000 (15:03 +0100)]
stlink: fix max SWV baudrate on stlink v3

While stlink v2 anly accept till to 2 MHz for SWV baudrate, stlink
v3 accepts up to 24 MHz.

Check the stlink version and use the respective max value.

Change-Id: I911207a35983b6acf0b901059076dd31f70e6290
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Pawel <phryniszak@users.sourceforge.net>
Fixes: https://sourceforge.net/p/openocd/tickets/283/
Reviewed-on: http://openocd.zylin.com/5908
Tested-by: jenkins
3 years agodrivers/jlink: fix check for max prescaler 07/5907/2
Antonio Borneo [Sat, 31 Oct 2020 13:49:23 +0000 (14:49 +0100)]
drivers/jlink: fix check for max prescaler

The value stored in TPIU ACPR is the prescaler value decremented
by one. Thus, the test should verify that prescaler does not
exceed the maximum ACPR value plus one. Also, zero value is not
allowed for prescaler.

Change-Id: I1817f04f2a310b2f413bad726f0cb9dd6a4172e2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5907
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
3 years agobuild: fix build with --enable-minidriver-dummy 11/5911/2
Antonio Borneo [Sun, 1 Nov 2020 14:39:23 +0000 (15:39 +0100)]
build: fix build with --enable-minidriver-dummy

Commit 462c01206692 ("Add complete JTAG debug logging.") breaks
the build for minidriver, that is enabled either on zy1000 build
and on minidriver-dummy build. The check on BUILD_ZY1000 was added
to pass the auto-build in jenkins. While the build issue with
minidriver-dummy was known, as reported in the comment, it was not
addressed and got ignored for slightly more than one year.

Use the macro HAVE_JTAG_MINIDRIVER_H in place of BUILD_ZY1000 to
take in account both builds that require the minidriver.
Fix also the build in case configure enables the HLA drivers due
to autodetection of libusb. The HLA drivers would not be in the
build and the function transport_is_hla() would be missing.

Change-Id: I1d85c5fa247bf4a85aba29b233c0b573b46665bc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5911
Tested-by: jenkins
3 years agotarget/arm7tdmi: remove unused/deprecated function parameter 12/5912/2
Antonio Borneo [Sun, 1 Nov 2020 00:03:44 +0000 (01:03 +0100)]
target/arm7tdmi: remove unused/deprecated function parameter

The function arm7tdmi_clock_out() has one unused 'deprecated'
parameter.

Drop the unused 'deprecated' parameter and the FIXME above it.

Change-Id: Ia8de41f5b8258825faccc737bba622e44c81a7ea
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5912
Tested-by: jenkins
3 years agodoc: remove reference to already dropped tftp support 13/5913/2
Antonio Borneo [Sun, 1 Nov 2020 21:06:03 +0000 (22:06 +0100)]
doc: remove reference to already dropped tftp support

The only code dealing with tftp in OpenOCD was in eCos build, code
already dropped in commit 39650e2273bc ("ecosboard: delete
bit-rotted eCos code") almost 8 years ago.

Drop tftp related documentation too.

Change-Id: I0defc8f844e74c90894dca04a652dcc497a520e1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5913
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agoconfigure.ac: add libutil to the dependency list 22/5922/2
Antonio Borneo [Thu, 5 Nov 2020 08:54:11 +0000 (09:54 +0100)]
configure.ac: add libutil to the dependency list

Jimtcl 0.80 (2020-10-29) adds dependency to libutil, which is part
of the GNU libc.
The library is searched and used by jimtcl build, but still has to
be linked in by OpenOCD as indirect dependency.

While OpenOCD is still using jimtcl 0.79, let's prepare to switch
to the next version.
Add libutil search in configure.ac.

Change-Id: I5a8952161b0e5b93fc00d23be256b5274d31e08c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5922
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agostm32h7x: Fix reset with non-HLA interfaces on macOS 72/5872/3
Alberto García Hierro [Tue, 20 Oct 2020 15:13:17 +0000 (16:13 +0100)]
stm32h7x: Fix reset with non-HLA interfaces on macOS

regsub doesn't work correctly on macOS Catalina, which results in
an incorrect CHIPNAME derived from the current target. Since regsub
is only used by this target, replace it with a simple string search
for '.' followed by a substring. This is funcionally equivalent to
what the regular expression was doing, but instead relies in simpler
string operations that should have little to no differences
between systems.

Also, refactor CHIPNAME detection into proc stm32h7x_chipname, so
it's always retrieved in the same way without duplicating the code.

Change-Id: Ia9f63f56b508688e74278b022eaec47e503916e7
Signed-off-by: Alberto Garcia Hierro <alberto@garciahierro.com>
Reviewed-on: http://openocd.zylin.com/5872
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget: Examine subsequent targets after failure 55/5855/5
Kevin Yang [Mon, 12 Oct 2020 22:33:47 +0000 (15:33 -0700)]
target: Examine subsequent targets after failure

When a target examination fails, continue to examine subsequent targets.
Return the number of targets that failed to examine.

Change-Id: I883a0c445edc7eb00f496b79271d773771ec6b66
Signed-off-by: Kevin Yang <kangyang@google.com>
Reviewed-on: http://openocd.zylin.com/5855
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/image: Use proper data types 19/5919/3
Marc Schink [Tue, 3 Nov 2020 15:11:48 +0000 (16:11 +0100)]
target/image: Use proper data types

While at it, fix some coding style issues.

Change-Id: Id521394d89e0bf787a6f812701c2cc0fe7e4e63f
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5919
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoGitHub/WorkFlow: fix for CVE-2020-15228 66/5866/3
Tarek BOCHKATI [Mon, 2 Nov 2020 15:31:27 +0000 (16:31 +0100)]
GitHub/WorkFlow: fix for CVE-2020-15228

According the CVE-2020-15228 documented in:
 - https://github.com/advisories/GHSA-mfwh-5m23-j46w
 - https://nvd.nist.gov/vuln/detail/CVE-2020-15228

the `set-env` commands will be disabled in the near future
and should be replaced by:
    echo "FOO=BAR" >> $GITHUB_ENV

idem for `add-path`, should be replaced by:
    echo "/path/to/add" >> $GITHUB_PATH

Change-Id: I725c9ccd861a0d1580ac22491b6d716ec65973d1
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5866
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoGithub: add capstone in windows snapshots 15/5915/4
Tarek BOCHKATI [Mon, 2 Nov 2020 11:58:15 +0000 (12:58 +0100)]
Github: add capstone in windows snapshots

Change-Id: I402c18ff72de715ce4012bce3df72aaed7159d50
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5915
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agocontrib/cross-build.sh: build capstone from source 14/5914/3
Tarek BOCHKATI [Mon, 2 Nov 2020 15:12:11 +0000 (16:12 +0100)]
contrib/cross-build.sh: build capstone from source

tested with capstone 4.0.2, with the following options
CAPSTONE_CONFIG="CAPSTONE_ARCHS=arm,aarch64
                 CAPSTONE_BUILD_CORE_ONLY=yes
                 CAPSTONE_STATIC=yes
                 CAPSTONE_SHARED=no"

Change-Id: I40297772664e85c3d0f9358c85bfd901b5eba8b1
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5914
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/interface/ftdi: Add HIE JTAG Debugger config 10/5910/3
Jonathan McDowell [Sun, 1 Nov 2020 12:10:23 +0000 (12:10 +0000)]
tcl/interface/ftdi: Add HIE JTAG Debugger config

Change-Id: Ibb7a2bb8807c442394982e89258874557a2baaad
Signed-off-by: Jonathan McDowell <noodles@earth.li>
Reviewed-on: http://openocd.zylin.com/5910
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agodoc: Improve 'jlink usb' description 18/5918/2
Marc Schink [Tue, 3 Nov 2020 12:38:59 +0000 (13:38 +0100)]
doc: Improve 'jlink usb' description

Change-Id: Ica44980ac0ba8a4f0ff03b42ce37d1de861d4fb5
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5918
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agosemihosting: print the semihosting operation id 23/5923/3
Adrian Negreanu [Thu, 5 Nov 2020 09:56:16 +0000 (11:56 +0200)]
semihosting: print the semihosting operation id

Change-Id: If5c3568bd1c99a48ac492137f48da0d9764efe14
Signed-off-by: Adrian Negreanu <adrian.negreanu@nxp.com>
Reviewed-on: http://openocd.zylin.com/5923
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Reviewed-by: Tim Newsome <tim@sifive.com>
3 years agoarmv7m: add a TCP channel to stream captured trace 45/5345/9
Tarek BOCHKATI [Mon, 8 Jun 2020 22:47:46 +0000 (23:47 +0100)]
armv7m: add a TCP channel to stream captured trace

When trace capturing the trace is enabled using 'tpiu_config internal'
(via the internal mode), OpenOCD can collect the trace buffers then append
it to a specified file or named pipe and propagate the trace to 'tcl_trace'
command.
This change is allowing OpenOCD to stream the captured trace over TCP.

When using this configuration OpenOCD acts like a server and multiple
clients can connect and receive the captured trace.

Example on STM32F7 running at 216MHz:
  itm port 0 on
  tpiu config internal :3344 uart off 216000000

Change-Id: Idea43e7e26e87b98a33da7fb9acf7ea50fe3b345
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5345
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoserver: permit the add_service function to return the created service 17/5717/4
Tarek BOCHKATI [Mon, 8 Jun 2020 23:15:49 +0000 (00:15 +0100)]
server: permit the add_service function to return the created service

returning the created service seems useful:

as the only method to get the freshly created service is by getting the
last item in the services linked list, and this seems to be like an
intrusion to service internal mechanism.

possibly, we could get the service from a connection but this is possible
only from [new_connection|input|connection_closed]_handler_t, but this is
not always practical:
  example: armv7m: add a TCP channel to stream captured trace
           http://openocd.zylin.com/#/c/5345/
           here we poll for trace and broadcast to all connections
           outside of these xxx_handler_t functions

also, storing one of the connections in new_connection_handler_t and get
the service from it is possible, but this will make the code less readable.

Change-Id: I5fef1baecec1e054953c6faf5b99d864ecc97f02
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5717
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 years agoopenocd: convert function setup_command_handler() to static 02/5902/2
Antonio Borneo [Thu, 29 Oct 2020 13:51:33 +0000 (14:51 +0100)]
openocd: convert function setup_command_handler() to static

The function setup_command_handler() was used in the eCos build of
OpenOCD, thus it was exported and a comment was added to remark it
should remain not-static. Unfortunately the comment was missing
the relevant information of the special build that requires so.
Also unusual is that there is no include file that declares the
prototype of the function.

The comment above the function was added in two steps, in commit
ea3e49f4e22d ("fix embedded builds") and commit fb96b8607a0c
("openocd: setup_command_handler() must not be static"), again
without info about the special build.
Also the mailing list archive does not report any further detail.
The only hint is in the first commit above that also adds a test
on BUILD_ECOSBOARD in a #if.

Commit 39650e2273bc ("ecosboard: delete bit-rotted eCos code")
removes all the eCos code, that effectively includes the both the
prototype and the call to the function setup_command_handler(),
http://openocd.zylin.com/#/c/503/2/src/ecosboard.c@a1092
but did not reverted the function to static.

With all the 'external' uses of this function being dropped, set
the function setup_command_handler() to static and remove the
obsoleted and misleading comment.

Change-Id: I4d6b83dec2a838119821189fc67949bfca070035
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5902
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agotarget/adi_v5_jtag: remove unused global variable 01/5901/2
Antonio Borneo [Thu, 29 Oct 2020 00:34:37 +0000 (01:34 +0100)]
target/adi_v5_jtag: remove unused global variable

Change-Id: Ia4e8b90359c23f4be1d3677b44b0ebd063bb8dcc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5901
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agocortex_m: declare local functions as static 00/5900/2
Antonio Borneo [Wed, 28 Oct 2020 22:48:57 +0000 (23:48 +0100)]
cortex_m: declare local functions as static

Functions that are not used outside the file should be declared as
static.

Change-Id: Ie81f6bdce91e2a1456364b47f30aa4d35c7ee7bc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5900
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
3 years agortos: make private the API rtos_try_next() 99/5899/2
Antonio Borneo [Wed, 28 Oct 2020 22:44:07 +0000 (23:44 +0100)]
rtos: make private the API rtos_try_next()

The function rtos_try_next() is only used internally.
Make it private.

Change-Id: I68c6b8d8e6bbf3d674b0e0199e63bc02d358c04e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5899
Tested-by: jenkins
3 years agotransport: remove unused function transports_are_declared() 98/5898/2
Antonio Borneo [Wed, 28 Oct 2020 22:20:42 +0000 (23:20 +0100)]
transport: remove unused function transports_are_declared()

The only use of this function has been removed with commit
159f11fefc19 ("jtag: set default "jtag_only" to uninitialized
transports").

Get rid of the unused function.

Change-Id: I79dd1d55bd54ed8edc39ed3443e6c3c01794f063
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5898
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoserver: declare local functions as static 97/5897/3
Antonio Borneo [Wed, 28 Oct 2020 23:49:06 +0000 (00:49 +0100)]
server: declare local functions as static

Functions that are not used outside the file should be declared as
static.

Change-Id: I57b2fa6e49e87e14604bd34c4f1d2f037f401507
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5897
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agojtag: declare local symbols as static 96/5896/2
Antonio Borneo [Wed, 28 Oct 2020 23:47:12 +0000 (00:47 +0100)]
jtag: declare local symbols as static

Functions and variables that are not used outside the file should
be declared as static.

Change-Id: I58c9f5557d4809db9ccc34d32182c3797f825da1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5896
Tested-by: jenkins
3 years agotarget: declare local symbols as static 95/5895/2
Antonio Borneo [Wed, 28 Oct 2020 23:23:13 +0000 (00:23 +0100)]
target: declare local symbols as static

Functions and variables that are not used outside the file should
be declared as static.

Change-Id: I9f97571a528f0cb3c3c26f873577ab16fdec3cdc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5895
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agortos: declare local symbols as static 94/5894/2
Antonio Borneo [Wed, 28 Oct 2020 22:39:34 +0000 (23:39 +0100)]
rtos: declare local symbols as static

Functions and variables that are not used outside the file should
be declared as static.

Change-Id: I9731a35496cd1c7421563c8961da5fa0e3cc71c3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5894
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agoflash: declare local symbols as static 93/5893/3
Antonio Borneo [Wed, 28 Oct 2020 22:27:02 +0000 (23:27 +0100)]
flash: declare local symbols as static

Functions and variables that are not used outside the file should
be declared as static.

Change-Id: I52d46ed6d4c9b98a7152eb23274c836416f409a3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5893
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoopenocd: add support for libftdi 1.5 91/5891/3
Antonio Borneo [Tue, 27 Oct 2020 23:51:30 +0000 (00:51 +0100)]
openocd: add support for libftdi 1.5

The new libftdi 1.5 (2020-07-07) changes some API, deprecating the
old ones. This cause a warning at compile time.

Detect in configure the version of libftdi.
Use the new API in the driver's code.
Add an helper include file 'libftdi_helper.h' that wraps the old
API for backward compatibility with old libftdi.

Change-Id: I7800fbebe17dd0ce62e55b3598d8c08be8875bb7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/286/
Reviewed-on: http://openocd.zylin.com/5891
Tested-by: jenkins
3 years agoconfigure.ac: stop automake to search for scripts in parent dirs 90/5890/3
Antonio Borneo [Tue, 27 Oct 2020 21:56:49 +0000 (22:56 +0100)]
configure.ac: stop automake to search for scripts in parent dirs

Automake will search for the helper scripts in the folder that
contains the current Makefile.am (typically '.'), then some of the
scripts will be also searched in '..' and '../..'.

If the parent folders '..' or '../..' of OpenOCD source code
contain a file named 'install.sh', then automake will use it and
will assume that the same folder should contains also 'ltmain.sh'.
This situation can either cause the build to fail or automake to
use incorrect helper scripts.

Force automake to only search for helper scripts in the current
directory.

Change-Id: I00bbd6bf9057c94cf5007e5ecda3fefd683481f5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/285/
Reviewed-on: http://openocd.zylin.com/5890
Tested-by: jenkins
3 years agotarget: handle command 'target current' when no target is present 81/5881/2
Antonio Borneo [Fri, 23 Oct 2020 14:45:35 +0000 (16:45 +0200)]
target: handle command 'target current' when no target is present

Is it possible to run OpenOCD without any target, for example to
only dump the rom-tables of an arm dap, or to perform low level
jtag operations.
But without any target created, the command 'target current'
causes OpenOCD to abruptly exit.

Handle in command 'target current' the case of no targets.

Change-Id: Ide15cb13bec84b88ccc3e7126523c04a6d70e636
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5881
Tested-by: jenkins
3 years agogdb_server: allow multiple GDB connections to selected targets 65/5865/2
Antonio Borneo [Thu, 15 Oct 2020 12:45:27 +0000 (14:45 +0200)]
gdb_server: allow multiple GDB connections to selected targets

The default way of working is to have a single GDB attached to one
target, so OpenOCD accepts only one connection to the GDB port of
each targets and rejects any further connection.

There are some barely safe use cases in which it could get useful
having a second GDB connection to the same target.
One such use case is while using GDB as a 'non-intrusive memory
inspector', as explained in the OpenOCD documentation.
One GDB can be left running an infinite loop to dump some memory
area, or even analysing the content, while keeping a second GDB
ready for user interaction or spot memory check.

Add a target configure option to specify the maximum number of GDB
connections allowed for that target, keeping the default to 1.

Change-Id: I4985a602e61588df0b527d2f2aa5b955c93e125e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5865
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agotcl: replace '-ctibase' with '-baseaddr' 70/5870/4
Antonio Borneo [Sat, 17 Oct 2020 17:25:50 +0000 (19:25 +0200)]
tcl: replace '-ctibase' with '-baseaddr'

Replace the deprecated option '-ctibase' with the generic option
'-baseaddr'.

Change generated with command:
sed -i 's/-ctibase/-baseaddr/g' $(find tcl/ -type f)

Change-Id: If776934d2ac106532708768bb3a4ec6fcffb0368
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5870
Tested-by: jenkins
3 years agotarget/arm_cti: use adiv5_jim_mem_ap_spot_configure() 69/5869/4
Antonio Borneo [Sat, 17 Oct 2020 14:27:13 +0000 (16:27 +0200)]
target/arm_cti: use adiv5_jim_mem_ap_spot_configure()

To avoid code duplication, reorganize the code to replace
cti_configure() with adiv5_jim_mem_ap_spot_configure().

Reorganize 'struct arm_cti_object' and its sub-'struct arm_cti'
moving DAP and mem-AP info in a 'struct adiv5_mem_ap_spot'.
Replace cti_configure() with adiv5_jim_mem_ap_spot_configure().
Deprecate the use of '-ctibase' in favor of '-baseaddr'.

Change-Id: I43740a37c80de67c0f5e4dc79c3400b91a12e9e8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5869
Tested-by: jenkins
3 years agotarget/arm_adi_v5: add helper to get mem_ap spot in configure/cget 57/5857/6
Antonio Borneo [Sun, 11 Oct 2020 22:11:07 +0000 (00:11 +0200)]
target/arm_adi_v5: add helper to get mem_ap spot in configure/cget

This is somehow an extension of existing adiv5_jim_configure(),
but includes the 'address' in the mem_ap.
Rewrite adiv5_jim_configure() using the new helper.

Change-Id: Ia7effeeece044004d459b45126ed4961a98b8568
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5857
Tested-by: jenkins
3 years agostm32h7x.cfg: alignment with RM0399 rev3 61/5861/4
Tarek BOCHKATI [Wed, 14 Oct 2020 13:14:09 +0000 (14:14 +0100)]
stm32h7x.cfg: alignment with RM0399 rev3

in RM0399 rev2, there was these bits in DBGMCU_CR registers:
 - DBGSTBY_D3 : bit 7
 - DBGSTOP_D3 : bit 8

these bits have been changed to reserved in rev3

Change-Id: I9d10d90e383795dc8e25a117d59fa065dc594610
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5861
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agojtag/tcl: fix memory leak in error return 06/5906/2
Tomas Vanek [Thu, 29 Oct 2020 19:41:54 +0000 (20:41 +0100)]
jtag/tcl: fix memory leak in error return

Clang static analyzer reported:
Warning: line 196, column 3
Potential leak of memory pointed to by 'fields'

Free allocated memory pointed by 'fields' and fields[i].in_value

Change-Id: I0b3935d9a235544afc03e39a4648319047e65815
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5906
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agogdb_server: fix clang static analyzer warning 05/5905/2
Tomas Vanek [Thu, 29 Oct 2020 18:57:20 +0000 (19:57 +0100)]
gdb_server: fix clang static analyzer warning

Warning: line 373, column 15
Assigned value is garbage or undefined

Most probably a false warning, building the hex string byte
per byte seems too complicated for static analyze.

Change malloc to calloc to silence the warning.

Change-Id: I746d43fa51abf05582ccf2680ed72dc557798a7a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5905
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agohelper/command: fix clang static analyzer warning 04/5904/2
Tomas Vanek [Thu, 29 Oct 2020 17:32:13 +0000 (18:32 +0100)]
helper/command: fix clang static analyzer warning

Warning: line 955, column 3
Argument to free() is the address of a global variable, which
is not memory allocated by malloc()

It is definitely a false alarm. Simplify concatenation of arguments
and allocate a string always to silence the warning.

Change-Id: I5ac4cc610fc35224df0b16ef4f7102700363249f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5904
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
3 years agoflash/nor/atsamv: fix clang static analyzer warning 03/5903/2
Tomas Vanek [Thu, 29 Oct 2020 17:15:33 +0000 (18:15 +0100)]
flash/nor/atsamv: fix clang static analyzer warning

Warning: line 679, column 4
4th function call argument is an uninitialized value

Change-Id: If62d96e1595be945c8e17885bb402e820fb1ec7b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5903
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agotcl/board: fix changed target config filenames 88/5888/2
Antonio Borneo [Mon, 26 Oct 2020 16:58:33 +0000 (17:58 +0100)]
tcl/board: fix changed target config filenames

In commit a1ce28b118e7 ("rename some target scripts to be
consistent with the rest") the following renames was applied, but
the old names are still referenced:
tcl/target/{sam7se512.cfg => at91sam7se512.cfg}
tcl/target/{sam7x256.cfg => at91sam7x256.cfg}

Fix the board files to use to correct target config filename.

Change-Id: I7698aa0da7db95c2bd9ba7ab8c260905a975c857
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5888
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 years agotcl/board: drop 'tcl' prefix in 'find' command 87/5887/2
Antonio Borneo [Mon, 26 Oct 2020 16:54:55 +0000 (17:54 +0100)]
tcl/board: drop 'tcl' prefix in 'find' command

When OpenOCD is installed to the host the 'tcl' folder gets
usually installed in /usr/share/openocd/, thus having 'tcl' as
prefix of the target's file causes 'find' to fail.

Remove the 'tcl' folder prefix.

Change-Id: I3dc484c8de6af8f5aae4dd1b230522ee47ae2ba6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5887
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 years agotcl/interface/ti-icdi: remove empty lines at end of file 03/5603/3
Antonio Borneo [Fri, 24 Apr 2020 20:52:57 +0000 (22:52 +0200)]
tcl/interface/ti-icdi: remove empty lines at end of file

Change-Id: I031dc52c20b8f213b12df13c9c974d9ac3ef2164
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5603
Tested-by: jenkins
3 years agojtag: xlnx-pcie-xvc: Declare function static 89/5889/2
Moritz Fischer [Tue, 27 Oct 2020 16:48:06 +0000 (16:48 +0000)]
jtag: xlnx-pcie-xvc: Declare function static

The xlnx_pcie_xvc_execute_stableclocks() function can and
should be static.

Change-Id: I45fb1363caee1f1762b0b1ac2c6bc1bb0153b15b
Signed-off-by: Moritz Fischer <moritzf@google.com>
Reviewed-on: http://openocd.zylin.com/5889
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoboard: drop open-bldc 84/5884/2
Karl Palsson [Mon, 26 Oct 2020 10:51:15 +0000 (10:51 +0000)]
board: drop open-bldc

This is a) broken and b) doesn't include anything other than the
(broken) target alias.  Don't see any reason for it to exist.

Change-Id: I833635eeac392bf7c0c39f51ff2f76525ba2d406
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-on: http://openocd.zylin.com/5884
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agojtag/drivers/stlink_usb: fix SWO prescaler 56/5656/3
Cliff L. Biffle [Tue, 12 May 2020 20:28:04 +0000 (13:28 -0700)]
jtag/drivers/stlink_usb: fix SWO prescaler

The config_trace function has an out-parameter for generating the
prescaler for the TPIU. The STLink implementation wasn't always writing
it, causing the tpiu command to load uninitialized stack memory (minus
one) into the TPIU's prescaler register when 'external' was requested.

This change ensures that the out-parameter (and the other one,
trace_freq, which hadn't caused any buggy behavior for me) are written
every time.

Signed-off-by: Cliff L. Biffle <cliff@oxide.computer>
Change-Id: I222975869b1aa49cc6b1963c79d5ea0f46522b8c
Reviewed-on: http://openocd.zylin.com/5656
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget: restore last run state after profiling 37/5237/5
Christopher Head [Fri, 14 Jun 2019 22:35:31 +0000 (15:35 -0700)]
target: restore last run state after profiling

Now that it’s possible to start profiling from either a running or a
halted state, rather than unconditionally halting after profiling
finishes, it makes more sense to restore the processor to whatever state
(running or halted) it was in before profiling started.

Change-Id: If6f6e70a1a365c1ce3b348a306c435c220b8bf12
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5237
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/cortex_m: reduce duplication in profiling 36/5236/5
Christopher Head [Fri, 14 Jun 2019 22:25:26 +0000 (15:25 -0700)]
target/cortex_m: reduce duplication in profiling

The Cortex-M implementation of profiling contains a bunch of
conditionals and checks to handle both chips which have PCSR and chips
which do not. However, the net effect of the non-PCSR branches is
actually exactly the same as what target_profiling_default does. Rather
than duplicating this code, just detect the situation where PCSR isn’t
available and delegate to target_profiling_default.

Change-Id: I1be57ac77f983816ab6bf644a3cfca77b67d6f70
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5236
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget: allow profiling from running 35/5235/5
Christopher Head [Fri, 14 Jun 2019 22:12:28 +0000 (15:12 -0700)]
target: allow profiling from running

There are a handful of implementations of profiling. There is the
default implementation, which repeatedly halts and resumes the target,
sampling PC each time. There is the Cortex-M implementation, which
uses PCSR if available, otherwise falling back to halting and resuming
and sampling PC. There is the OR1K implementation, which reads NPC
repeatedly. Finally, there is the NDS32 implementation which uses some
kind of AICE commands with which I am unfamiliar.

None of these (with the possible exception of the NDS32
implementation) actually require the target to be halted when starting
profiling. The Cortex-M and OR1K actually resume the target as pretty
much their first action. The default implementation doesn’t do this,
but is written in such a way that the target just flips back and forth
between halted and running, and the code will do the right thing from
either initial state. The NDS32 implementation I don’t know about.

As such, for everything except NDS32, it is not really necessary that
the target be halted to start profiling. For the non-PCSR Cortex-M and
default implementations, there is no real harm in such a requirement,
because profiling is intrusive anyway, but there is no benefit. For
the PCSR-based Cortex-M and the OR1K, requiring that the target is
halted is annoying because it makes profiling more intrusive.

Remove the must-be-halted check from the target_profiling function.
Add it to the NDS32 implementation because I am not sure if that will
break when invoked with a running target. Do not add it to any of the
other implementations because they don’t need it.

Change-Id: I479dce999a80eccccfd3be4fa192c904f0a45709
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5235
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash/nor/nrf5: unify size of HWID 89/5589/2
Tomas Vanek [Mon, 13 Apr 2020 18:19:41 +0000 (20:19 +0200)]
flash/nor/nrf5: unify size of HWID

HWID is a part of 32 bit CONFIGID register. hwid member of struct nrf5_info
was typed uint32_t to enable direct CONFIGID read and masked afterwards.

Change to uint16_t to unify with hwid in struct nrf5_device_spec
and RM description.

Change-Id: Ib720d3ce23c301aee41d074ea78a6f00a23aed68
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5589
Tested-by: jenkins
3 years agoflash/nor/nrf5: improve handling of nRF52 flash errors 87/5587/2
Tomas Vanek [Mon, 13 Apr 2020 12:49:46 +0000 (14:49 +0200)]
flash/nor/nrf5: improve handling of nRF52 flash errors

nRF52 devices indicate a flash error by emitting hard fault
exception (unlike nRF51 series).

Change error message when NVMC READY read fails. A hard fault
from flash erase/write operation is detected here.

Check exit point of the flash write algo to ensure a failed
write is recognised.

Change-Id: I637eda268a6bf45f7f41bcb9dcd82db8f5cb41b4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5587
Tested-by: jenkins
3 years agoflash/nor/nrf5: check protection before flash erase/write on nRF51 22/5522/5
Tomas Vanek [Mon, 16 Mar 2020 14:49:54 +0000 (15:49 +0100)]
flash/nor/nrf5: check protection before flash erase/write on nRF51

nRF51 devices have a clumsy flash protection based on UICR CLENR0.
A code running in RAM can write to a protected flash region without
any hint the protection gets violated.
NVMC flash page erase obeys protection setting but fails absolutely
silently.

Before this change the first problem was not addressed in the code.
To justify the second one, protection was loaded during probe,
after protection setting and after a mass erase.

Move protection updates to the beginning of erase/write operation
and limit them to nRF51 series only. Check for protected sectors
before write.

The change also fixes the problem of 'nrf5 mass_erase' on
nRF52833/840 devices. They use ACL flash protection, which is not
supported in nrf5 driver. mass_erase then looked like it failed.

Change-Id: Ie58cda68eb104d410b02777c3df5b343408e2666
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5522
Tested-by: jenkins
3 years agoflash/nor/nrf5: fix protection setting on nRF51 86/5586/3
Tomas Vanek [Sun, 12 Apr 2020 08:15:00 +0000 (10:15 +0200)]
flash/nor/nrf5: fix protection setting on nRF51

Protection setting has not ever worked. UICR CLENR0 register cannot
be simply written but has to programmed because it resides in UICR
page of the flash.

Enable flash programming before writing CLENR0 and set back to r/o
afterwards.

Inform the user that reset might be required.

Change-Id: Ib0f96c74ba3583ac33f4394ddb57d8c8895adf53
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5586
Tested-by: jenkins
3 years agotcl/interface/ftdi: Add Steppenprobe open hardware interface 53/5653/3
Diego Herranz [Sun, 10 May 2020 17:57:46 +0000 (18:57 +0100)]
tcl/interface/ftdi: Add Steppenprobe open hardware interface

https://github.com/diegoherranz/steppenprobe

Change-Id: Ief2c3f4a8707fa628650697d93893b2355015898
Signed-off-by: Diego Herranz <diegoherranz@diegoherranz.com>
Reviewed-on: http://openocd.zylin.com/5653
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoserver/telnet: Handle Ctrl+K 68/5868/4
Brian Brooks [Sun, 18 Oct 2020 13:37:09 +0000 (08:37 -0500)]
server/telnet: Handle Ctrl+K

Handle Ctrl+K shortcut which clears the line from the cursor position
to the end of line.

Change-Id: I2ecff5284473cef7c11cf9cb7e1c0c97d55f6c1c
Signed-off-by: Brian Brooks <brooks.brian@gmail.com>
Reviewed-on: http://openocd.zylin.com/5868
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
3 years agotarget/arc: introduce watchpoints support 67/5867/3
Evgeniy Didin [Thu, 30 Jul 2020 21:02:38 +0000 (00:02 +0300)]
target/arc: introduce watchpoints support

With help of actionpoint mechanism now it is possible to introduce
watchpoints support for ARC.

Change-Id: I5887335d0ba38c15c377bc1d24a1ef36e138cf65
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5867
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoAdded comment to ti-icdi.cfg 28/2528/4
John Pham [Tue, 3 Feb 2015 02:22:38 +0000 (21:22 -0500)]
Added comment to ti-icdi.cfg

Added comment to ti-icdi.cfg specifying how to get serial and an example of
specifying hla_serial for ti-icdi devices. This has been implemented in revision
2121a8f92969804611412b705af8114697a647dc

Change-Id: I648458a4dea176beae6a3f1a4e5641d0206077eb
Signed-off-by: John Pham <jhnphm@gmail.com>
Reviewed-on: http://openocd.zylin.com/2528
Tested-by: jenkins
Reviewed-by: Matthew Trescott <matthewtrescott@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoEnable hla_serial for TI ICDI devices 27/2527/5
John Pham [Mon, 2 Feb 2015 10:23:32 +0000 (05:23 -0500)]
Enable  hla_serial for TI ICDI devices

Used jtag_libusb_open from libusb_helper.h instead of
libusb_open_device_with_vid_pid to get device handle,
as well as managing context, i.e. similar to stlink_usb.
Direct calls to libusb1 are left in for the moment.

(When this Gerrit revision was originally created,
the jtag_libusb_ wrappers did not return error conditions.)

Tested w/ a TM4C123GXL board

Change-Id: I71e9a366356c125444d4813e58ddd9b6c6498bf0
Signed-off-by: John Pham <jhnphm@gmail.com>
Signed-off-by: Matthew Trescott <matthewtrescott@gmail.com>
Reviewed-on: http://openocd.zylin.com/2527
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash/stm32l4: add support of STM32G4 category 4 devices (G491/G4A1) 93/5793/3
Tarek BOCHKATI [Thu, 15 Oct 2020 16:05:48 +0000 (17:05 +0100)]
flash/stm32l4: add support of STM32G4 category 4 devices (G491/G4A1)

STM32G4 cat.4 devices are up to 512 KB of flash memory (single bank)
organized into pages of 2KB each.

Reference: RM0440 rev.4

Change-Id: I0f510e2806c8f824fff8083e2d4f90d68f01046b
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5793
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agotcl/target/nrf52: fix nrf52_recover 45/5845/2
Tomas Vanek [Thu, 1 Oct 2020 10:36:00 +0000 (12:36 +0200)]
tcl/target/nrf52: fix nrf52_recover

nrf52_recover was merged in pre "Handle Tcl return values consistently"
state - remove ocd_ prefixes.

Erase and unlock sequence was changed to comply Nordic semiconductor
recommendation:
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fnwp_027%2FWP%2Fnwp_027%2FnWP_027_erasing.html

Change-Id: Ic54236c27cf25ad8091e9e572ba1ef846f0d47c2
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reported-by: Pieter De Gendt <pieter.degendt@gmail.com>
Reviewed-on: http://openocd.zylin.com/5845
Tested-by: jenkins
Reviewed-by: Pieter De Gendt <pieter.degendt@gmail.com>
3 years agocortex_m: support control.FPCA 53/5853/3
Sylvain Chouleur [Mon, 12 Oct 2020 15:24:05 +0000 (17:24 +0200)]
cortex_m: support control.FPCA

Bit 2 of control register is used if the processor includes the FP
extension

Change-Id: Ie21bc9de8cae5bad9d841e1908eff3aa0bb29d4b
Signed-off-by: Sylvain Chouleur <schouleur@graimatterlabs.ai>
Reviewed-on: http://openocd.zylin.com/5853
Reviewed-by: Sylvain Chouleur <sylvain.chouleur@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoriscv: fix compile error 56/5856/2
Antonio Borneo [Wed, 14 Oct 2020 08:41:12 +0000 (10:41 +0200)]
riscv: fix compile error

The commit b68674a1da72 ("Upstream tons of RISC-V changes.") was
proposed well before commit 3ac010bb9f10 ("Fix debug prints when
loading to flash"), but the merge got in different order.
After latest merge, the master branch fails to compile.

Fix the compile error.

Change-Id: Ia3bd21d970d589343a3b9b2d58c89e0c49f30015
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5856
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
3 years agoUpstream tons of RISC-V changes. 21/5821/11
Tim Newsome [Wed, 19 Aug 2020 20:24:56 +0000 (13:24 -0700)]
Upstream tons of RISC-V changes.

These are all the changes from https://github.com/riscv/riscv-openocd
(approximately 91dc0c0c) made just to src/target/riscv/*. Some of the
new code is disabled because it requires some other target-independent
changes which I didn't want to include here.

Built like this, OpenOCD passes:
* All single-RV32 tests against spike.
* All single-RV64 tests against spike.
* Enough HiFive1 tests. (I suspect the failures are due to the test
suite rotting.)
* Many dual-RV32 (-rtos hwthread) against spike.
* Many dual-RV64 (-rtos hwthread) against spike.

I suspect this is an overall improvement compared to what's in mainline
right now, and it gets me a lot closer to getting all the riscv-openocd
work upstreamed.

Change-Id: Ide2f80c9397400780ff6780d78a206bc6a6e2f98
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/5821
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
3 years agoflash/nor/at91sam4: ATSAMG55x19 Rev.B 25/5825/3
Benedikt-Alexander Mokroß [Mon, 24 Aug 2020 08:59:27 +0000 (10:59 +0200)]
flash/nor/at91sam4: ATSAMG55x19 Rev.B

Add support for ATSAMG55x19 Rev.B.
Both chips have nearly the same cidr, however, Rev.B has an incremented version.

Change-Id: I5939c41fa5d54c4d3bfb850964974b878f709d13
Signed-off-by: Benedikt-Alexander Mokroß <mokross@gessler.de>
Reviewed-on: http://openocd.zylin.com/5825
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 years agotarget/aarch64: fix use of 'target->private_config' 47/5847/2
Antonio Borneo [Wed, 16 Sep 2020 13:26:40 +0000 (15:26 +0200)]
target/aarch64: fix use of 'target->private_config'

The function adiv5_jim_configure() casts the void pointer
'target->private_config' to a struct adiv5_private_config pointer.
This is tricky in case of aarch64, where the private data are in a
struct aarch64_private_config that has as first element the struct
adiv5_private_config.

While the current solution is working fine, it's not clean and
requires special attention for any further code development.

Override 'target->private_config' to the correct pointer while
calling adiv5_jim_configure().

Change-Id: Ic2fc047dd1e57013943d96e6d5879a919d1eb7b3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5847
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agotarget/aarch64: Use apnum setting 31/5831/4
Kevin Yang [Thu, 3 Sep 2020 03:15:31 +0000 (20:15 -0700)]
target/aarch64: Use apnum setting

Change aarch64 to use ap-num setting if provided. Fall back to original
behavior of using first AP when ap-num is invalid.

Change-Id: I0d3624f75c86ba5fd5a322ac60856dbbb6e71eaf
Signed-off-by: Kevin Yang <kangyang@google.com>
Reviewed-on: http://openocd.zylin.com/5831
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agodrivers/jlink: fix (again) calculate_swo_prescaler formula 46/5846/2
Antonio Borneo [Thu, 1 Oct 2020 12:19:16 +0000 (14:19 +0200)]
drivers/jlink: fix (again) calculate_swo_prescaler formula

The prescaler computation should round at the nearest integer
value, not to the next integer value.

Change-Id: I957e0774421211f3c4ba4b312738b1c67b87c4a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 051e80812b1b ("drivers/jlink: fix calculate_swo_prescaler formula")
Reviewed-on: http://openocd.zylin.com/5846
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
3 years agoUpdate user dir config file search path 90/3890/6
Andreas Fritiofson [Sat, 24 Dec 2016 10:38:04 +0000 (11:38 +0100)]
Update user dir config file search path

Search in XDG_CONFIG_HOME as per XDG Base Directory Specification
in addition to $HOME/.openocd.

On Darwin, search in ~/Library/Preferences/org.openocd/ which
appears to be one of the conventional locations.

Make $OPENOCD_SCRIPTS highest priority on all platforms, previously
it was only higher on WIN32.

Update the documentation to reflect the search order.

Change-Id: Ibaf4b59b51fdf452712d91b47ea2b5312bb5ada9
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/3890
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoFreeRTOS: strip duplicate line returns 43/5843/3
Karl Palsson [Thu, 24 Sep 2020 14:29:36 +0000 (14:29 +0000)]
FreeRTOS: strip duplicate line returns

Log lines already print a new line, so these superfluous \r\n result in
blank lines being printed in the log.  Remove per review comment
request.

Change-Id: I8f5b20776634cf70ce4490fc4f732c916130928a
Signed-off-by: Karl Palsson <karlp@etactica.com>
Reviewed-on: http://openocd.zylin.com/5843
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 years agoFreeRTOS: properly read on big endian systems. 42/5842/3
Karl Palsson [Thu, 24 Sep 2020 09:09:11 +0000 (09:09 +0000)]
FreeRTOS: properly read on big endian systems.

Remember, don't cast your pointers between types of different sizes!

While the FreeRTOS handlers attempt to account for different pointer and
list widths, the types used are always fixed, so this will _remain_
broken if/when someone targets FreeRTOS on 8/16/64 bit targets. (Note
that this patch does not _change_ that, it was fixed to 32bit before as
well)

In the meantime, this properly handles 32bit reads on a mips BE system
(ath79) as well as remaining fully functional on x86_64.

Change-Id: I677bb7130e25dccb7c1bee8fabaee27371494d00
Signed-off-by: Karl Palsson <karlp@etactica.com>
Reviewed-on: http://openocd.zylin.com/5842
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 years agoARM|Driver: Add DPI Driver for emulation 73/5573/7
Kevin Burke [Sat, 4 Apr 2020 00:47:50 +0000 (20:47 -0400)]
ARM|Driver: Add DPI Driver for emulation

This driver provides support for Cadence JTAG BFM

The "jtag_dpi" driver implements a JTAG driver acting as a client for the
SystemVerilog Direct Programming Interface (DPI) for JTAG devices.
DPI allows OpenOCD to connect to the JTAG interface of a hardware model
written in SystemVerilog, for example, on an emulation model of
target hardware.

Tested on Ampere emulation with Altra and Altra Max models

Change-Id: Iaef8ba5cc1398ee2c888f39a606e8cb592484625
Signed-off-by: Kevin Burke <kevinb@os.amperecomputing.com>
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-on: http://openocd.zylin.com/5573
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/cortex_m.c: vector_catch command checks if a target is examined 13/5813/2
Daniel Trnka [Mon, 17 Aug 2020 15:51:43 +0000 (17:51 +0200)]
target/cortex_m.c: vector_catch command checks if a target is examined

If a target is not examined, command vector_catch crashes while accessing
the debug_ap NULL pointer.

maskisr and reset_config commands don't require this check.

Change-Id: I949b6f6e8b983327dd98fbe403735141f8f0b5d6
Signed-off-by: Daniel Trnka <daniel.trnka@gmail.com>
Reviewed-on: http://openocd.zylin.com/5813
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/aarch64: a64 disassembler 04/5004/5
Mete Balci [Sat, 30 Mar 2019 11:27:57 +0000 (12:27 +0100)]
target/aarch64: a64 disassembler

Add A64 (AArch64) Disassembler using Capstone framework.

Change-Id: Ia92b57001843b11a818af940a468b131e42a03fd
Signed-off-by: Mete Balci <metebalci@gmail.com>
[Antonio Borneo: Rebased on current HEAD]
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5004
Tested-by: jenkins
3 years agotcl: board/dp_busblaster_v4 Busblaster v4.1a by Seed Studio added 49/5549/5
Ulrich-Lorenz Schlüter [Tue, 31 Mar 2020 08:05:47 +0000 (10:05 +0200)]
tcl: board/dp_busblaster_v4 Busblaster v4.1a by Seed Studio added

Change-Id: I53141d7f6f022f9dee641858f5fb0e0b70c049f8
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Ulrich-Lorenz Schlüter <audiomobster@gmail.com>
Reviewed-on: http://openocd.zylin.com/5549
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/board: Add QuickLogic QuickFeather configuration 03/5803/4
Jan Kowalewski [Thu, 9 Jul 2020 10:34:22 +0000 (12:34 +0200)]
tcl/board: Add QuickLogic QuickFeather configuration

Add configuration for QuickLogic QuickFeather development kit.

Change-Id: I39120714bf0bcafa86e0071c38da84a7d9f12a0d
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
Reviewed-on: http://openocd.zylin.com/5803
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 years agotcl/target: Add QuickLogic EOS S3 MCU configuration 02/5802/3
Jan Kowalewski [Fri, 3 Jul 2020 16:19:01 +0000 (18:19 +0200)]
tcl/target: Add QuickLogic EOS S3 MCU configuration

Add configuration for QuickLogic EOS S3 MCU target.

Change-Id: I375057ff387a826e632f194843dbd92148b0c5dd
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
Reviewed-on: http://openocd.zylin.com/5802
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agodrivers/jlink: fix calculate_swo_prescaler formula 07/5807/4
Adrian Negreanu [Mon, 7 Sep 2020 19:36:10 +0000 (22:36 +0300)]
drivers/jlink: fix calculate_swo_prescaler formula

a) TPIU_ACPR is defined as:
SWO_baudrate = TRACECLKIN/(TPIU_ACPR +1)

b) TPIU_ACPR is set by armv7m_trace_tpiu_config()
target_write_u32(target, TPIU_ACPR, Prescaler-1), so
TPIU_ACPR = Prescaler-1

Replacing TPIU_ACPR in a), we get:
SWO_baudrate = TRACECLKIN/Prescaler, so

c) Prescaler = TRACECLKIN/SWO_baudrate

The Prescaler calculated by calculate_swo_prescaler() is greater by 1:
Prescaler = TRACECLKIN/SWO_baudrate + 1

The second problem is that even in situations when
an exact baudrate match is possible,
the resulting TRACECLKIN/Prescaler already has a 3% deviation.

For example, TRACECLKIN=88000000, SWO_baudrate=500000,
calculate_swo_prescaler will return Prescaler=171.
The correct value should be Prescaler=176 (TPIU_ACPR=175).

Might be related to https://sourceforge.net/p/openocd/tickets/263/

Change-Id: Ib4d6df6e34685a9be4c2995cb500b2411c76e39b
Signed-off-by: Adrian Negreanu <adrian.negreanu@nxp.com>
Reviewed-on: http://openocd.zylin.com/5807
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoAdd support of STM32H72x/73x 1M (0x483) 92/5792/3
Tarek BOCHKATI [Tue, 11 Aug 2020 11:34:50 +0000 (12:34 +0100)]
Add support of STM32H72x/73x 1M (0x483)

STM32H72x/73x flash is similar to STM32H74x/75x,
except STM32H72x/73x devices have only one single flash bank.

Change-Id: I3d3422dc60234f8273172924f426200210f388cc
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5792
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoUse capstone for ARM disassembler 12/4812/7
Marc Schink [Wed, 12 Aug 2020 11:54:10 +0000 (13:54 +0200)]
Use capstone for ARM disassembler

Change-Id: I1c9bf3f8178d4a06babe23a918e4411833ebc418
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/4812
Tested-by: jenkins
Reviewed-by: Fredrik Hederstierna <fredrik@hederstierna.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agocortex_m: add detection of Cortex M35P and M55 99/5799/2
Tarek BOCHKATI [Tue, 11 Aug 2020 14:23:19 +0000 (15:23 +0100)]
cortex_m: add detection of Cortex M35P and M55

Change-Id: I52599b2b09c2dc50c95d64059213c832d380ea31
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5799
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agocortex_m: read and display core security state 98/5798/2
Tarek BOCHKATI [Tue, 11 Aug 2020 13:06:04 +0000 (14:06 +0100)]
cortex_m: read and display core security state

Change-Id: I0fce3c66af7e98df2dc2258daf0d6af661e29ae7
Signed-off-by: Laurent LEMELE <laurent.lemele@st.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5798
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoarmv8-m: add SecureFault exception 97/5797/2
Tarek BOCHKATI [Tue, 11 Aug 2020 11:56:36 +0000 (12:56 +0100)]
armv8-m: add SecureFault exception

Change-Id: I4e1963631e834b6334bc917e956c2db4464b7b08
Signed-off-by: Laurent LEMELE <laurent.lemele@st.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5797
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoGitHub: add workflow to provide an openocd snapshot binaries for win32 94/5594/10
Tarek BOCHKATI [Tue, 2 Jun 2020 21:03:18 +0000 (22:03 +0100)]
GitHub: add workflow to provide an openocd snapshot binaries for win32

This change could be used within OpenOCD GitHub forks.

Once workflow actions are enabled in the GitHub project, this workflow
will be run automatically on each push into OpenOCD.

This workflow will provide a neutral build of openocd for win32, then
the package will be available for download in Actions section.
Note: the artifact will be deleted after 90 day (actual GitHub rules)

If the push is a tag, the generated package will be uploaded to release
pane under the corresponding release, and it will resides forever.

The built openocd enables libusb1, hidapi and libftdi adapters,
and could be extended to cover more adapters and Oses

PS: ./contrib/cross-build.sh updated to build libftdi from source like
libusb1 and hidapi.

Change-Id: I290c8aa14a12548e2dcb6a0eee456430ea44ab9f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5594
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget: avoid checking for non NULL pointer to free it 09/5809/3
Antonio Borneo [Mon, 17 Aug 2020 07:58:58 +0000 (09:58 +0200)]
target: avoid checking for non NULL pointer to free it

The function free() can be called with a NULL pointer as argument,
no need to check the argument before. If the pointer is NULL, no
operation is performed by free().

Remove the occurrences of pattern:
if (ptr)
free(ptr);

In target/openrisc/jsp_server.c, an error is logged if the ptr was
already NULL. This cannot happen since the pointer was already
referenced few lines before and openocd would have been already
SIGSEGV in that case, so remove the log.

Change-Id: I290a32e6d4deab167676af4ddc83523c830ae49e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5809
Tested-by: jenkins
3 years agodrivers/buspirate: remove empty lines at end of file 04/5604/2
Antonio Borneo [Fri, 24 Apr 2020 20:59:13 +0000 (22:59 +0200)]
drivers/buspirate: remove empty lines at end of file

Change split from http://openocd.zylin.com/5172/ to avoid
conflicts with other pending changes in gerrit.

Change-Id: Id3e21c92b3da7ddce7b00664280da2143c06f172
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5604
Tested-by: jenkins
3 years agojtag: avoid checking for non NULL pointer to free it 10/5810/3
Antonio Borneo [Mon, 17 Aug 2020 08:05:11 +0000 (10:05 +0200)]
jtag: avoid checking for non NULL pointer to free it

The function free() can be called with a NULL pointer as argument,
no need to check the argument before. If the pointer is NULL, no
operation is performed by free().

Remove the occurrences of pattern:
if (ptr)
free(ptr);

Change-Id: I2938e333bd1eac5218bd67aefb9d8f373da017a8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5810
Tested-by: jenkins
3 years agoopenrisc: Fix segv jsp due to free of unallocated data 93/4093/2
Stafford Horne [Tue, 4 Apr 2017 21:11:30 +0000 (06:11 +0900)]
openrisc: Fix segv jsp due to free of unallocated data

The prompt pointer in the jtag serial port is never zero'd or allocated.
Completely remove it since there is not much use for it as the target
software will provide the actual prompt.

Change-Id: Id95d8ccb9f725e53b9d03386b11d91eba1cd6ef4
Signed-off-by: Stafford Horne <shorne@gmail.com>
Reviewed-on: http://openocd.zylin.com/4093
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoopenocd: fix command's usage string 24/5824/2
Antonio Borneo [Sat, 22 Aug 2020 23:43:21 +0000 (01:43 +0200)]
openocd: fix command's usage string

The usage string should contain only the command parameters.
OpenOCD will automatically prepend the command name to the usage
string while dumping the usage or help message.

Remove the repeated command name from the usage string.

Change-Id: If10a0f1c254aee302b9ca08958390b7f21cdb21b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5824
Tested-by: jenkins

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)