openocd.git
4 years agoflash/stm32h7x: add support of STM32H7Ax/H7Bx devices 41/5441/6
Tarek BOCHKATI [Thu, 6 Feb 2020 23:12:48 +0000 (00:12 +0100)]
flash/stm32h7x: add support of STM32H7Ax/H7Bx devices

this new device has the following features:
 - single core cortex-M7
 - 2MB flash - dual bank
    - page size 8k
    - write protection grouped by 4 sectors
    - write block size 128 bits (16 bytes)

the bit definition of FLASH_CR is different than STM32H74x,
that's why we introduced a helper to compute the FLASH_CR value

Change-Id: I4da10cde8dd215b1b0f2645f0efdba9d198038d1
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5441
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoAdd support for SAMD21E17D device 58/5458/3
Michael Stoll [Wed, 19 Feb 2020 16:32:26 +0000 (17:32 +0100)]
Add support for SAMD21E17D device

Change-Id: Id0a533f8899b20cc87e3a9143383ddf279c86301
Signed-off-by: Michael Stoll <michael.stoll@meadow-robotics.com>
Reviewed-on: http://openocd.zylin.com/5458
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agotarget/arc: fix clang static analyzer warnings 80/5480/2
Evgeniy Didin [Fri, 28 Feb 2020 08:14:42 +0000 (11:14 +0300)]
target/arc: fix clang static analyzer warnings

Fixes:
* Removed typo in *bitfields initializations.
* Removed potentional memory leak allocating
  reg_data_type_struct_field/reg_data_type_flags_field objects.
* Initialize buffers with "0" before usage in buf_set_u32().
* Removed memory leak in jim_arc_add_reg().

Change-Id: Iefde57cd4a48c4f3350c376475df8642607f52ff
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5480
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoIntroduce ARCv2 architecture related code 32/5332/13
Evgeniy Didin [Mon, 27 Jan 2020 12:22:27 +0000 (15:22 +0300)]
Introduce ARCv2 architecture related code

This patch is an initial bump of ARC-specific code
which implements the ARCv2 target(EMSK board) initializing
routine and some basic remote connection/load/continue
functionality.

Changes:
03.12.2019:
-Add return value checks.
-Using static code analizer next fixes were made:
        Mem leak in functions:
                arc_jtag_read_memory,arc_jtag_read_memory,
                arc_jtag_write_registers, arc_jtag_read_registers,
                jim_arc_add_reg_type_flags, jim_arc_add_reg_type_struct,
                arc_build_reg_cache, arc_mem_read.
        Dead code in "arc_mem_read";
        In arc_save_context, arc_restore_context correct arguments
        in"memset" calls.
        In "build_bcr_reg_cache", "arc_build_reg_cache" check
        if list is not empty.

29.12.2019
-Moved code from arc_v2.c to arc.c
-Added checks of the result of calloc/malloc calls
-Reworked arc_cmd.c: replaced spagetty code with functions
-Moved to one style in if statements - to "if(!bla)"
-Changed Licence headers

22.01.2020
-Removed unused variables in arc_common
-Renamed register operation functions
-Introduced arc_deinit_target function
-Fixed interrupt handling in halt/resume:
        * add irq_state field in arc_common
        * fix irq enable/disable calls ( now STATUS32 register is used)
-Switched from buf_set(get)_us32() usage to target_buffer_set(get)_u32()
-Made some cleanup

30.01.2020
-Removed redundant arc_register struct, moved target link to arc_reg_desc
-Introduced link to BCR reg cache in arc_common for freeing memory.
-Now arc_deinit_target frees all arc-related allocated memory.
Valgrind shows no memory leaks.
-Inroduced arch description in arc.c

01.02.2020
-Remove small memory allocations in arc_init_reg. Instead created reg_value
and feature fields in arc_reg_desc.
-Add return value for arc_init_reg() func.
-Replaced some integer constants(61,62,63) with defines.
-Removed redundant conversions in arc_reg_get_field().
-Moved iccm/dccm configuration code from arc_configure()
to separate functions.

19.02.2020
-Change sizeof(struct) to sizeof(*ptr) in allocations
-Changed if/while(ptr != NULL) to if/while(ptr)
-Removed unused variables from struct arc_jtag
-Add additional structs to arc_reg_data_type
 to reduce amount of memory allocations calls
 and simplifying memory freeing.
-Add helper arc_reg_bitfield_t struct which includes
 reg_data_type_bitfield object and char[] name. Reduces
 memory allocations calls.
-Add limit for reg_type/reg_type_field names(20 symbols).
-Add in jim_arc_add_reg_type*() functions additional
 argnument checks(amount of field/name size).
-In jim_arc_add_reg_type*() reduced amount of memory allocations.
-Cleanup of jim_arc_add_reg_type*() functions.
-For commands update ".usage" fields according docopt.
-Cleanup in arc_jtag.c
-Renamed functions which require jtag_exeutre_queue() to arc_jtag_enque_*()
-Add arc_jtag_enque_register_rw() function, which r/w to jtag ir/dr regs
 during regiter r/w.

24.02:
-Change include guards in arc* files according coding style
-Remove _t suffix in struct arc_reg_bitfield_t
-Some cleanup

Change-Id: I6ab0e82b12e6ddb683c9d13dfb7dd6f49a30cb9f
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5332
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agocoding style: doc: remove empty lines at end of text files 70/5170/4
Antonio Borneo [Sun, 12 May 2019 10:52:59 +0000 (12:52 +0200)]
coding style: doc: remove empty lines at end of text files

Empty lines at end of text files are useless.
Remove them.

Change-Id: I30e4d3d03c4ce846aa7bcefa7366f88732275557
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5170
Tested-by: jenkins
4 years agocoding style: testing: remove empty lines at end of text files 69/5169/4
Antonio Borneo [Sun, 12 May 2019 10:51:28 +0000 (12:51 +0200)]
coding style: testing: remove empty lines at end of text files

Empty lines at end of text files are useless.
Remove them.

Change-Id: Id05a7bd944edccaa03ed9eb48599b2e262664cf0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5169
Tested-by: jenkins
4 years agocoding style: tools: remove empty lines at end of text files 68/5168/4
Antonio Borneo [Sun, 12 May 2019 10:38:18 +0000 (12:38 +0200)]
coding style: tools: remove empty lines at end of text files

Empty lines at end of text files are useless.
Remove them.

Change-Id: Iea4c8425e137d6252fb2e5b62e0b124c73a01cb6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5168
Tested-by: jenkins
4 years agocoding style: add newline at end of text files 67/5167/5
Antonio Borneo [Sun, 12 May 2019 10:26:46 +0000 (12:26 +0200)]
coding style: add newline at end of text files

Some text file is missing newline at EOF.
Add it.

Change-Id: Ieebc790096f40961283c644642e56fde975e957f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5167
Tested-by: jenkins
4 years agocoding style: fix space around pointer's asterisk 97/5197/4
Antonio Borneo [Sun, 5 May 2019 19:26:56 +0000 (21:26 +0200)]
coding style: fix space around pointer's asterisk

The script checkpatch available in new Linux kernel offers an
experimental feature for automatically fix the code in place.
While still experimental, the feature works quite well for simple
fixes, like spacing.

This patch has been created automatically with the script under
review for inclusion in OpenOCD, using the command
find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types POINTER_LOCATION --fix-inplace -f {} \;
then manually reviewed.

OpenOCD coding style does not mention the space around pointer's
asterisk, so no check is enforced. This patch only makes the style
uniform across the files.

The patch only changes amount and position of whitespace, thus
the following commands show empty diff
git diff -w
git log -w -p
git log -w --stat

Change-Id: Iefb4998e69bebdfe0d1ae65cadfc8d2c4f166d13
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5197
Tested-by: jenkins
4 years agolog: let command "log_output" to set back its default 33/5233/3
Antonio Borneo [Fri, 14 Jun 2019 08:00:06 +0000 (10:00 +0200)]
log: let command "log_output" to set back its default

The default log output is stderr. After the command "log_output"
has been used to set an output log file, it is possible to return
back to stderr only on *NIX hosts specifying a new log output file
as "/dev/stderr", but this is not intuitive, not documented and
not portable out of *NIX.

Make command "log_output" able to set back the default output to
stderr when the parameter is either "default" or is missing.
While there, add debug message to log the change and make the
command return error on incorrect syntax.

Change-Id: I8c7c929780f58e2c23936737c8e7274a96734786
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5233
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoadi_v5_dapdirect: fix connect under reset 15/5415/3
Antonio Borneo [Thu, 23 Jan 2020 14:18:33 +0000 (15:18 +0100)]
adi_v5_dapdirect: fix connect under reset

Deassert the reset only if connect under reset is not required;
otherwise, assert the reset.
This fix aligns the behavior of connect under reset in dapdirect
with the behavior in jtag and swd.

Change-Id: I937ef4320b44e51ef6cb0e349e12348dbfbe4abb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5415
Tested-by: jenkins
4 years agoflash/nor/stm32l4x: Minor code cleanups 49/5449/2
Marc Schink [Mon, 10 Feb 2020 14:37:45 +0000 (15:37 +0100)]
flash/nor/stm32l4x: Minor code cleanups

Change-Id: I3053bbe888ac1f0a0593ef51bf9ca564f1cc27ec
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5449
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agoflash/nor/stm32h7x: Minor code cleanups 48/5448/2
Marc Schink [Mon, 10 Feb 2020 14:39:19 +0000 (15:39 +0100)]
flash/nor/stm32h7x: Minor code cleanups

Change-Id: Ia212b1877abeda27f507de29a3aee2b171c1b8c6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5448
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
4 years agoSupport bitbanging on 64-bit ARM CPUs. 74/5274/2
Mara Bos [Fri, 9 Aug 2019 09:59:24 +0000 (11:59 +0200)]
Support bitbanging on 64-bit ARM CPUs.

The configure.ac file restricted this to only 'arm' CPUs, but
${host_cpu} is 'aarch64' (not 'arm') for 64 bit ARM CPUs.

Tested on a Raspberry Pi compute module 3.

Change-Id: I6cb1d7e7fadc51dbb12419176f1faf0a0cb0b228
Signed-off-by: Mara Bos <m-ou.se@m-ou.se>
Reviewed-on: http://openocd.zylin.com/5274
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agotcl/board: update ST NUCLEO-H745ZI-Q configuration file to use dapdirect 16/5316/3
Tarek BOCHKATI [Wed, 12 Feb 2020 11:14:06 +0000 (12:14 +0100)]
tcl/board: update ST NUCLEO-H745ZI-Q configuration file to use dapdirect

this board embeds and STLINK DAP capable firmware

Change-Id: I276e9f44ad6cf7d1ff664898bbc884676bdbc967
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5316
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agotarget/adi_v5_swd: fix clang static analyzer warning 74/5374/3
Tomas Vanek [Fri, 20 Dec 2019 22:41:55 +0000 (23:41 +0100)]
target/adi_v5_swd: fix clang static analyzer warning

Change-Id: I24b3e74b62fad469e3150ad97a10a9ab69c2793b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5374
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoflash/nor/tcl.c: add filld command to write double-word with 64-bit value 43/5443/2
Tarek BOCHKATI [Fri, 7 Feb 2020 17:36:29 +0000 (18:36 +0100)]
flash/nor/tcl.c: add filld command to write double-word with 64-bit value

Change-Id: I2eeda7af7d855ed1284083d025994f8fa9531969
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5443
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor/stm32l4x: lock flash after error 61/5361/4
Tomas Vanek [Sat, 14 Dec 2019 18:37:41 +0000 (19:37 +0100)]
flash/nor/stm32l4x: lock flash after error

Also add locking after option write, it was missing at all.

Change-Id: I0227c6a74866f0fe8e40aa58616f0b3115ad5af0
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5361
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
4 years agotcl/board: Add imx8mp-evk 27/5427/3
Leonard Crestez [Sat, 1 Feb 2020 00:02:04 +0000 (02:02 +0200)]
tcl/board: Add imx8mp-evk

Board includes an internal adapter (interface/ftdi/imx8mp-evk.cfg) and a
standard external ARM-10 connector.

Change-Id: Ibb301011665b1edfb95be1213d8100143f6839dd
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-on: http://openocd.zylin.com/5427
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agotcl/interface/ftdi: Add imx8mp-evk internal JTAG interface 26/5426/3
Leonard Crestez [Fri, 31 Jan 2020 23:53:35 +0000 (01:53 +0200)]
tcl/interface/ftdi: Add imx8mp-evk internal JTAG interface

The imx8mp-evk board has a FT4232H chip connected to the chip's JTAG
pins.

Switching between this on-board interface and the external ARM-10
connector is controlled by an GPIO which is behind an i2c expander
connected to the same FTDI chip.

Switching can be performed using the NXP bcu tool:

https://github.com/NXPmicro/bcu

Change-Id: Ic910515f76eaf09ea6d0f755b026fb09cf09ccfc
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-on: http://openocd.zylin.com/5426
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/stm32h7x: use alignment infrastructure 88/5388/5
Christopher Head [Fri, 3 Jan 2020 22:49:16 +0000 (14:49 -0800)]
flash/stm32h7x: use alignment infrastructure

Report the 32-byte alignemnt requirement via the bank structure rather
than enforcing it ad-hoc in the write routine. This allows people to do
non-32-byte-aligned writes if they want, with the infrastructure fixing
up the addresses passed to the low-level driver.

Change-Id: I2c4f532f2000435954a900224dbc9f2c30d1cc94
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5388
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor/stm32f1x: Some small code cleanups 04/5404/6
Marc Schink [Sun, 19 Jan 2020 15:56:16 +0000 (16:56 +0100)]
flash/nor/stm32f1x: Some small code cleanups

Change-Id: I1fc08b96b179a1376af233b713ae50d6ad7867a0
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5404
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
4 years agoflash/nor/stm32h7x: check OPTCHANGEERR 18/5418/2
Christopher Head [Mon, 27 Jan 2020 22:48:15 +0000 (14:48 -0800)]
flash/nor/stm32h7x: check OPTCHANGEERR

Without this, a failed attempt to change option bytes will silently
appear to succeed but without actually changing the option bytes
(confusingly, the option bytes will still read back as if they had been
changed until a reboot as well!).

Change-Id: Id529c6c384a8a16be75f5702310670d99d8fac79
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5418
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
4 years agoflash/nor/stm32h7x: fix incorrect array indexing 17/5417/2
Christopher Head [Mon, 27 Jan 2020 21:30:04 +0000 (13:30 -0800)]
flash/nor/stm32h7x: fix incorrect array indexing

Change-Id: Iec2246df284953d1442dfefdad8e70041690dfe2
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5417
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
4 years agostlink: add trace support in DAP direct mode 09/5409/3
Antonio Borneo [Thu, 18 Jul 2019 13:14:34 +0000 (15:14 +0200)]
stlink: add trace support in DAP direct mode

Reuse the existing tracing functionality of HLA mode to support
tracing in DAP direct mode.

Change-Id: I75a01e88ba5d3e45717e4108b99697ac3225db9e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5409
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoarmv8: check the core state to pass the correct arch to gdb 34/5234/2
Antonio Borneo [Fri, 14 Jun 2019 13:59:17 +0000 (15:59 +0200)]
armv8: check the core state to pass the correct arch to gdb

Commit 3799eded6761 ("target/aarch64: add support for
multi-architecture gdb") passes the constant string "aarch64" as
architecture to gdb. This is not working if the core is running
in 32 bits mode; gdb reports:
Truncated register 8 in remote 'g' packet
then closes the connection with OpenOCD.

Make the architecture string dependant from the current state of
the core.

Change-Id: I16e1614ea02ba29bf87f450b3dfe25c83c9a3612
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5234
Tested-by: jenkins
Reviewed-by: Muhammad Omair Javaid <omair.javaid@linaro.org>
4 years agocoding style: use ARRAY_SIZE() when possible 98/5198/3
Antonio Borneo [Mon, 6 May 2019 10:50:44 +0000 (12:50 +0200)]
coding style: use ARRAY_SIZE() when possible

We have the macro ARRAY_SIZE() already available. Use it!

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types ARRAY_SIZE -f {} \;

Change-Id: Ic7da9b710edf118eacb08f9e222f34208c580842
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5198
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agocoding style: remove unnecessary parentheses 96/5196/3
Antonio Borneo [Mon, 6 May 2019 09:29:17 +0000 (11:29 +0200)]
coding style: remove unnecessary parentheses

Identified by checkpatch script from Linux kernel v5.1 using the
command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types UNNECESSARY_PARENTHESES -f {} \;

then fixed manually.

Change-Id: Ia2d9a0953d9b89fc87dc1195aa05c7f63c068c48
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5196
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agojtag/startup.tcl: remove trailing whitespaces 94/5194/2
Antonio Borneo [Mon, 6 May 2019 13:15:54 +0000 (15:15 +0200)]
jtag/startup.tcl: remove trailing whitespaces

Change-Id: I1d6f4f47ee6f8985c84ddb2647e029c5f4e6a55a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5194
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
4 years agotarget/nds32: fix type of magic number 93/5193/2
Antonio Borneo [Mon, 6 May 2019 09:40:17 +0000 (11:40 +0200)]
target/nds32: fix type of magic number

The macro NDS32_COMMON_MAGIC was cast-ed to int to avoid compile
time error for comparison type mismatch while comparing it with
the field common_magic.
This is incorrect because the macro value is a 32 bit unsigned
value; better changing the type of the field common_magic to keep
the unsigned value.

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types TYPECAST_INT_CONSTANT -f {} \;

Change-Id: Ib5924b6cecdffe70ab5c78d3b30a9c8e4deb7c7b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5193
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor/stm32lx: Minor code cleanups 38/5438/2
Marc Schink [Thu, 6 Feb 2020 10:02:25 +0000 (11:02 +0100)]
flash/nor/stm32lx: Minor code cleanups

Change-Id: I6440a4eb1f65a2f8ae2914b38f21a59955e85e0d
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5438
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agojtag_vpi: added an option to stop simulation on exit 07/5407/4
Jan Matyas [Wed, 22 Jan 2020 07:50:36 +0000 (08:50 +0100)]
jtag_vpi: added an option to stop simulation on exit

Command CMD_STOP_SIMU had been defined in jtag_vpi for a long time
(since the beginning?) but has not been utilized until now.
Its purpose is to signal to the jtag_vpi server (i.e. the RTL
simulation software) that the simulation shall be stopped.

This commit adds a TCL configuration command that selects whether
CMD_STOP_SIMU will be sent to the jtag_vpi server when OpenOCD is
about to exit. This functionality is off by default to maintain
identical behavior as in previous OpenOCD versions, unless the user
enables it explicitly.

Change-Id: If3894af6efa61038ccf6c9191f664e2128f2ef11
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/5407
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agoInclude start-of-region address 99/4799/2
Piotr Kasprzyk [Sat, 8 Dec 2018 17:02:11 +0000 (18:02 +0100)]
Include start-of-region address

When $ADDRESS == $BASE that address used to be excluded.

After this commit $ADDRESS == $BASE is within the range.

Now the rule for "iswithin" is:
$BASE <= $ADDRESS < ($BASE + $LEN)

Thanks to Antonio Borneo <borneo.antonio@gmail.com> for noticing this.

Change-Id: I74373c6010e069372d886fa7ecd8120892616834
Signed-off-by: Piotr Kasprzyk <ciri@ciri.pl>
Reviewed-on: http://openocd.zylin.com/4799
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agoflash/stm32lx: mention explicitly that this driver covers STM32 L0 and L1 37/5437/3
Tarek BOCHKATI [Wed, 5 Feb 2020 18:00:46 +0000 (19:00 +0100)]
flash/stm32lx: mention explicitly that this driver covers STM32 L0 and L1

this is to avoid confusion with STM32 L4, L4+ and L5 families

also:
 - a warning message is changed to error
 - stm32l0x and stm32l1x aliases has been created to permit
   the usage of either names

Change-Id: If3f16d2a3b7d1369959aa7407da37a9076ea91d7
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5437
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/startup.tcl: update stm32 flash driver aliases 36/5436/3
Tarek BOCHKATI [Wed, 5 Feb 2020 17:21:15 +0000 (18:21 +0100)]
flash/startup.tcl: update stm32 flash driver aliases

This will enable us to use either name when calling flash driver commands.

For example the stm32wbx family use the same flash driver as the stm32l4x, so
the user has to use 'stm32l4x lock 0' which can be confusing.
Now the user can also use 'stm32wbx lock 0' with the same result.

Change-Id: Ic0d8da9afc202d7cc82d9b9949827e958a1cc824
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5436
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agojtag: Fix copy-paste error in 'irscan' help 46/5446/2
Marek Vasut [Sat, 8 Feb 2020 07:58:53 +0000 (08:58 +0100)]
jtag: Fix copy-paste error in 'irscan' help

Replace "Instruction Register (DR)" with "Instruction Register (IR)",
that is sed "s@DR@IR@", which was likely a copy-paste error.

Change-Id: I3e625872c855d655485b3efa5f50fe1c00ecbf52
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5446
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
4 years agotcl: Remove executable bit 19/5419/2
Marc Schink [Tue, 28 Jan 2020 13:54:19 +0000 (14:54 +0100)]
tcl: Remove executable bit

Change-Id: Ib452435b13c3cb8d14453d983151936238b9601d
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5419
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Tested-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agoefm32: add EFR32ZG13P and EFR32ZG14P parts 64/5364/2
Frank Hunleth [Tue, 17 Dec 2019 20:06:09 +0000 (15:06 -0500)]
efm32: add EFR32ZG13P and EFR32ZG14P parts

This adds the EFR32 Zen Gecko Family parts. The device family values are
found in table 4.7.11 of
https://www.silabs.com/documents/public/reference-manuals/efr32xg14-rm.pdf.

Change-Id: I3858b7ba815784b1150e2214a2833e8ff7d249e1
Signed-off-by: Frank Hunleth <fhunleth@troodon-software.com>
Reviewed-on: http://openocd.zylin.com/5364
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
4 years agostlink: fix max packet size for 8 bit R/W on stlink-v3 08/5408/2
Antonio Borneo [Mon, 6 Jan 2020 11:35:17 +0000 (12:35 +0100)]
stlink: fix max packet size for 8 bit R/W on stlink-v3

While ST internal documentation for STLINK-V3 reports that 8 bits
read/write commands handle 512 bytes of data, a firmware bug makes
it crashing on high data size.
This is fixed with firmware V3J6 (shipped together with V2J36).

Check for firmware version to use the proper data size.

Change-Id: Iaba6cd26bbe130097c1c19de610680e0e8b69bfc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/259/
Reviewed-on: http://openocd.zylin.com/5408
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agojtag: flush jtag queue after jtag_add_tlr() 05/5405/2
Antonio Borneo [Wed, 2 Oct 2019 16:21:05 +0000 (18:21 +0200)]
jtag: flush jtag queue after jtag_add_tlr()

If the TLR sequence is sent as result of the command "adapter
assert trst" while polling is off, the TLR sequence is not sent out
until a following jtag operation.

Flush the jtag queue before return.

Change-Id: I20efd7137cb7b1d1c4f73c1362cbe4e57aeaae49
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5405
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoSwitch to HTTPS for submodules 06/5406/3
Christopher Head [Tue, 21 Jan 2020 20:44:46 +0000 (12:44 -0800)]
Switch to HTTPS for submodules

repo.or.cz already redirects HTTP requests to HTTPS. There is therefore
no possible benefit to keeping the submodule URLs using HTTP—anyone who
can’t access via HTTPS will fail anyway, immediately after the redirect.
Changing the submodule URLs eliminates one unnecessary HTTP request and,
more importantly, eliminates SSLStrip-style attacks.

Change-Id: I9faf1ec8aa87bcfd1acafe2c445a0baf2abfbd09
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5406
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agotcl: fix remaining scripts after rework adapter commands 24/5424/2
Antonio Borneo [Thu, 30 Jan 2020 17:11:54 +0000 (18:11 +0100)]
tcl: fix remaining scripts after rework adapter commands

Some script have been added or modified after the patches for
reworking the adapter commands were pushed in gerrit.
Such scripts use the old command syntax and trigger a "deprecated"
warning at runtime.

Fix them with the same sed commands used for the other scripts:
sed -i 's/^interface /adapter driver /' $(find tcl/ -type f)
sed -i 's/adapter_khz/adapter speed/g' $(find tcl/ -type f)
sed -i 's/adapter_nsrst_delay/adapter srst delay/g' $(find tcl/ -type f)
sed -i 's/adapter_nsrst_assert_width/adapter srst pulse_width/g' $(find tcl/ -type f)

Change-Id: I0824d6c506a9af3eb9129b74c02a92b4eb1b100d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5424
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
4 years agotcl: Add interface config for isodebug isolated JTAG/SWD+UART 51/5251/4
Andreas Fritiofson [Fri, 28 Jun 2019 13:45:23 +0000 (15:45 +0200)]
tcl: Add interface config for isodebug isolated JTAG/SWD+UART

Currently only used internally at Unjo.

Change-Id: I7786e95e1bd755a73156ecad5b6d7f6273d8ddef
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/5251
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agojtag: drivers: xlnx-pcie-xvc: fix build on Linux pre v4.10 35/5435/2
Antonio Borneo [Wed, 5 Feb 2020 17:00:12 +0000 (18:00 +0100)]
jtag: drivers: xlnx-pcie-xvc: fix build on Linux pre v4.10

The macro PCI_CFG_SPACE_EXP_SIZE is exposed to userspace from
Linux kernel v4.10, with commit cc10385b6fde ("PCI: Move config
space size macros to pci_regs.h")
http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc10385b6fde

Define the macro in the driver code, if not already defined.

Change-Id: I610219a2587eff2c142102b9f7830e3da882af78
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5435
Reviewed-by: Moritz Fischer <moritzf@google.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
4 years agoflash/nor: Add Renesas RPC HF driver 49/5149/20
Marek Vasut [Sat, 13 Apr 2019 20:44:45 +0000 (22:44 +0200)]
flash/nor: Add Renesas RPC HF driver

Add driver for the RPC block in HF mode on Renesas R-Car Gen3 SoCs.
This driver allows operating the on-SIP HF memory.

Note that HF is CFI compliant flash, but it is not memory mapped,
hence the need to replace all the memory accessors and read/write
functions. The write function is entirely replaced to increase
performance and is Spansion/AMD specific, since there is no known
SIP with other HF from another vendor.

Add the following two lines to board TCL file to bind the driver on
R-Car Gen3 SoC using HyperFlash:

  set _FLASHNAME $_CHIPNAME.flash
  flash bank $_FLASHNAME rpchf 0x08000000 0x4000000 2 2 $_CHIPNAME.a57.0

Change-Id: Ie18729d017eeb46e1363333ffe002d010dfc5ead
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5149
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoflash/nor: Export various functions from the CFI core 48/5148/19
Marek Vasut [Sat, 13 Apr 2019 20:44:45 +0000 (22:44 +0200)]
flash/nor: Export various functions from the CFI core

Export various functions needed by other driver, specifically the
upcoming Renesas RPC HF driver. No functional change.

Change-Id: I551258979a7221288fb4f4382f857db5cfe0b0de
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5148
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agojtag: Fix jtag_reset fallback 16/5416/2
Leonard Crestez [Mon, 27 Jan 2020 18:10:30 +0000 (20:10 +0200)]
jtag: Fix jtag_reset fallback

The fallback provided for the jtag_reset command always fails with a
strange message: 'Error: invalid command name "de"'

This is caused by incorrect quoting inside the warning message.

Fixes: c07b774e8f49 ("jtag: replace command "jtag_reset" with "adapter [de]assert"")
Change-Id: Icd47fca2b5a7b33474bfb0040e88193a0968f301
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-on: http://openocd.zylin.com/5416
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agotcl: replace the deprecated commands with "adapter ..." 84/5284/5
Antonio Borneo [Fri, 23 Aug 2019 13:51:00 +0000 (15:51 +0200)]
tcl: replace the deprecated commands with "adapter ..."

Avoid annoying "deprecated" messages while running the scripts
distributed with OpenOCD code.
Change automatically created with commands
sed -i 's/adapter_khz/adapter speed/g' $(find tcl/ -type f)
sed -i 's/adapter_nsrst_delay/adapter srst delay/g' $(find tcl/ -type f)
sed -i 's/adapter_nsrst_assert_width/adapter srst pulse_width/g' $(find tcl/ -type f)

Minor indentation issue fixed manually in
tcl/board/at91sam9g20-ek.cfg
tcl/target/at91sam9260_ext_RAM_ext_flash.cfg

Change-Id: I425fd56c0c88cd6b06124621306eeb89166dfe71
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5284
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agodoc: replace example command "interface" with "adapter driver" 85/5285/3
Antonio Borneo [Fri, 23 Aug 2019 14:07:12 +0000 (16:07 +0200)]
doc: replace example command "interface" with "adapter driver"

Keep documentation consisted after commands renaming.

Change-Id: I97b43887cae9d7c224b07e4ba0b7d04915a19fc4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5285
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotcl: replace command "interface" with "adapter driver" 83/5283/4
Antonio Borneo [Fri, 23 Aug 2019 13:49:58 +0000 (15:49 +0200)]
tcl: replace command "interface" with "adapter driver"

Avoid annoying "deprecated" messages while running the scripts
distributed with OpenOCD code.
Change automatically created with command
sed -i 's/^interface /adapter driver /' $(find tcl/ -type f)

Change-Id: I2291dfb96e164beecbeb3366ce83f9df2ad6c197
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5283
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoopenocd: fix minor inconsistencies after renaming "adapter" command 82/5282/3
Antonio Borneo [Fri, 23 Aug 2019 13:12:57 +0000 (15:12 +0200)]
openocd: fix minor inconsistencies after renaming "adapter" command

Replace in the code any reference to the deprecated commands.

Change-Id: I75d28064017d664990b4024967900f32e196230a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5282
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agomove ftdi_location deprecation helper to proper place 78/5278/3
Oleksij Rempel [Wed, 14 Aug 2019 11:17:51 +0000 (13:17 +0200)]
move ftdi_location deprecation helper to proper place

Change-Id: I927d4e918acbf321aea1dd7a8de95fbaa8fbbbf0
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/5278
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 years agojtag: adapter: rework adapter related commands 74/4774/9
Oleksij Rempel [Mon, 19 Nov 2018 11:56:48 +0000 (12:56 +0100)]
jtag: adapter: rework adapter related commands

currently we have different types of same command group:
- starting with adapter_*
- starting with interface*
- without adapter or interface prefix.

Since interface name is already used, we can only use "adapter" command
group by keeping old commands as well.

Change-Id: Id0a1cb63a2ea6860c67ae1e7a3a06a37ddf464f4
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4774
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoflash/nor/stm32l4x: fix minor errors in flash write/async algo 60/5360/4
Tomas Vanek [Sat, 14 Dec 2019 17:55:01 +0000 (18:55 +0100)]
flash/nor/stm32l4x: fix minor errors in flash write/async algo

Fix comment of tested errors in asm src.

List all relevant errors in FLASH_ERROR mask: FLASH_PROGERR was missing
and any trial to re-program already programmed double word ended up
in the error bit held uncleared and flash write permanetly repeating
the error message until reset.

Lock the bank also after unsuccesfull write_block run.

Set async target algo block size to size of double word.

Remove warning in case of write_block success. In case of error
use LOG_ERROR instead of warning.

Change-Id: Ibf6d5e306a4c2eaa43de67d636b4902c737f02f3
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5360
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
4 years agoflash/nor/stm32l4x: use flash infrastructure to align write 59/5359/3
Tomas Vanek [Sat, 14 Dec 2019 15:08:32 +0000 (16:08 +0100)]
flash/nor/stm32l4x: use flash infrastructure to align write

The original code paded the write chunk with random bytes by overrunning
the buffer. An user can easily regard the random bytes to
be a programming error.

Change-Id: Ib0f47b5bc406bc6a7c32f3d929bf324a17c7c1e1
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5359
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
4 years agotcl/board: Add config for STM32WB Nucleo board 58/5358/2
Marc Schink [Thu, 12 Dec 2019 12:30:57 +0000 (13:30 +0100)]
tcl/board: Add config for STM32WB Nucleo board

Change-Id: Ic29802306c706bcf3e261c60facd01d101c9e1ce
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5358
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Ilya Kharin <akscram@gmail.com>
4 years agotarget/arm_cti: fix regression from Tcl_return_values series 63/5363/2
Tomas Vanek [Mon, 16 Dec 2019 12:08:01 +0000 (13:08 +0100)]
target/arm_cti: fix regression from Tcl_return_values series

Since commit 7f260f5009a774f2d66b5f3037f8f595c6881d4d native OpenOCD
command handlers should not directly use Jim_SetResult functions.
The Tcl result of a native command is built as concatenation of
command_print() strings and Jim_SetResult() is called after return
of the command handler.

Replace "wrong number of args" error messages (now not delivered to user)
by simply return ERROR_COMMAND_SYNTAX_ERROR

Change-Id: I40c1374a13859cefbdef68e0f1c13ab93538bd50
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5363
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
4 years agoflash/nor/nrf5: Fix build error on OSX 01/5401/2
Marek Vasut [Fri, 10 Jan 2020 03:24:59 +0000 (04:24 +0100)]
flash/nor/nrf5: Fix build error on OSX

The chip->hwid is uint32_t , fix the print format.
This was detected by TravisCI on OSX, where this triggers a build error.

Change-Id: I776a7bb50e396c8fccc24500dec4750190da7982
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5401
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Ilya Kharin <akscram@gmail.com>
4 years agojtag: drivers: xlnx-pcie-xvc: fix build after merge 02/5402/2
Antonio Borneo [Fri, 17 Jan 2020 15:44:00 +0000 (16:44 +0100)]
jtag: drivers: xlnx-pcie-xvc: fix build after merge

Commit [1] was submitted in gerrit well before the conflicting
commit [2] get merged in master branch. While it was fine
committing in master branch [1] alone, it should not be
committed "as is" after [2].
Unfortunately gerrit did not complained committing [1] after [2].
The result is that master branch does not build anymore when the
driver xlnx-pcie-xvc is enabled at configure time by the optional
flag --enable-xlnx-pcie-xvc.

Apply to the driver the required changes as in [2].
While there, remove the duplicated struct xlnx_pcie_xvc_transports
and the struct field already implicitly initialized to zero.

[1] ff6d0704ecd6 ("jtag: drivers: xlnx-pcie-xvc: Add support for
    Xilinx XVC/PCIe")
[2] efd1d642220a ("adapter: switch from struct jtag_interface to
    adapter_driver")

Change-Id: I5498479b802a231afbee1b845ae9775e1da7c728
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5402
Reviewed-by: Moritz Fischer <moritzf@google.com>
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
4 years agoflash/nor/sh_qspi: Add SH QSPI driver 43/5143/17
Marek Vasut [Tue, 2 Apr 2019 14:44:18 +0000 (16:44 +0200)]
flash/nor/sh_qspi: Add SH QSPI driver

Add driver for the SH QSPI controller. This SPI controller is often
connected to the boot SPI NOR flash on R-Car Gen2 platforms.

Add the following two lines to board TCL file to bind the driver on
R-Car Gen2 SoC and make SRAM work area available:

  flash bank flash0 sh_qspi 0xe6b10000 0 0 0 ${_TARGETNAME}0 cs0
  ${_TARGETNAME}0 configure -work-area-phys 0xe6300000 -work-area-virt 0xe6300000 -work-area-size 0x10000 -work-area-backup 0

To install mainline U-Boot on the board, use the following procedure:

  proc update_uboot {} {
    # SPL
    flash erase_sector 0 0x0 0x0
    flash write_bank 0 /u-boot/spl/u-boot-spl.bin 0x0
    # U-Boot
    flash erase_sector 0 0x5 0x6
    flash write_bank 0 /u-boot/u-boot.img 0x140000
  }

Change-Id: Ief22f61e93bcabae37f6e371156dece6c4be3459
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
V2: - Add Makefile and linker script for the SH QSPI IO algorithm
    - Include the algorithm code instead of hard-coding it
Reviewed-on: http://openocd.zylin.com/5143
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agojtag_libusb_bulk_read|write: return error code instead of size 90/4590/21
Oleksij Rempel [Thu, 5 Jul 2018 11:42:14 +0000 (13:42 +0200)]
jtag_libusb_bulk_read|write: return error code instead of size

A USB bulk write/read operation may fail with different errors:
 LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates transferred)
 LIBUSB_ERROR_PIPE if the endpoint halted
 LIBUSB_ERROR_OVERFLOW if the device offered more data, see Packets and overflows
 LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
 another LIBUSB_ERROR code on other failures

Current OpenOCD code is using the transfer size based error detection.
Which may not always work. For example for LIBUSB_ERROR_OVERFLOW as libusb
documentation says:
"Problems may occur if the device attempts to send more data than can fit in
the buffer. libusb reports LIBUSB_TRANSFER_OVERFLOW for this condition but
other behaviour is largely undefined: actual_length may or may not be accurate,
the chunk of data that can fit in the buffer (before overflow) may or may not
have been transferred."

This patch is refactoring code to use actual error return value for
error detection instead of size.

Change-Id: Iec0798438ca7b5c76e2e2912af21d9aa76ee0217
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4590
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agomips_ejtag: there is no DCR.MIPS64 bit 28/4628/6
Jiri Kastner [Wed, 1 Aug 2018 13:17:43 +0000 (15:17 +0200)]
mips_ejtag: there is no DCR.MIPS64 bit

available revisions (2.60, 3.10, 5.06 and 6.10) of
MD00047 (EJTAG specification), have only in IMPCODE
MIPS32/MIPS64 bit/flag.

Change-Id: If9191b6ced760c59bb7551bb041cd72b0a060bb1
Signed-off-by: Jiri Kastner <cz172638@gmail.com>
Reviewed-on: http://openocd.zylin.com/4628
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
4 years agojtag: drivers: xlnx-pcie-xvc: Add support for Xilinx XVC/PCIe 14/5314/15
Moritz Fischer [Fri, 4 Oct 2019 03:25:26 +0000 (20:25 -0700)]
jtag: drivers: xlnx-pcie-xvc: Add support for Xilinx XVC/PCIe

Add support for Xilinx Virtual Cable over PCIe JTAG controller.
It is commonly used in Xilinx based PCI Express designs with JTAG IP
in the FPGA fabric.

Access to the JTAG registers happens via the PCI Express extended
configuration space.

This can be used to debug soft-cores instantiated in the FPGA fabric.

The clang static checker doesn't find any new problems with this change.

Change-Id: Ib12ede0d1f26dacfda808d5e05b947b640c5bde7
Signed-off-by: Moritz Fischer <moritzf@google.com>
Reviewed-on: http://openocd.zylin.com/5314
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Marex
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoflash/nor: Rename flash_address() to cfi_flash_address() 91/5391/7
Marek Vasut [Sun, 5 Jan 2020 21:34:42 +0000 (22:34 +0100)]
flash/nor: Rename flash_address() to cfi_flash_address()

This is a preparatory change, align the function name with the rest
of the API, no functional change.

Change-Id: I6a810d2a54edcd13ad9a87d24a7334802c41623b
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5391
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: Rename get_cfi_info() to cfi_get_info() 90/5390/7
Marek Vasut [Sun, 5 Jan 2020 21:33:29 +0000 (22:33 +0100)]
flash/nor: Rename get_cfi_info() to cfi_get_info()

This is a preparatory change, align the function name with the rest
of the API, no functional change.

Change-Id: Ib967520f027b03eb1792b36ede52335df8e23941
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5390
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: Allow CFI memory read/write functions be overriden 47/5147/17
Marek Vasut [Sat, 13 Apr 2019 20:44:45 +0000 (22:44 +0200)]
flash/nor: Allow CFI memory read/write functions be overriden

Add possibility to supply custom CFI memory accessors via cfi_info
and override the default memory-mapped ones.

Change-Id: I1b6bc1db69fc33e8cdef96c41742c40e6d8917e9
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5147
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: Drop size argument of cfi_target_{read,write}_memory() 89/5389/6
Marek Vasut [Sun, 5 Jan 2020 16:26:18 +0000 (17:26 +0100)]
flash/nor: Drop size argument of cfi_target_{read,write}_memory()

The size argument is always set to bank->bus_width and bank pointer
is now passed into cfi_target_{read,write}_memory(), so the size
can be accessed through the bank pointer inside the function instead
of being explicitly passed in.

Change-Id: I0abc1cc3bf513281c10cb5de7a21cb0e75cb7676
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5389
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: Pass flash_bank to memory accessors 46/5146/16
Marek Vasut [Sun, 21 Apr 2019 14:28:10 +0000 (16:28 +0200)]
flash/nor: Pass flash_bank to memory accessors

Replace passing in struct target with passing in struct flash_bank,
so that the later can contain function pointers to custom per-driver
memory accessor functions.

Change-Id: Id2573a6d5f1a73ed9c4f73c53592a9a335a11c99
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5146
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agotarget/xscale: remove duplicated command 82/5382/2
Tomas Vanek [Fri, 20 Dec 2019 22:54:29 +0000 (23:54 +0100)]
target/xscale: remove duplicated command

Reported by clang static analyzer.

Change-Id: I893af10852af4885507ed62d024008159a80dd56
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5382
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotarget/etm: add check for calloc error 81/5381/2
Tomas Vanek [Fri, 20 Dec 2019 22:50:26 +0000 (23:50 +0100)]
target/etm: add check for calloc error

and fix one more clang static analyzer warning.

Change-Id: I17f03e318e1cf7617e7f753e7ca960552be547e5
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5381
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotarget/semihosting_common: fix minor memory leak 80/5380/2
Tomas Vanek [Fri, 20 Dec 2019 22:48:46 +0000 (23:48 +0100)]
target/semihosting_common: fix minor memory leak

Reported by clang static analyzer.

Change-Id: Ie663f49d92588c0d8b502cfdd8fc34004b308066
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5380
Reviewed-by: Liviu Ionescu <ilg@livius.net>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotarget/target: fix clang static analyzer warnings 79/5379/2
Tomas Vanek [Fri, 20 Dec 2019 22:48:13 +0000 (23:48 +0100)]
target/target: fix clang static analyzer warnings

Change-Id: I23e6586be60915f21a7179a994a1ec93fb9b2c36
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5379
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotarget/avr32_jtag: fix error returns 78/5378/3
Tomas Vanek [Fri, 20 Dec 2019 22:46:46 +0000 (23:46 +0100)]
target/avr32_jtag: fix error returns

Fixed only 2 error returns discovered by clang static analyzer.
There are obviously many more missing error tests in avr32_jtag.c
These was not fixed to keep this change minimal.
Not tested with hw.

Change-Id: I6c79f6248db774990ddb42c0dacdb621651ed69e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5378
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotarget/arm_dpm: add missing error returns 77/5377/2
Tomas Vanek [Fri, 20 Dec 2019 22:45:20 +0000 (23:45 +0100)]
target/arm_dpm: add missing error returns

Discoverd by clang static analyzer.

Change-Id: I93d5de0a36216e62b170fe8cc870431226a7777f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5377
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agotarget/arm946e: add missing error detection 76/5376/2
Tomas Vanek [Fri, 20 Dec 2019 22:43:55 +0000 (23:43 +0100)]
target/arm946e: add missing error detection

Discoverd by clang static analyzer.
While on it remove useless type casts from arm946e_read_cp15() parameter.

Change-Id: I549e19685b431400243800ee0f7d1bbe6cdb14b4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5376
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoserver/server: fix clang static analyzer warning 73/5373/2
Tomas Vanek [Fri, 20 Dec 2019 22:40:07 +0000 (23:40 +0100)]
server/server: fix clang static analyzer warning

Change-Id: I317e189b62540e3688a20d88a95f551280317f14
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5373
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoxsvf: fix memory leak 72/5372/2
Tomas Vanek [Fri, 20 Dec 2019 22:38:42 +0000 (23:38 +0100)]
xsvf: fix memory leak

Discovered by clang static analyzer.

Change-Id: I2980586aea5ee43226adb1f4cf72e7ba1dfddd83
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5372
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
4 years agoflash/nor/stm32l4x: add support of STM32L4P5/L4Q5x devices 92/5392/2
Tarek BOCHKATI [Mon, 6 Jan 2020 17:33:42 +0000 (18:33 +0100)]
flash/nor/stm32l4x: add support of STM32L4P5/L4Q5x devices

STM32L4P/Q devices have:
 - similar flash layout as STM32L4R/S devices
 - 1024K of flash memory (some parts have 512K only)

tested on NUCLEO-L4P5ZG using board/st_nucleo_l4.cfg

Change-Id: I77047351bc7dcd7c76d0f31a77be73005104a06f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5392
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: add support of STM32WB on top STM32L4 flash driver 33/4933/6
Tarek BOCHKATI [Mon, 6 Jan 2020 16:19:31 +0000 (17:19 +0100)]
flash/nor: add support of STM32WB on top STM32L4 flash driver

Change-Id: I9fb6700085d817d35a691f6484193f67939a4e0f
Signed-off-by: Laurent LEMELE <laurent.lemele@st.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/4933
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: add support of STM32L41/L42xx 34/4934/6
Tarek BOCHKATI [Mon, 6 Jan 2020 14:47:09 +0000 (15:47 +0100)]
flash/nor: add support of STM32L41/L42xx

tested using STM32L412KB

Change-Id: I1e2ae93d8c740db219f0fb579940de7f2fffac15
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/4934
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor/stm32l4x : add structure containers to hold devices' information 32/4932/13
Tarek BOCHKATI [Sun, 5 Jan 2020 22:19:41 +0000 (23:19 +0100)]
flash/nor/stm32l4x : add structure containers to hold devices' information

This rework is inspired from the 'flash/nor/stm32h7x.c'
This rework will ease the support of new devices on top of this driver:
  for example: STM32WB have different flash base and size addresses

Notes:
 - stm32l4_probe modified in order to charge the correct part_info from
   the defined stm32l4_parts according to the device id
 - stm32l4_flash_bank.bank2_start is replaced by .part_info->bank1_sectors
 - STM32_FLASH_BASE is removed , part_info->flash_regs_base will be used instead
   based on that flash register addresses are changed to offsets,
   >> stm32l4_get_flash_reg was modified accordingly
 - stm32l4_read_option and stm32l4_write_option was modified to accept an
   offset instead of an absolute address, luckily this is the commands'
   argument by default
 - stm32l4_mass_erase modifications :
     - use MER2 only on top of dual bank devices
     - wait for BUSY bit before starting the mass erase

Change-Id: Ib35bfc3cbadc76bbeaaaba9005b82077b9e1e744
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/4932
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
4 years agotarget/target: parse value as proper type 19/5219/3
Christopher Head [Thu, 6 Jun 2019 18:40:12 +0000 (11:40 -0700)]
target/target: parse value as proper type

The `value` variable is passed into `target_fill_mem` as its
second-to-last parameter. That parameter is of type `uint64_t`. It is
appropriate to parse the value as that type, since otherwise a target
with a 32-bit address space but 64-bit data write capabilities would not
be able to exercise those capabilities.

Change-Id: Ib336d47d42c27cd2b5ba1206b04e8f740f167dba
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5219
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
4 years agostlink: fix handling of DPv1 and DPv2 banked registers 78/4978/6
Antonio Borneo [Thu, 28 Feb 2019 09:28:26 +0000 (10:28 +0100)]
stlink: fix handling of DPv1 and DPv2 banked registers

Arm DPv1 and DPv2 support banked registers by setting the bank in
field DPBANKSEL of register DP_SELECT.
Old ST-Link firmware don't support banked registers and setting a
bank other than bank zero on DPv1 or DPv2 cause issues in the
firmware because it cannot set back bank zero to read CTRL/STAT.
New ST-Link firmware mask away DPBANKSEL bits while writing in
DP_SELECT but support banked register using the same packed method
used by OpenOCD:
#define BANK_REG(bank, reg) (((bank) << 4) | (reg))

Add a new macro STLINK_F_HAS_DPBANKSEL for firmware that support
arm DPv1 and DPv2, plus trigger an error if banked registers are
requested on old firmware.
Prevent changing DPBANKSEL on old firmware.
Log a debug message when changing DPBANKSEL will be ignored.

Change-Id: Iaa592517831d63f8da2290db54f6b32504e3081b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4978
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agostlink: add DAP direct driver 04/4904/9
Antonio Borneo [Mon, 28 Jan 2019 17:53:53 +0000 (18:53 +0100)]
stlink: add DAP direct driver

STLINK-V3 and the new firmware V2J24 for ST-LINK/V2 provide API
to directly access the DAP registers.
This mode permits to use the native target in cortex_m.c, with no
need to override it with the target in hla_target.c.
Other advantages wrt HLA are: support for Cortex-A cores, support
for SoC multi-core and/or multi AP, support for OpenOCD commands
"dap" thus including control of CSW.
This obsoletes the existing HLA driver for ST-Link, that should
anyway be kept for those cases where it's not possible to update
the ST-Link firmware.

This commit introduces the minimal implementation for direct DAP
access. The implementation is much slower than the HLA because
every memory transfer requires several USB packets. Further
commits will close the performance gap.
The whole ST-Link driver is compiled under BUILD_HLADAPTER, to
remove the need to split the driver between the two modes. This
has to be reworked, but it's quite invasive!
A new interface file stlink-dap.cfg is added and should be used
in place of stlink.cfg to enable the DAP mode.
Documentation is updated and reports limitation on the maximum AP
number that can be accessed by ST-Link for some firmware already
tested.

Change-Id: I932ffe16bc81d00b1fe489e2944fda13470cce9b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4904
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoadi_v5_dapdirect: add support for adapter drivers that provide DAP API 03/4903/8
Antonio Borneo [Wed, 23 Jan 2019 09:52:28 +0000 (10:52 +0100)]
adi_v5_dapdirect: add support for adapter drivers that provide DAP API

Some high level adapters, like STLINK-V3 and new firmware for
ST-Link/V2, provide API to directly access the DAP registers
hiding the details of the physical transport JTAG or SWD.
OpenOCD has already the intermediate API in struct dap_ops that
are suitable for such adapters, but are not exposed to the
adapter drivers.

Add in struct adapter_driver two independent struct dap_ops for
the cases of physical JTAG and SWD transport.
Add new transport names "dapdirect_jtag" and "dapdirect_swd", to
be used by the drivers that provide one or both DAP API.
Add the necessarily glue in target/adi_v5_dapdirect.c

Change-Id: I2bb8e3a80fba750f2c218d877cfa5888428e3c28
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4903
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoTODO: add restructuring of JTAG/adapter layer 01/4901/8
Antonio Borneo [Tue, 22 Jan 2019 17:23:38 +0000 (18:23 +0100)]
TODO: add restructuring of JTAG/adapter layer

SWD is already implemented, so remove the item.
Rename the section JTAG as Adapter, including the subsections.
Add an initial list of pending activities after the restructure
of the JTAG layer.

Change-Id: I540777344c62a746df8347538fe8b29e4d72e1c7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4901
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoadapter: switch from struct jtag_interface to adapter_driver 00/4900/8
Antonio Borneo [Tue, 22 Jan 2019 15:31:18 +0000 (16:31 +0100)]
adapter: switch from struct jtag_interface to adapter_driver

To reorganize the adapters code, introduce an adapter_driver
struct that contains all the adapter generic part, while
keeping in two separate struct the specific API jtag_ops and
swd_ops.
Move the allocation of *adapter_driver from the JTAG-specific
file core.c to the more adapter-specific file adapter.c
While splitting the old jtag_interface for every driver, put
the fields in the same order as in the struct declaration so
we keep a consistent code across all the drivers.

While other transport specific API could/would be added as
separate ops, nothing is done here for HLA.

Change-Id: I2d60f97ac514c0dd2d93a6ec9be66fd9d388dad5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4900
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agodrivers/kitprog: remove unused JTAG execute_queue method 99/4899/8
Antonio Borneo [Tue, 22 Jan 2019 00:31:42 +0000 (01:31 +0100)]
drivers/kitprog: remove unused JTAG execute_queue method

kitprog is SWD only and we do not rely on JTAG queue anymore.
Remove the remaining JTAG heritage.

Change-Id: Ic586278368301eb669bc6e4e641f683a81cb171d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4899
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agohla: remove empty JTAG execute_queue method 98/4898/8
Antonio Borneo [Mon, 14 Jan 2019 21:52:42 +0000 (22:52 +0100)]
hla: remove empty JTAG execute_queue method

We do not rely on JTAG queue anymore.
Remove the remaining JTAG heritage.

Change-Id: I6c87d9ffebaa383c998cf273188b3e7f28b3fe95
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4898
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agojtag: print an errmsg on using jtag API for non jtag transport 97/4897/8
Antonio Borneo [Tue, 28 Aug 2018 12:49:10 +0000 (14:49 +0200)]
jtag: print an errmsg on using jtag API for non jtag transport

After the cleanup of swd and hla, there should be no more calls
to jtag_execute_queue() or to queue jtag commands if current
transport is not jtag. Thus we can start removing the jtag
specific code from adapters that do not support jtag.

To prevent some remaining call to jtag_execute_queue() to crash
openocd, verify the transport, print an error message if the
transport is not jtag, call the adapter's jtag_execute_queue()
only if it exist.
To identify code that still add commands in the jtag queue even
if transport is not jtag, print an error message in the function
jtag_queue_command(). For the moment, still queue the message,
even if will cause a memory leak if there is no following call
to jtag_execute_queue(); the target is to identify the issue and
cleanup the code, thus solving also the leak.

Change-Id: I8fc85f754aa057aad1df05ff0448c8619897da23
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4897
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agohla: use the new system_reset API 96/4896/7
Antonio Borneo [Fri, 6 Sep 2019 09:00:19 +0000 (11:00 +0200)]
hla: use the new system_reset API

HLA uses its own internal driver's API to control the adapter's
system reset, but at the same time it calls jtag_add_reset() to
avoid breaking the internal logic of OpenOCD. This implicitly
forces HLA to rely on jtag queue mechanism, even if HLA has no
link with JTAG state machine. It requires HLA to implement an
empty execute_queue() to comply with the JTAG queue.

Modify the HLA framework and the HLA targets to use the new
adapter API for system_reset and decouple HLA from JTAG queue.
Rename the HLA static functions adapter_assert_reset() and
adapter_deassert_reset() to avoid overlap with the global
functions with same name.
While there, fix a minor typo in a comment s/incase/in case/.

Do not remove from HLA the JTAG specific API execute_queue(),
even if not required anymore, because OpenOCD code still has
calls to jtag_execute_queue() in case of non JTAG transport.

Change-Id: I0e65e3e557bd665bd3d3aeaa84ea609b55a05e48
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4896
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agobitbang: jtag-only drivers: switch to new reset API 00/5300/3
Antonio Borneo [Wed, 4 Sep 2019 14:47:24 +0000 (16:47 +0200)]
bitbang: jtag-only drivers: switch to new reset API

Remove the JTAG_RESET command from the bitbang execute queue now
that all bitbang drivers have moved away from old reset method.
Remove also the internal reset API in struct bitbang_interface.

Tested parport only.

Change-Id: I12b157ef442f4c9912406b19b7a4d32ba6ec0b53
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5300
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoswd: get rid of jtag queue to assert/deassert srst 95/4895/7
Antonio Borneo [Sat, 31 Aug 2019 09:08:16 +0000 (11:08 +0200)]
swd: get rid of jtag queue to assert/deassert srst

The transport SWD uses the JTAG queue to assert/deassert the
system reset srst. This is the major inconsistency that has to be
removed to properly split JTAG and SWD.

Introduce a new driver API, reset(), to controls both the signals
trst and srst in the driver, skipping the JTAG queue. Put the new
API in struct jtag_interface, even if in this patch it's used for
SWD only; the goal is to get it reused by the other transports.

Add the implementation of the API in all the drivers that
implement SWD. Such implementation is almost the same of the old
code in JTAG queue.

Create a wrapper adapter_system_reset() to use the new API and
remove the SWD specific swd_add_reset(). In the wrapper replace
jtag_add_sleep() with jtag_sleep(), because the former uses the
JTAG queue too.
Rename the old jtag_add_reset() as legacy_jtag_add_reset() with
the target to remove it when all drivers would be ported to the
new reset API. Create a new jtag_add_reset() that calls the
legacy function for drivers still on the old reset API.

Use the new API also on JTAG transport for the drivers that can
support both SWD and JTAG.

For the moment, do not modify the implementation of JTAG-only
drivers, which will continue using the usual method. This should
be cleaned-up in future commits.

Change-Id: I32331c88313f6059b25e12c6bb0156aebc1c074f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4895
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoflash/nor: Factor out CFI memory read/write functions 45/5145/11
Marek Vasut [Sun, 21 Apr 2019 13:54:38 +0000 (15:54 +0200)]
flash/nor: Factor out CFI memory read/write functions

Create separate memory read/write functions which facilitate access
to the CFI NOR, so that they can be replaced by controller-specific
functions if necessary. This would become necessary when implementing
support for e.g. HyperFlash controllers, which do not directly map
the HyperFlash into the address space.

Change-Id: I1bba1edfd397cb37bfedb43efe2dd03feb26a375
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5145
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
4 years agoflash/nor: Factor out cfi_spansion_unlock_seq() 44/5144/11
Marek Vasut [Fri, 19 Apr 2019 18:34:36 +0000 (20:34 +0200)]
flash/nor: Factor out cfi_spansion_unlock_seq()

Factor out the spansion unlock sequence to deduplicate the code.

Change-Id: Id78522e9a2f0e701870ef816772289d08257476a
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5144
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
4 years agoflash/nor/stm32f2x: Support value line chips with trimmed flash 26/4926/12
Keir Fraser [Tue, 3 Dec 2019 08:17:56 +0000 (08:17 +0000)]
flash/nor/stm32f2x: Support value line chips with trimmed flash

The current code assumes an STM32's flash bank is laid-out in either of
two configurations:
- 4 x 16kB + 1 x 64kB + n x 128kB
- 4 x 32kB + 1 x 128kB + n x 256kB

This is quite ad-hoc but works fine in practice, as long as there are at
least 5 sectors (if n=0). Unfortunately, some newer STM32s are shipping
with only 64 kB of flash (4 x 16kB sectors).

This patch still assumes the same sector layout, but only keeps adding
sectors to the bank if the bank's capacity has not been reached. This
prevents openocd from crashing on some newer STM32s.

Change-Id: If00e5d7a328d11b399babc0bb2111e3ad8a3217e
Signed-off-by: Romain Goyet <romain.goyet@numworks.com>
Signed-off-by: Keir Fraser <keir.xen@gmail.com>
Reviewed-on: http://openocd.zylin.com/4926
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoarm_adi_v5: add API send_sequence() and use it 02/4902/7
Antonio Borneo [Wed, 23 Jan 2019 15:46:31 +0000 (16:46 +0100)]
arm_adi_v5: add API send_sequence() and use it

The method to send an arbitrary sequence to DAP depends on the
transport and is thus different on JTAG and SWD. This is already
coded in dap_to_jtag() and dap_to_swd().

Add a new API send_sequence() in struct dap_ops.
Add the implementations of send_sequence() in adi_v5_jtag.c and
adi_v5_swd.c
Rewrite dap_to_jtag() and dap_to_swd() using the new API.
Move the enum swd_special_seq in arm_adi_v5.h to solve a circular
dependencies among swd.h and arm_adi_v5.h

Change-Id: I9db13a00f129761eab283783c094cfff2dd92610
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4902
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agotcl: update scripts after "jtag_reset" got deprecated 87/5287/3
Antonio Borneo [Wed, 14 Aug 2019 12:53:24 +0000 (14:53 +0200)]
tcl: update scripts after "jtag_reset" got deprecated

Avoid annoying "deprecated" messages in the scripts
distributed with OpenOCD code.

Change-Id: I82d27cd420db30f0653efbd286a627ef56a8c1fd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5287
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agojtag: replace command "jtag_reset" with "adapter [de]assert" 86/5286/3
Antonio Borneo [Wed, 14 Aug 2019 12:51:06 +0000 (14:51 +0200)]
jtag: replace command "jtag_reset" with "adapter [de]assert"

Replace the JTAG transport specific command with a more generic
one. Deprecate "jtag_reset" and update the documentation.
While there, fix an error in the documentation, where the command
"jtag_reset" was used in place of command "reset_config".

Change-Id: I41a988d37ce69f7b35a960cbaf5306aab0299b99
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5286
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 years agoadapter: add command "adapter [de]assert srst|trst [[de]assert srst|trst]" 77/5277/5
Antonio Borneo [Thu, 10 Jan 2019 09:58:15 +0000 (10:58 +0100)]
adapter: add command "adapter [de]assert srst|trst [[de]assert srst|trst]"

Inspired from http://openocd.zylin.com/#/c/3720/1

Add commands to control the adapter's signals srst and trst.
Add macros for the flag's values assert/deassert to make clear what
they mean and to propose a uniform set of values across the code.

Change-Id: Ia8b13f4ded892942916cad7bda49540a896e7218
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5277
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)